2014-04-09 01:04:25 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2014-04-06 22:55:39 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-08-24 02:00:08 +02:00
|
|
|
#include "generated/gl_3_2_core.h"
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-04-09 02:15:08 +02:00
|
|
|
#include "common/common.h"
|
2014-08-28 20:21:54 +02:00
|
|
|
#include "core/hw/gpu.h"
|
2014-04-09 02:15:08 +02:00
|
|
|
#include "video_core/renderer_base.h"
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-21 09:27:53 +02:00
|
|
|
#include <array>
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-28 20:21:54 +02:00
|
|
|
class EmuWindow;
|
|
|
|
|
2014-08-28 10:51:57 +02:00
|
|
|
class RendererOpenGL : public RendererBase {
|
2014-04-06 22:55:39 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
RendererOpenGL();
|
2014-08-28 10:51:57 +02:00
|
|
|
~RendererOpenGL() override;
|
2014-04-06 22:55:39 +02:00
|
|
|
|
|
|
|
/// Swap buffers (render frame)
|
|
|
|
void SwapBuffers();
|
|
|
|
|
2014-08-21 09:27:53 +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);
|
|
|
|
|
|
|
|
/// Initialize the renderer
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
/// Shutdown the renderer
|
|
|
|
void ShutDown();
|
|
|
|
|
|
|
|
private:
|
2014-08-28 20:21:54 +02:00
|
|
|
/// Structure used for storing information about the textures for each 3DS screen
|
|
|
|
struct TextureInfo {
|
|
|
|
GLuint handle;
|
|
|
|
GLsizei width;
|
|
|
|
GLsizei height;
|
|
|
|
};
|
|
|
|
|
2014-08-28 11:34:47 +02:00
|
|
|
void InitOpenGLObjects();
|
|
|
|
void DrawScreens();
|
2014-08-28 20:21:54 +02:00
|
|
|
void DrawSingleScreenRotated(const TextureInfo& texture, float x, float y, float w, float h);
|
2014-04-06 22:55:39 +02:00
|
|
|
void UpdateFramerate();
|
|
|
|
|
2014-08-28 20:21:54 +02:00
|
|
|
// Loads framebuffer from emulated memory into the active OpenGL texture.
|
|
|
|
static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
|
|
|
|
const TextureInfo& texture);
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-21 09:27:53 +02:00
|
|
|
EmuWindow* render_window; ///< Handle to render window
|
|
|
|
u32 last_mode; ///< Last render mode
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-21 09:27:53 +02:00
|
|
|
int resolution_width; ///< Current resolution width
|
|
|
|
int resolution_height; ///< Current resolution height
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-28 20:21:54 +02:00
|
|
|
// OpenGL object IDs
|
|
|
|
GLuint vertex_array_handle;
|
|
|
|
GLuint vertex_buffer_handle;
|
2014-08-21 09:27:53 +02:00
|
|
|
GLuint program_id;
|
2014-08-28 20:21:54 +02:00
|
|
|
std::array<TextureInfo, 2> textures;
|
|
|
|
// Shader uniform location indices
|
|
|
|
GLuint uniform_modelview_matrix;
|
|
|
|
GLuint uniform_color_texture;
|
2014-08-28 10:37:07 +02:00
|
|
|
// Shader attribute input indices
|
|
|
|
GLuint attrib_position;
|
2014-08-28 20:21:54 +02:00
|
|
|
GLuint attrib_tex_coord;
|
2014-07-11 19:40:34 +02:00
|
|
|
};
|