Original Post
Two problems today making me irritated.
/***************************/
The first problem is that im going to make a small billiard-game. Yet i dont have information of what resolution theyll run my game in. It will probably be 1280-800 or the other one (whatever it is, cant fínd it in my papers). I use fullscreen with this guy:
glutFullScreen();
Then i try to get the resolution of the window using the following guy:
glGetIntegerv(GL_VIEWPORT, Pi);
Pi[2] and Pi[3] is suppose to be the width and the height. But they return 300, 300 pixels. If i set glutInitWindowSize(x, y); before running glutFullScreen; i get x, y from glGetIntegerv();
When i run glGetIntegerv anywhere else in the program after my initialization-commands (Edit: initalization = everything before glutMainLoop()) i get the correct size of the screen, but while setting up the screen i get everything but the correct size. Ive tried to run my "glutDisplayFunc"ion and my "glutReshapeFunc"ion. But it wont make any difference. So how do i get the size of my screen before i start the program?
/***************************/
My second problem is the geometry of my program that fails.
I put my camera at [0,0,8] and I set my upvector towards [0,1,0]. It is looking down on the billiard table which lies on the (z=0)-plane. I setup my viewport in the following manner:
gluPerspective(60, width/height, 1, 30);
this should meant that (if i understood this stuff correctly) i can see the points [-x, -y, 0] and [x, y, 0] on my billiard-table-plane where
x = 8 sin(30)*width/height = 4*width/height
y = 8 sin(30) = 4
This is true for all resolutions if i only multiply x and y with approximately 1.14
Who is 1.14 and where is this guy coming from? Or have i misunderstood everything? (Edit: I try to hit the balls with the mouse, therefore i need to know where on the billiard-table i have the mouse.)
[Edited by - slutbit on June 10, 2010 9:48:07 AM]
/***************************/
The first problem is that im going to make a small billiard-game. Yet i dont have information of what resolution theyll run my game in. It will probably be 1280-800 or the other one (whatever it is, cant fínd it in my papers). I use fullscreen with this guy:
glutFullScreen();
Then i try to get the resolution of the window using the following guy:
glGetIntegerv(GL_VIEWPORT, Pi);
Pi[2] and Pi[3] is suppose to be the width and the height. But they return 300, 300 pixels. If i set glutInitWindowSize(x, y); before running glutFullScreen; i get x, y from glGetIntegerv();
When i run glGetIntegerv anywhere else in the program after my initialization-commands (Edit: initalization = everything before glutMainLoop()) i get the correct size of the screen, but while setting up the screen i get everything but the correct size. Ive tried to run my "glutDisplayFunc"ion and my "glutReshapeFunc"ion. But it wont make any difference. So how do i get the size of my screen before i start the program?
/***************************/
My second problem is the geometry of my program that fails.
I put my camera at [0,0,8] and I set my upvector towards [0,1,0]. It is looking down on the billiard table which lies on the (z=0)-plane. I setup my viewport in the following manner:
gluPerspective(60, width/height, 1, 30);
this should meant that (if i understood this stuff correctly) i can see the points [-x, -y, 0] and [x, y, 0] on my billiard-table-plane where
x = 8 sin(30)*width/height = 4*width/height
y = 8 sin(30) = 4
This is true for all resolutions if i only multiply x and y with approximately 1.14
Who is 1.14 and where is this guy coming from? Or have i misunderstood everything? (Edit: I try to hit the balls with the mouse, therefore i need to know where on the billiard-table i have the mouse.)
[Edited by - slutbit on June 10, 2010 9:48:07 AM]