From 3b06773f438197dbfc6ff0f7cf985cba30730ec6 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 28 Nov 2013 09:53:05 +0700 Subject: [PATCH] (R): Rewrite OGL_SwapBuffers() and use it for all platforms. --- FrameBuffer.cpp | 6 +----- GLSLCombiner.cpp | 4 ++-- OpenGL.cpp | 17 ++++++++--------- OpenGL.h | 2 -- VI.cpp | 4 ---- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 155c3029..f6fef2e5 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -460,11 +460,7 @@ void FrameBuffer_RenderBuffer( u32 address ) } ogl_glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo); -#ifndef __LINUX__ - SwapBuffers( OGL.hDC ); -#else - OGL_SwapBuffers(); -#endif + OGL_SwapBuffers(); } #else diff --git a/GLSLCombiner.cpp b/GLSLCombiner.cpp index ded2b2cd..007c858c 100644 --- a/GLSLCombiner.cpp +++ b/GLSLCombiner.cpp @@ -719,7 +719,7 @@ void GLSL_RenderDepth() { v1 = 1.0; ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -#ifndef __LINUX__ +#ifdef _WINDOWS glDrawBuffer( GL_FRONT ); #else glDrawBuffer( GL_BACK ); @@ -737,7 +737,7 @@ void GLSL_RenderDepth() { glTexCoord2f( u1, 0.0f ); glVertex2f( (GLfloat)OGL.width, 0.0f ); glEnd(); -#ifndef __LINUX__ +#ifdef _WINDOWS glDrawBuffer( GL_BACK ); #else OGL_SwapBuffers(); diff --git a/OpenGL.cpp b/OpenGL.cpp index 5455f028..1beab020 100644 --- a/OpenGL.cpp +++ b/OpenGL.cpp @@ -310,11 +310,7 @@ void OGL_InitStates() ((i > (rand() >> 10)) << 0); } -#ifndef __LINUX__ - SwapBuffers( wglGetCurrentDC() ); -#else OGL_SwapBuffers(); -#endif } void OGL_UpdateScale() @@ -1154,10 +1150,14 @@ void OGL_ReadScreen( void **dest, long *width, long *height ) glReadPixels( 0, OGL.heightOffset, OGL.width, OGL.height, GL_BGR_EXT, GL_UNSIGNED_BYTE, *dest ); } -#ifdef __LINUX__ -void -OGL_SwapBuffers() +void OGL_SwapBuffers() { +#ifdef _WINDOWS + if (OGL.hDC == NULL) + SwapBuffers( wglGetCurrentDC() ); + else + SwapBuffers( OGL.hDC ); +#else static int frames[5] = { 0, 0, 0, 0, 0 }; static int framesIndex = 0; static Uint32 lastTicks = 0; @@ -1179,10 +1179,9 @@ OGL_SwapBuffers() } SDL_GL_SwapBuffers(); +#endif // _WINDOWS } -#endif // __LINUX__ - void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers) { switch (OGL.framebuffer_mode) { case GLInfo::fbFBO: diff --git a/OpenGL.h b/OpenGL.h index f3a81b25..e5fbe259 100644 --- a/OpenGL.h +++ b/OpenGL.h @@ -187,9 +187,7 @@ void OGL_ClearDepthBuffer(); void OGL_ClearColorBuffer( float *color ); void OGL_ResizeWindow(); void OGL_SaveScreenshot(); -#ifdef __LINUX__ void OGL_SwapBuffers(); -#endif // __LINUX__ void OGL_ReadScreen( void **dest, long *width, long *height ); void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers); diff --git a/VI.cpp b/VI.cpp index 622eeeef..2ca79b47 100644 --- a/VI.cpp +++ b/VI.cpp @@ -86,11 +86,7 @@ void VI_UpdateScreen() } else { if (gSP.changed & CHANGED_COLORBUFFER) { -#ifndef __LINUX__ - SwapBuffers( OGL.hDC ); -#else OGL_SwapBuffers(); -#endif gSP.changed &= ~CHANGED_COLORBUFFER; #ifdef DEBUG while (Debug.paused && !Debug.step);