I found this snippet of code on nehe's opengl site, from tutorial 2
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
Yes. I don't have a great eye for such things. One could add fullscreen Anti-alaising easily.
If you change aspect ratios you get distrortions (say 640x480 stretched to 1440x900) I don't have float support in my injector ( I push the floats by hand ) so I didn't want to do a Best-Fit calculation
If you wish to see for yourself: here is the POC code for this project:
and as mentioned in that thread I added windowed mode and a stretchable window to a different game here (source code)