[OpenGL] Shuffle initialization code around and rename functions.

This commit is contained in:
Yuri Kunde Schlesner 2014-08-28 06:34:47 -03:00
parent 83973f3ba6
commit 7aae063844
2 changed files with 18 additions and 26 deletions

View file

@ -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

View file

@ -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