PDA

View Full Version : Displaying problems



I_NeedHelp
03-27-2003, 02:16 AM
Ok, here is what i'm trying to do. I want to display a message box telling the user he has crashed (i'm doing a flight game). When the message box appears, i want to have a cracked window behind it. Now in order to achieve the look of a cracked window i'm going to simply apply a texture to a quad which will be the entire size of the screen and mask over it so you can still see the background.
My problem is that instead of seeing the cracked window, i get a blue background the same color as my clear-color. I'm doing all of this outside my main rendering loop. In the top of this function that draws the quad, i've got:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

and at the bottom i've got:
glutSwapBuffers();

Now, my masking is working grand cos i'm using it elsewhere.

Summary, can i have two lines of each above in my program? One in this function and one in my main rendering loop?
It seems to balls up my display

Zengar
03-27-2003, 04:00 AM
You should render WHOLE scene between
glClear ... glutSwapBuffers

glClear...

draw display
draw "crack" texture
draw mesasge window

swap buffers

I hope I did'n miss something...

I_NeedHelp
03-27-2003, 05:02 AM
OK. Just something i didn't mention, when i crash, i reset the game back to starting position. ie the runway. So when i crash i want to display the message with this cracked window as a background, have the user click ok and then redraw the scene with the camera position back at the runway.
Now i'm only a begginner so there is a big chance i'm mistaken but if i do it as you say, i don't think i'll get the same effect?
See, the cracked window only displays while the message box is up then i want it to disappear. The messagebox pauses the program and only when it's gone is the landsacpe drawn again.

Thanks for your reply. I hope i haven't missed something either. Am i right in my thinking?

nexusone
03-27-2003, 05:13 AM
The other poster example was very good as how it should work.

I will try a little more:


void Display( void )
{

// setup to start drawing.
// use perspective view

Draw_3D_scene()

// Now for control panel and information screen.
// switch to ortho view.

if (crash == TRUE)
{
draw_crack();
draw_information_screen();
}

// Swap buffers
}

Just use logic variables to select what is drawn in your display routine.
You also will need to use sometype of blending to bind the images.


Originally posted by I_NeedHelp:
OK. Just something i didn't mention, when i crash, i reset the game back to starting position. ie the runway. So when i crash i want to display the message with this cracked window as a background, have the user click ok and then redraw the scene with the camera position back at the runway.
Now i'm only a begginner so there is a big chance i'm mistaken but if i do it as you say, i don't think i'll get the same effect?
See, the cracked window only displays while the message box is up then i want it to disappear. The messagebox pauses the program and only when it's gone is the landsacpe drawn again.

Thanks for your reply. I hope i haven't missed something either. Am i right in my thinking?



[This message has been edited by nexusone (edited 03-27-2003).]

I_NeedHelp
03-27-2003, 05:23 AM
OK. Both of you can't be wrong http://www.opengl.org/discussion_boards/ubb/smile.gif
I'll try that and if it doesn't work you'll be the first to know about it

nexusone
03-27-2003, 05:28 AM
You can also post you display routine here so we can see how you have it setup.


Originally posted by I_NeedHelp:
OK. Both of you can't be wrong http://www.opengl.org/discussion_boards/ubb/smile.gif
I'll try that and if it doesn't work you'll be the first to know about it

Zengar
03-27-2003, 12:14 PM
You know, the problem is then in OpenGL you should redraw the scene in every new frame.

See, if you use back-buffering that does mean, you have two buffers; you show one of them and render in the same time to another.
It means, if you use glutSwapBuffers, then another buffer will be showed, so you should make shure that it contents are valid(I mean picture is the one you need).
Alltogether, if you have a picture in the frontbuffer and you try rendering something on the top of it, you'll in reality draw to the back-buffer - in the quite different picture. That's why you don't see anything.
It's the same story as with text output: you gotta draw the same string in every frame. Otherwise it whould be simply erased by buffer swap operation. Sometimes it's nerving, but you'll otta use to it.

Zengar