Screen width/height and Viewport
In Nehe''s code for the window alone I don''t know where about the variable width is filled with the screen width (also with height) so could someone tell me.
Another thing is, My screen resolution is 1024x768, I set the rez of my game to 1024x768, but if I maximise the window, the width and height change because my viewport changes (which I don''t want in what I''m doing) and I don''t know the width and height of a maximised window ????
Tanks
You can use GetSystemMetrics in Windows to get the resolution of the screen.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://druidgames.cjb.net/
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://druidgames.cjb.net/
Do you have any idea why this doesn''t work. I want to put the "graphics" in the top left quarter of the whole screen and I want it to be orthographic projection so I did this.
///**********width & height are window width & height********
glViewport(0,_height/2,_width/2,_height);
glOrtho(0,width,height,0,-1.0f,1.0f);
>.................Other Stuff.................<
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,_height);
glVertex2f(_width,_height);
glVertex2f(_width,0.0f);
glEnd();
glColor3f(1.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,_height/2);
glVertex2f(_width/2,_height/2);
glVertex2f(_width/2,0.0f);
glEnd();
Now the problem is that the 2nd quad is never drawn when the viewport is changed to what I set it, whats wierder is the fact that if I leave the viewport to normal it draws the whole screen blue and a small red square in the top left likes it supposed to. But if I make the viewport to the smaller one it draws a quarter of the screen blue (thats normal) but doesn''t draw the smaller red quad. I really can''t understand why this happens, I can''t find a fault with what I''m doing. Could someone please enlighten me before I explode =(
///**********width & height are window width & height********
glViewport(0,_height/2,_width/2,_height);
glOrtho(0,width,height,0,-1.0f,1.0f);
>.................Other Stuff.................<
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,_height);
glVertex2f(_width,_height);
glVertex2f(_width,0.0f);
glEnd();
glColor3f(1.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,_height/2);
glVertex2f(_width/2,_height/2);
glVertex2f(_width/2,0.0f);
glEnd();
Now the problem is that the 2nd quad is never drawn when the viewport is changed to what I set it, whats wierder is the fact that if I leave the viewport to normal it draws the whole screen blue and a small red square in the top left likes it supposed to. But if I make the viewport to the smaller one it draws a quarter of the screen blue (thats normal) but doesn''t draw the smaller red quad. I really can''t understand why this happens, I can''t find a fault with what I''m doing. Could someone please enlighten me before I explode =(
OK, I seem to have discovered something, i think the box is being drawn but off screen, its as if my viewport is half onscreen and half offscreen. But if I define my viewport as:
glViewport(0,height/2,width/2,height);
This should mean that the top of the viewport is at "height" and if height is my window height (default 1024) then the top of the viewport should be at the top of my window instead of "above" it. Can anyone explain this or the correct way to display to the top quarter of the screen ( i presume i must use the viewport, so I can display different ''screens'' in the other quarters a la multiplayer split screen) or what is wrong with what I am doing?
glViewport(0,height/2,width/2,height);
This should mean that the top of the viewport is at "height" and if height is my window height (default 1024) then the top of the viewport should be at the top of my window instead of "above" it. Can anyone explain this or the correct way to display to the top quarter of the screen ( i presume i must use the viewport, so I can display different ''screens'' in the other quarters a la multiplayer split screen) or what is wrong with what I am doing?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement