Display a static Image on the screen?
Hi!
I'm trying to do something very simple but with my knowledge of OpenGL I can't seem to make it work. I wan't to display a normal BMP image either as Background or just an image, maybe a space craft. How can I do this.
I've tried to modify the tutorials but I can't make it work.
Please help!
Post some code, so I can understand how to do this.
Thanks!
Well I just want to join so I can get som help.
Quote:
Post some code, so I can understand how to do this.
you will find people don't hand out full source code to solve problems.. It's best you are given the basics then use trial and error to discover yourself why things arn't working..
but anywho..
This sort of thing is fairly simple to do.
Basically, what you want is not to be using any projection in the openGL pipeline.
For example, if you set both the modelview matrix and projection matrix to identity, then every vertex you plot with glVertex/glDrawElements, etc, will not be transformed. (remember it's bets to push both matrices first then pop once done)
So therefore, the corners of the scren become {-1,-1,0} , {-1,1,0} , {1,-1,0} and {1,1,0}.
eg, glVertex2f(0,0);
would be the centre of the screen.
But of course the screen is not 2x2 pixels in size, so for something a bit more useful, you would want to scale and translate the modelview matrix (or the projection matrix, makes no difference)
eg,
glTranslatef(-1,-1,0); (this makes 0,0 effectivly -1,-1, so the corner not the centre)
glScalef( 2.0f / screenWidth, 2.0f / screenHeight, 1); (and this shouldn't be hard to figure out)
Make sure that makes sense, because it's off the top of my head and may not work.. So to recognise why it's not working you need to know what it's trying to do [wink]
Then, for example,
plotting a background image, would be a rendering a single quad...
eg,
glVertex2f(0,0);
glVertex2f(screenWidth,0);
...
Just remember to turn off things like lighting, back face culling, depth testing, etc. They screw up this sort of thing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement