PDA

View Full Version : Resize Window But Not Models



Lazloo
12-21-2014, 09:30 AM
Hy Guys,

I have a Problem. Right now I try to implement my own small 2D-Game. I would like to change the windows size (e.g. going to full screen). However I also want that the size of the models do not change. Therefore I wrote a function to do all the necessary settings:




void basicOpenGLOperations::checkWindowSize(void){

glfwGetWindowSize(WindowMember,&WindowWidth,&WindowHeight);
ViewRatio = static_cast<GLfloat>(WindowWidth)/static_cast<GLfloat>(WindowHeight);
ProjectionMatrix = glm::perspective(ViewField,ViewRatio,0.1f,100.0f);

glOrtho(-1.0, // Left
1.0, // Right
-1.0 / (WindowWidth / WindowHeight), // Bottom
1.0 / (WindowWidth / WindowHeight), // Top
0.01, // Near
10000.0); // Far
glViewport(0, 0, WindowWidth, WindowHeight);
}


All models are actual rectangle (2xTriangles) with textures. Interestingly, everything works fine works fine if I only change the width of the window. However if I change the height all models are resized as well