1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

(R): Rewrite OGL_SwapBuffers() and use it for all platforms.

This commit is contained in:
Sergey Lipskiy 2013-11-28 09:53:05 +07:00
parent 67b9a3dd1f
commit 3b06773f43
5 changed files with 11 additions and 22 deletions

View File

@ -460,11 +460,7 @@ void FrameBuffer_RenderBuffer( u32 address )
} }
ogl_glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); ogl_glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo); ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
#ifndef __LINUX__ OGL_SwapBuffers();
SwapBuffers( OGL.hDC );
#else
OGL_SwapBuffers();
#endif
} }
#else #else

View File

@ -719,7 +719,7 @@ void GLSL_RenderDepth() {
v1 = 1.0; v1 = 1.0;
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
#ifndef __LINUX__ #ifdef _WINDOWS
glDrawBuffer( GL_FRONT ); glDrawBuffer( GL_FRONT );
#else #else
glDrawBuffer( GL_BACK ); glDrawBuffer( GL_BACK );
@ -737,7 +737,7 @@ void GLSL_RenderDepth() {
glTexCoord2f( u1, 0.0f ); glTexCoord2f( u1, 0.0f );
glVertex2f( (GLfloat)OGL.width, 0.0f ); glVertex2f( (GLfloat)OGL.width, 0.0f );
glEnd(); glEnd();
#ifndef __LINUX__ #ifdef _WINDOWS
glDrawBuffer( GL_BACK ); glDrawBuffer( GL_BACK );
#else #else
OGL_SwapBuffers(); OGL_SwapBuffers();

View File

@ -310,11 +310,7 @@ void OGL_InitStates()
((i > (rand() >> 10)) << 0); ((i > (rand() >> 10)) << 0);
} }
#ifndef __LINUX__
SwapBuffers( wglGetCurrentDC() );
#else
OGL_SwapBuffers(); OGL_SwapBuffers();
#endif
} }
void OGL_UpdateScale() 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 ); 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 frames[5] = { 0, 0, 0, 0, 0 };
static int framesIndex = 0; static int framesIndex = 0;
static Uint32 lastTicks = 0; static Uint32 lastTicks = 0;
@ -1179,10 +1179,9 @@ OGL_SwapBuffers()
} }
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
#endif // _WINDOWS
} }
#endif // __LINUX__
void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers) { void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers) {
switch (OGL.framebuffer_mode) { switch (OGL.framebuffer_mode) {
case GLInfo::fbFBO: case GLInfo::fbFBO:

View File

@ -187,9 +187,7 @@ void OGL_ClearDepthBuffer();
void OGL_ClearColorBuffer( float *color ); void OGL_ClearColorBuffer( float *color );
void OGL_ResizeWindow(); void OGL_ResizeWindow();
void OGL_SaveScreenshot(); void OGL_SaveScreenshot();
#ifdef __LINUX__
void OGL_SwapBuffers(); void OGL_SwapBuffers();
#endif // __LINUX__
void OGL_ReadScreen( void **dest, long *width, long *height ); void OGL_ReadScreen( void **dest, long *width, long *height );
void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers); void ogl_glGenFramebuffers (GLsizei n, GLuint *framebuffers);

4
VI.cpp
View File

@ -86,11 +86,7 @@ void VI_UpdateScreen()
} }
else { else {
if (gSP.changed & CHANGED_COLORBUFFER) { if (gSP.changed & CHANGED_COLORBUFFER) {
#ifndef __LINUX__
SwapBuffers( OGL.hDC );
#else
OGL_SwapBuffers(); OGL_SwapBuffers();
#endif
gSP.changed &= ~CHANGED_COLORBUFFER; gSP.changed &= ~CHANGED_COLORBUFFER;
#ifdef DEBUG #ifdef DEBUG
while (Debug.paused && !Debug.step); while (Debug.paused && !Debug.step);