#### Archived

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

# Sprites

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

## Recommended Posts

How could I display sprites on OGL? Sprites as in: quads with a 3D location but always face the camera... I guess you''d have to somehow undo the rotation by the camera-martix in the modelview- but im not sure how... Anybody got ideas?

##### Share on other sites
Yup i think so...
nehe did it in his tutorial on particles/sprites ...
(i might be wrong)

SnAkE's Programming Resources

Edited by - SnAkE on February 17, 2001 7:44:38 AM

##### Share on other sites
Take a look at Tutorial 21 to see how to set up an orthographic view. It is good for 2D stuff, since you kind of nullify the perspective issues.

http://www.gdarchive.net/druidgames/

##### Share on other sites
It strongly depends on how you implement your rotations, but if you use them like NeHe does, the following code should work :

// Undo rotations and translations in opposite order in wich they were done
glTranslatef(Position.x,Position.y,Position.z);
glRotatef((float)( A1),0.0f,1.0f,0.0f);
glRotatef((float)(-A2),1.0f,0.0f,0.0f);
glRotatef((float)(-A3),0.0f,0.0f,1.0f);

glTexCoord2f(1.0f,0.0f);
glVertex3f(Size,-Size,0);

glTexCoord2f(0.0f,0.0f);
glVertex3f(Size,Size,0);

glTexCoord2f(0.0f,1.0f);
glVertex3f(-Size,Size,0);

glTexCoord2f(1.0f,1.0f);
glVertex3f(-Size,-Size,0);
glEnd();

// Redo Translations and rotations in the correct order
glRotatef((float)( A3),0.0f,0.0f,1.0f);
glRotatef((float)( A2),1.0f,0.0f,0.0f);
glRotatef((float)(-A1),0.0f,1.0f,0.0f);
glTranslatef(-Position.x,-Position.y,-Position.z);

This only displays a squar sprite, but you could easily draw rectangular ones with 2 Size variables. You should also watch you transparency/blend functions to avoid displaying it as a rectangle, other than that, this code should work perfectly (as it does in my engine

Edited by - Flous on February 18, 2001 4:03:52 PM

1. 1
Rutin
34
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633337
• Total Posts
3011415
• ### Who's Online (See full list)

There are no registered users currently online

×