blob: d440e2bc79a28d26cd95a3e41eaf3927f2a80278 (
plain) (
tree)
|
|
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "generated/gl_3_2_core.h"
#include "common/common.h"
#include "core/hw/gpu.h"
#include "video_core/renderer_base.h"
#include <array>
class EmuWindow;
class RendererOpenGL : public RendererBase {
public:
RendererOpenGL();
~RendererOpenGL() override;
/// Swap buffers (render frame)
void SwapBuffers() override;
/**
* Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering
*/
void SetWindow(EmuWindow* window) override;
/// Initialize the renderer
void Init() override;
/// Shutdown the renderer
void ShutDown() override;
private:
/// Structure used for storing information about the textures for each 3DS screen
struct TextureInfo {
GLuint handle;
GLsizei width;
GLsizei height;
};
void InitOpenGLObjects();
void DrawScreens();
void DrawSingleScreenRotated(const TextureInfo& texture, float x, float y, float w, float h);
void UpdateFramerate();
// Loads framebuffer from emulated memory into the active OpenGL texture.
static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
const TextureInfo& texture);
/// Updates the viewport rectangle
void UpdateViewportExtent();
EmuWindow* render_window; ///< Handle to render window
u32 last_mode; ///< Last render mode
int resolution_width; ///< Current resolution width
int resolution_height; ///< Current resolution height
struct {
int width;
int height;
} framebuffer_size; ///< Current framebuffer size
struct {
int x;
int y;
int width;
int height;
} viewport_extent; ///< Current viewport rectangle
// OpenGL object IDs
GLuint vertex_array_handle;
GLuint vertex_buffer_handle;
GLuint program_id;
std::array<TextureInfo, 2> textures;
// Shader uniform location indices
GLuint uniform_modelview_matrix;
GLuint uniform_color_texture;
// Shader attribute input indices
GLuint attrib_position;
GLuint attrib_tex_coord;
};
|