FIXED division by 0

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@332 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2008-01-22 13:27:31 +00:00
parent 92198f10d5
commit 39ffa7eee5
1 changed files with 30 additions and 17 deletions

View File

@ -95,6 +95,7 @@ private:
u8 *filterData; u8 *filterData;
RECT destRect; RECT destRect;
bool failed; bool failed;
bool initialized;
GLFONT font; GLFONT font;
int pitch; int pitch;
GLuint displaylist; GLuint displaylist;
@ -170,6 +171,7 @@ OpenGLDisplay::OpenGLDisplay()
height = 0; height = 0;
size = 0.0f; size = 0.0f;
failed = false; failed = false;
initialized = false;
filterData = NULL; filterData = NULL;
currentAdapter = 0; currentAdapter = 0;
} }
@ -234,6 +236,8 @@ void OpenGLDisplay::cleanup()
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 ); EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
// restore default video mode // restore default video mode
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL ); ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
initialized = false;
} }
//init renderer //init renderer
@ -271,6 +275,9 @@ bool OpenGLDisplay::initialize()
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL ); ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
} }
width = theApp.rect.right;
height = theApp.rect.bottom;
EnableOpenGL(); EnableOpenGL();
initializeFont(); initializeFont();
glPushAttrib( GL_ENABLE_BIT ); glPushAttrib( GL_ENABLE_BIT );
@ -309,6 +316,7 @@ bool OpenGLDisplay::initialize()
if(failed) if(failed)
return false; return false;
initialized = true;
return true; return true;
} }
@ -422,13 +430,15 @@ void OpenGLDisplay::render()
//resize screen //resize screen
void OpenGLDisplay::resize( int w, int h ) void OpenGLDisplay::resize( int w, int h )
{ {
initializeMatrices( w, h ); if( initialized ) {
/* Display lists are not mutable, so we have to do this*/ initializeMatrices( w, h );
if (displaylist) /* Display lists are not mutable, so we have to do this*/
{ if (displaylist)
glDeleteLists(displaylist, 1); {
displaylist = 0; glDeleteLists(displaylist, 1);
renderlist(); displaylist = 0;
renderlist();
}
} }
} }
@ -548,18 +558,20 @@ void OpenGLDisplay::setVSync( int interval )
bool OpenGLDisplay::changeRenderSize( int w, int h ) bool OpenGLDisplay::changeRenderSize( int w, int h )
{ {
if( (width != w) || (height != h) ) { if( (width != w) || (height != h) ) {
if( texture != 0 ) { if( initialized ) {
glDeleteTextures( 1, &texture ); if( texture != 0 ) {
texture = 0; glDeleteTextures( 1, &texture );
} texture = 0;
}
if( !initializeTexture( w, h ) ) { if( !initializeTexture( w, h ) ) {
failed = true; failed = true;
return false; return false;
}
if (filterData)
free(filterData);
filterData = (u8 *)malloc(4*w*h);
} }
if (filterData)
free(filterData);
filterData = (u8 *)malloc(4*w*h);
} }
if (displaylist) if (displaylist)
{ {
@ -575,6 +587,7 @@ void OpenGLDisplay::calculateDestRect( int w, int h )
{ {
float scaleX = (float)w / (float)width; float scaleX = (float)w / (float)width;
float scaleY = (float)h / (float)height; float scaleY = (float)h / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY; float min = (scaleX < scaleY) ? scaleX : scaleY;
if( theApp.fsMaxScale && (min > theApp.fsMaxScale) ) { if( theApp.fsMaxScale && (min > theApp.fsMaxScale) ) {
min = (float)theApp.fsMaxScale; min = (float)theApp.fsMaxScale;