#### Archived

This topic is now archived and is closed to further replies.

This topic is 5650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

im working on a simple opengl fps "game", and i want to make a menu screen along with a title screen etc., how would i go about making a 2d box appear on my screen and have it completely cover the screen (its in fullscreen), with out going over the edge of the screen? thanks

##### Share on other sites
Okay, do your normal buffer clear stuff, then insert this:
glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0,640,480,0,-1,1);glMatrixMode(GL_MODELVIEW);glLoadIdentity();

Then, just bind your texture and
glBegin(GL_QUADS);   glTexCoord2f(0,1);   glVertex2i(0,0);   glTexCoord2f(0,0);   glVertex2i(0,480);   glTexCoord2f(1,0);   glVertex2f(640,480);   glTexCoord2f(1,1);   glVertex2i(640,0);glEnd();

Hope that helps. If you have any questions, feel free to ask.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

##### Share on other sites
thanks, that works good, i have it set up so that its toggled on pressing space, when i switch from the code u gave me to me game, everything is black and i cant see my crappy game, do u know how i might fix this?, thanks

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

##### Share on other sites
Yupyup, you gotta reset your perspective. Here''s my code, though you probably already have something better (hint: you should be calling something similar to this in response to WM_SIZE).
glMatrixMode(GL_PROJECTION);glLoadIdentity();glFrustum (Left, Right, Bottom, Top, Near, Far);glMatrixMode(GL_MODELVIEW);

You most likely use the function gluPerspective. Same thing.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

##### Share on other sites
im sorry, im still learning OGL, its probably pretty obvious, i dont know where to put that code, i cant seem to find a good place, do i put it at the end of the function that draws the level? its not working there

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

##### Share on other sites
Okay, here''s the deal. Whenever you want to display your menu, call the glClear function, etc., then call the first bit of code I gave you (glOrtho and so on). You finish up your drawing with a call to SwapBuffers. To tell you what you need to do when drawing your game, I''ll need to see the code you call from your WndProc whenever you receive a WM_SIZE message. Overall, it should looks something like this:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity(); // don''t think this is really necessary...if(Keydown(SPACEBAR)) // or whatever{    // glOrtho code block    // draw your menu}else{    // perspective code block    // do game drawing}SwapBuffers(hDC); // e.g.

Of course, I split most of the projection switching code into its own function so I can make multiple calls (e.g. when drawing a HUD) to swap between orthographic and perspective, and you can also split of menu drawing into its own function...just do whatever you want, but I''ll need your perspective correction code (as stated above) in order to help you further.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

##### Share on other sites
AHHH, there i got it, i noticed that NeHe(im using his base code) has made a funtion for resetting the perspective, it works, thankyou for all your help, and thankyou for being so patient with me.

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

##### Share on other sites
My pleasure. Good luck in your future endeavors.

Peace,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

• ### Forum Statistics

• Total Topics
628642
• Total Posts
2983998

• 9
• 9
• 10
• 21
• 20