OpenGL renderer: Shuffle initialization code around and rename functions.
This commit is contained in:
parent
787a1b047c
commit
5f598a5e2c
|
@ -81,7 +81,7 @@ void RendererOpenGL::SwapBuffers() {
|
||||||
RenderXFB(framebuffer_size, framebuffer_size);
|
RenderXFB(framebuffer_size, framebuffer_size);
|
||||||
|
|
||||||
// XFB->Window copy
|
// XFB->Window copy
|
||||||
RenderFramebuffer();
|
DrawScreens();
|
||||||
|
|
||||||
// Swap buffers
|
// Swap buffers
|
||||||
render_window->PollEvents();
|
render_window->PollEvents();
|
||||||
|
@ -151,8 +151,16 @@ void RendererOpenGL::RenderXFB(const Common::Rect& src_rect, const Common::Rect&
|
||||||
// so this may need to be changed (pair for each screen).
|
// so this may need to be changed (pair for each screen).
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize the FBO
|
/**
|
||||||
void RendererOpenGL::InitFramebuffer() {
|
* Initializes the OpenGL state and creates persistent objects.
|
||||||
|
*/
|
||||||
|
void RendererOpenGL::InitOpenGLObjects() {
|
||||||
|
glGenVertexArrays(1, &vertex_array_id);
|
||||||
|
glBindVertexArray(vertex_array_id);
|
||||||
|
|
||||||
|
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
program_id = ShaderUtil::LoadShaders(GLShaders::g_vertex_shader, GLShaders::g_fragment_shader);
|
program_id = ShaderUtil::LoadShaders(GLShaders::g_vertex_shader, GLShaders::g_fragment_shader);
|
||||||
sampler_id = glGetUniformLocation(program_id, "sampler");
|
sampler_id = glGetUniformLocation(program_id, "sampler");
|
||||||
attrib_position = glGetAttribLocation(program_id, "position");
|
attrib_position = glGetAttribLocation(program_id, "position");
|
||||||
|
@ -190,7 +198,10 @@ void RendererOpenGL::InitFramebuffer() {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::RenderFramebuffer() {
|
/**
|
||||||
|
* Draws the emulated screens to the emulator window.
|
||||||
|
*/
|
||||||
|
void RendererOpenGL::DrawScreens() {
|
||||||
glViewport(0, 0, resolution_width, resolution_height);
|
glViewport(0, 0, resolution_width, resolution_height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -253,20 +264,8 @@ void RendererOpenGL::Init() {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate VAO
|
|
||||||
glGenVertexArrays(1, &vertex_array_id);
|
|
||||||
glBindVertexArray(vertex_array_id);
|
|
||||||
|
|
||||||
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
|
|
||||||
// Initialize everything else
|
|
||||||
// --------------------------
|
|
||||||
InitFramebuffer();
|
|
||||||
|
|
||||||
NOTICE_LOG(RENDER, "GL_VERSION: %s\n", glGetString(GL_VERSION));
|
NOTICE_LOG(RENDER, "GL_VERSION: %s\n", glGetString(GL_VERSION));
|
||||||
|
InitOpenGLObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown the renderer
|
/// Shutdown the renderer
|
||||||
|
|
|
@ -42,14 +42,8 @@ public:
|
||||||
void ShutDown();
|
void ShutDown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void InitOpenGLObjects();
|
||||||
/// Initialize the FBO
|
void DrawScreens();
|
||||||
void InitFramebuffer();
|
|
||||||
|
|
||||||
// Blit the FBO to the OpenGL default framebuffer
|
|
||||||
void RenderFramebuffer();
|
|
||||||
|
|
||||||
/// Updates the framerate
|
|
||||||
void UpdateFramerate();
|
void UpdateFramerate();
|
||||||
|
|
||||||
/// Structure used for storing information for rendering each 3DS screen
|
/// Structure used for storing information for rendering each 3DS screen
|
||||||
|
|
Loading…
Reference in New Issue