FIXED division by 0

This commit is contained in:
spacy51 2008-01-22 13:27:31 +00:00
parent 2aebee7acb
commit 6abce5085e
1 changed files with 30 additions and 17 deletions

View File

@ -95,6 +95,7 @@ private:
u8 *filterData;
RECT destRect;
bool failed;
bool initialized;
GLFONT font;
int pitch;
GLuint displaylist;
@ -170,6 +171,7 @@ OpenGLDisplay::OpenGLDisplay()
height = 0;
size = 0.0f;
failed = false;
initialized = false;
filterData = NULL;
currentAdapter = 0;
}
@ -234,6 +236,8 @@ void OpenGLDisplay::cleanup()
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
// restore default video mode
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
initialized = false;
}
//init renderer
@ -271,6 +275,9 @@ bool OpenGLDisplay::initialize()
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
}
width = theApp.rect.right;
height = theApp.rect.bottom;
EnableOpenGL();
initializeFont();
glPushAttrib( GL_ENABLE_BIT );
@ -309,6 +316,7 @@ bool OpenGLDisplay::initialize()
if(failed)
return false;
initialized = true;
return true;
}
@ -422,6 +430,7 @@ 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)
@ -430,6 +439,7 @@ void OpenGLDisplay::resize( int w, int h )
displaylist = 0;
renderlist();
}
}
}
//update filtering methods
@ -548,6 +558,7 @@ 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;
@ -561,6 +572,7 @@ bool OpenGLDisplay::changeRenderSize( int w, int h )
free(filterData);
filterData = (u8 *)malloc(4*w*h);
}
}
if (displaylist)
{
glDeleteLists(displaylist, 1);
@ -575,6 +587,7 @@ 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;