From 6a90061fb793fcdb7d71f86f0bfbcf5c1e66cb2a Mon Sep 17 00:00:00 2001 From: squall_leonhart69r Date: Fri, 1 Feb 2008 09:11:34 +0000 Subject: [PATCH] Reverts Spacy's Divide by Zero fix that caused GBA rom white screen (mudlord) Note, spacy, in the future, have mudlord check any code you want to commit to svn, or have him fix the bug. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@349 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/OpenGL.cpp | 84 ++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/src/win32/OpenGL.cpp b/src/win32/OpenGL.cpp index ef77fa7a..12ccbad9 100644 --- a/src/win32/OpenGL.cpp +++ b/src/win32/OpenGL.cpp @@ -46,28 +46,7 @@ #include #include "glFont.h" #include - - typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int ); -/*We need to declare the procs for these functions like this -If anyone's got a better solution, I'd love to see it =D */ -PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL; -PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL; -PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL; -PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL; -PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL; -PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL; -PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = NULL; -PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL; -PFNGLGETINFOLOGARBPROC glGetInfoLogARB = NULL; -PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL; -PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL; -PFNGLUNIFORM4FARBPROC glUniform4fARB = NULL; -PFNGLUNIFORM1IARBPROC glUniform1iARB = NULL; - - - - extern int Init_2xSaI(u32); extern void winlog(const char *,...); extern int systemSpeed; @@ -94,7 +73,6 @@ private: u8 *filterData; RECT destRect; bool failed; - bool initialized; GLFONT font; int pitch; GLuint displaylist; @@ -170,7 +148,6 @@ OpenGLDisplay::OpenGLDisplay() height = 0; size = 0.0f; failed = false; - initialized = false; filterData = NULL; currentAdapter = 0; } @@ -235,8 +212,6 @@ void OpenGLDisplay::cleanup() EnumDisplayDevices( NULL, currentAdapter, &dev, 0 ); // restore default video mode ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL ); - - initialized = false; } //init renderer @@ -274,9 +249,6 @@ bool OpenGLDisplay::initialize() ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL ); } - width = theApp.rect.right; - height = theApp.rect.bottom; - EnableOpenGL(); initializeFont(); glPushAttrib( GL_ENABLE_BIT ); @@ -315,7 +287,6 @@ bool OpenGLDisplay::initialize() if(failed) return false; - initialized = true; return true; } @@ -329,7 +300,7 @@ void OpenGLDisplay::clear() //dlist void OpenGLDisplay::renderlist() { - displaylist = glGenLists(1); //Generate a List + displaylist = glGenLists(1); //set the cube list to Generate a List glNewList(displaylist,GL_COMPILE); //compile the new list glBegin( GL_QUADS ); @@ -429,15 +400,13 @@ void OpenGLDisplay::render() //resize screen void OpenGLDisplay::resize( int w, int h ) { - if( initialized ) { - initializeMatrices( w, h ); - /* Display lists are not mutable, so we have to do this*/ - if (displaylist) - { - glDeleteLists(displaylist, 1); - displaylist = 0; - renderlist(); - } + initializeMatrices( w, h ); + /* Display lists are not mutable, so we have to do this*/ + if (displaylist) + { + glDeleteLists(displaylist, 1); + displaylist = 0; + renderlist(); } } @@ -486,6 +455,12 @@ void OpenGLDisplay::initializeMatrices( int w, int h ) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + if (displaylist) + { + glDeleteLists(displaylist, 1); + displaylist = 0; + renderlist(); + } } //init font texture @@ -557,20 +532,18 @@ void OpenGLDisplay::setVSync( int interval ) bool OpenGLDisplay::changeRenderSize( int w, int h ) { if( (width != w) || (height != h) ) { - if( initialized ) { - if( texture != 0 ) { - glDeleteTextures( 1, &texture ); - texture = 0; - } - - if( !initializeTexture( w, h ) ) { - failed = true; - return false; - } - if (filterData) - free(filterData); - filterData = (u8 *)malloc(4*w*h); + if( texture != 0 ) { + glDeleteTextures( 1, &texture ); + texture = 0; } + + if( !initializeTexture( w, h ) ) { + failed = true; + return false; + } + if (filterData) + free(filterData); + filterData = (u8 *)malloc(4*w*h); } if (displaylist) { @@ -586,7 +559,6 @@ void OpenGLDisplay::calculateDestRect( int w, int h ) { float scaleX = (float)w / (float)width; float scaleY = (float)h / (float)height; - float min = (scaleX < scaleY) ? scaleX : scaleY; if( theApp.fsMaxScale && (min > theApp.fsMaxScale) ) { min = (float)theApp.fsMaxScale; @@ -605,6 +577,12 @@ void OpenGLDisplay::calculateDestRect( int w, int h ) destRect.top += diff; destRect.bottom += diff; } + if (displaylist) + { + glDeleteLists(displaylist, 1); + displaylist = 0; + renderlist(); + } } //config options