citra/src/video_core/renderer_opengl/renderer_opengl.h

83 lines
2.5 KiB
C
Raw Normal View History

2014-04-09 01:04:25 +02:00
// Copyright 2014 Citra Emulator Project
2014-12-17 06:38:14 +01:00
// Licensed under GPLv2 or any later version
2014-04-09 01:04:25 +02:00
// Refer to the license.txt file included.
2014-04-06 22:55:39 +02:00
#pragma once
#include <array>
#include <glad/glad.h>
2014-04-06 22:55:39 +02:00
#include "core/hw/gpu.h"
2014-04-06 22:55:39 +02:00
#include "video_core/renderer_base.h"
2015-05-19 06:21:33 +02:00
#include "video_core/renderer_opengl/gl_state.h"
2014-04-06 22:55:39 +02:00
class EmuWindow;
class RendererOpenGL : public RendererBase {
2014-04-06 22:55:39 +02:00
public:
RendererOpenGL();
~RendererOpenGL() override;
2014-04-06 22:55:39 +02:00
/// Swap buffers (render frame)
void SwapBuffers() override;
2014-04-06 22:55:39 +02:00
/**
2014-04-06 22:55:39 +02:00
* Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering
*/
void SetWindow(EmuWindow* window) override;
2014-04-06 22:55:39 +02:00
/// Initialize the renderer
void Init() override;
2014-04-06 22:55:39 +02:00
/// Shutdown the renderer
void ShutDown() override;
2014-04-06 22:55:39 +02:00
private:
/// Structure used for storing information about the textures for each 3DS screen
struct TextureInfo {
GLuint handle;
GLsizei width;
GLsizei height;
GPU::Regs::PixelFormat format;
GLenum gl_format;
GLenum gl_type;
};
void InitOpenGLObjects();
2015-05-19 06:21:33 +02:00
void ConfigureFramebufferTexture(TextureInfo& texture,
const GPU::Regs::FramebufferConfig& framebuffer);
void DrawScreens();
void DrawSingleScreenRotated(const TextureInfo& texture, float x, float y, float w, float h);
2014-04-06 22:55:39 +02:00
void UpdateFramerate();
// Loads framebuffer from emulated memory into the active OpenGL texture.
2015-05-19 06:21:33 +02:00
void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
const TextureInfo& texture);
// Fills active OpenGL texture with the given RGB color.
2015-05-19 06:21:33 +02:00
void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b,
const TextureInfo& texture);
2014-04-06 22:55:39 +02:00
EmuWindow* render_window; ///< Handle to render window
2014-04-06 22:55:39 +02:00
int resolution_width; ///< Current resolution width
int resolution_height; ///< Current resolution height
2014-04-06 22:55:39 +02:00
2015-05-19 06:21:33 +02:00
OpenGLState state;
// OpenGL object IDs
GLuint vertex_array_handle;
GLuint vertex_buffer_handle;
GLuint program_id;
std::array<TextureInfo, 2> textures; ///< Textures for top and bottom screens respectively
// Shader uniform location indices
GLuint uniform_modelview_matrix;
GLuint uniform_color_texture;
// Shader attribute input indices
GLuint attrib_position;
GLuint attrib_tex_coord;
};