Fixed the window rescaling to do letter/pillar boxing per the email thread.

This commit is contained in:
wrenczes@gmail.com
2011-04-13 04:55:17 +00:00
parent 30a7e7f811
commit 0b821c9b4f
2 changed files with 24 additions and 5 deletions

View File

@@ -822,7 +822,7 @@ void JRenderer::BeginScene()
#ifdef WIN32
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
float scaleW = mActualWidth/SCREEN_WIDTH_F;
glScalef(scaleW,scaleW,1.f);
glScalef(scaleW,scaleH,1.f);
#endif
checkGlError();
}

View File

@@ -145,6 +145,8 @@ enum eDisplayMode
unsigned int gDisplayMode = DisplayMode_lowRes;
const float kActualRatio((GLfloat)SCREEN_WIDTH / (GLfloat)SCREEN_HEIGHT);
DWORD lastTickCount;
BOOL g_keys[256];
@@ -209,16 +211,33 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
JRenderer::GetInstance()->SetActualWidth(static_cast<float>(width));
JRenderer::GetInstance()->SetActualHeight(static_cast<float>(height));
GLsizei adjustedWidth(width);
GLsizei adjustedHeight(height);
GLint x(0);
GLint y(0);
if ((GLfloat)width / (GLfloat)height < kActualRatio)
{
adjustedHeight = (GLsizei)(width / kActualRatio);
y = -(adjustedHeight - height) / 2;
}
else
{
adjustedWidth = (GLsizei)(height * kActualRatio);
x = -(adjustedWidth - width) / 2;
}
glViewport(x, y, adjustedWidth, adjustedHeight);
glScissor(0, 0, width, height);
glViewport (0, 0, width, height); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0.0f, (float) width-1.0f, 0.0f, (float) height -1.0f);
gluOrtho2D(0.0f, (float) width - 1.0f, 0.0f, (float) height - 1.0f);
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity (); // Reset The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glDisable (GL_DEPTH_TEST);
}