From 7aae063844d440a5fe9ab5569222303641978f2a Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Thu, 28 Aug 2014 06:34:47 -0300 Subject: [PATCH] [OpenGL] Shuffle initialization code around and rename functions. --- .../renderer_opengl/renderer_opengl.cpp | 34 +++++++++---------- .../renderer_opengl/renderer_opengl.h | 10 ++---- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index ce90a9754..93bcfcd17 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -81,7 +81,7 @@ void RendererOpenGL::SwapBuffers() { RenderXFB(framebuffer_size, framebuffer_size); // XFB->Window copy - RenderFramebuffer(); + DrawScreens(); // Swap buffers 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). } -/// 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); sampler_id = glGetUniformLocation(program_id, "sampler"); attrib_position = glGetAttribLocation(program_id, "position"); @@ -190,7 +198,10 @@ void RendererOpenGL::InitFramebuffer() { 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); glClear(GL_COLOR_BUFFER_BIT); @@ -254,21 +265,8 @@ void RendererOpenGL::Init() { 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)); + InitOpenGLObjects(); } /// Shutdown the renderer diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 687845d62..c64c7b5c3 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -42,14 +42,8 @@ public: void ShutDown(); private: - - /// Initialize the FBO - void InitFramebuffer(); - - // Blit the FBO to the OpenGL default framebuffer - void RenderFramebuffer(); - - /// Updates the framerate + void InitOpenGLObjects(); + void DrawScreens(); void UpdateFramerate(); /// Structure used for storing information for rendering each 3DS screen