View Full Version : freeGLUT fullscreen small drawing area

09-24-2012, 12:42 PM
When I call glutFullScreen();, my freeGLUT window becomes full screen, but the OGL 3.1 scene is only rendered within a small viewing rectangle in the center of the screen about 700x700 (the monitor is 1366x786). Anything outside thise 700x700 pixel area isn't rendered, even if I'm in fullscreen mode, or if I'm in a windowed mode and drag the window borders beyond 700x700. I searched google for anything that could be causing freeGLUT to do this, but I only found refernces to old glut functions. Is there some way I can fix this or is it a set behavior?

carsten neumann
09-24-2012, 02:29 PM
Do you have a glutResizeFunc() registered? Does it adjust the viewport - or perhaps you set the viewport elsewhere?
How do you determine that rendering is limited to a 700x700 area? Does glClearColor(1.f, 0.f, 0.f, 1.f); glClear(GL_COLOR_BUFFER_BIT); affect the whole window or is it also limited?

09-24-2012, 05:55 PM
I have glutReshapeFunc registered, and this code for when the window resizes:

void ResizeFunction(int Width, int Height)
CurrentWidth = Width;
CurrentHeight = Height;
glViewport(0, 0, CurrentWidth, CurrentHeight);

ProjectionMatrix =
ProjectionMatrixUniformLocation = glGetUniformLocation(ProgramId, "ProjectionMatrix");
glUniformMatrix4fv(ProjectionMatrixUniformLocation , 1, GL_FALSE, ProjectionMatrix.m);
CreateProjectionMatrix creates a projection matrix based on the arguments (field of view, aspect ratio, near plane, far plane):

Matrix CreateProjectionMatrix(
float fovy,
float aspect_ratio,
float near_plane,
float far_plane
Matrix out = { { 0 } };

const float
y_scale = Cotangent(DegreesToRadians(fovy / 2)),
x_scale = y_scale / aspect_ratio,
frustum_length = far_plane - near_plane;

out.m[0] = x_scale;
out.m[5] = y_scale;
out.m[10] = -((far_plane + near_plane) / frustum_length);
out.m[11] = -1;
out.m[14] = -((2 * near_plane * far_plane) / frustum_length);

return out;
Additionally, I have glutKeyboardFunc registered, with this code as part of it:

case 'f':
glutReshapeWindow(800, 600);
Still, whenever I enter fullscreen mode or rescale the window to be large, only vertices within a small central region of the screen (700x700 isn't exact but more a rough guess) are rendered. glClearColor, however, does affect the entire viewport, even the part vertices aren't rendering to.

09-26-2012, 05:19 AM
Sorry for the double post, but I can't seem to edit my prior one. Here's a couple pictures to illustrate what's happening. This is a wireframe of my cube, from some distance away:

And here's the same cube when I zoom in by translating the view matrix (with face culling off):


The cube, and anything else I render, is cut off beyond those boundaries, even though the whole screen is affected by glClearColor. At a guess, it might be something with my projection matrix, but I really don't know. Does anyone have a clue what could be causing something like this?