PDA

View Full Version : Can window size be reshaped with viewport



Lee_Jennifer_82
10-14-2015, 06:26 PM
Hello,
This is just an extension of my previous post. I've the following function which is reshaping the viewport as it is stretched.


void Reshape(GLsizei nWidth, GLsizei nHeight)
{
int windowWidth = glutGet(GLUT_WINDOW_WIDTH);
int windowHeight = glutGet(GLUT_WINDOW_HEIGHT);

GLfloat new_aspect = (float)nWidth / float(nHeight);

if (aspect < new_aspect) {
glViewport(0, 0, nHeight*aspect, nHeight);
}
else if (aspect > new_aspect){
glViewport(0, 0, nWidth, nWidth / aspect);
}
else {
glViewport(0, 0, nWidth, nHeight);
}

}





I'd like to know is it possible to enforce to keep the window size same as viewport while stretching? Thanks again

Alfonse Reinheart
10-14-2015, 08:09 PM
This is just an extension of my previous post.

Then you should have posted it there.


I'd like to know is it possible to enforce to keep the window size same as viewport while stretching?

What do you mean "while stretching"?

This is more of a FreeGLUT question (OpenGL itself doesn't care about windows). It is theoretically possible for you to call glutReshapeWindow to set the size of the window. However, this will not stop the user from being able to drag the size as they see fit. It'll just allow the user to fight with you over the shape of the window. You may always win, but it'll still be a bad user-interface.

FreeGLUT does not have a way for you to force a window to be of a particular size.