PDA

View Full Version : sprites? omniditertional?



TB-Rex
08-16-2000, 05:49 AM
Please help!

I don't know how to render a simple Sprite. It is needed for flares and other objects who looks identical from every side.

Is there a simple openGL function or must I write my own?

Kilam Malik
08-16-2000, 06:07 AM
You render a simple quad with the texture of your sprite on it. But you have to render it in 2D screen coordinates so it always faces you with its front side.

TB-Rex
08-16-2000, 11:30 AM
I tried this:

glBegin(GL_QUADS);
glColor3f(1,0,0);
glTexCoord2f(-1,-1);
glVertex2f(-0.1,-0.1);

glTexCoord2f(1,-1);
glVertex2f(0.1,-0.1);

glTexCoord2f(1,1);
glVertex2f(0.1,0.1);

glTexCoord2f(-1,1);
glVertex2f(-0.1,0.1);
glEnd();

but no sprite! Only a 3D quad. What is wrong?

john
08-16-2000, 03:39 PM
I'm guessing you haven't set up your projection matrix for ortho proj. If you don't do this then your quad will appear with perspective.

cheers,
John

Relic
08-16-2000, 10:32 PM
So, you see something, but not the texture.
Usual arrays of questions you should ask yourself:
- texturing enabled?
- texture downloaded correctly? All levels of detail for mipmapping, which is default?
- texture environment and texture parameter set correctly? (No mipmapping, if you downloaded level of deatail 0 only).

Texture coordinates s and t normally go from 0.0 to 1.0. You issued coordinates from -1.0 to 1.0. This would display your texture four times on your quad with wrap mode GL_REPEAT.

Look at glAlphaFunc for alpha testing to get the shape of your actual sprite (if it is not a quad).

TB-Rex
08-17-2000, 01:26 AM
But I want to display the sprite on a 3D position. With your method I draw a 2D quad on a 2D pos.
I can't use it for 3D flares.

Relic
08-17-2000, 01:46 AM
Search for a tutorial on billboarding. (Look in the GLUT distribution, there is an example.)

What about this one http://reality.sgi.com/mjk/tips/lensflare/