Jump to content
  • Advertisement
Sign in to follow this  
Xeiph

OpenGL Sprites for 2d games

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to make a 2d game with simple graphics and it looks like using sprites is the way to go. I want to use OpenGL because i have a bit of experience with it, but i am having trouble finding good info from google on how to start my project. If someone could give me just a small sample template to use or a site with a decent introduction to using sprites with OpenGL, that would be great. If i am completely wrong about using sprites, is there anything else whould be good to design the graphics of my game? i hope i wont have to draw every polygon using GL_POLYGON, that would take a long time.

Share this post


Link to post
Share on other sites
Advertisement
If your question is simply how to go about creating 2D sprites in OpenGL, I would recommend NeHe's OpenGL tutorials at http://nehe.gamedev.net/.

They will teach you how to create shapes, texture them and even use transparency so you can control what gets drawn to the screen.

These should be sufficient for anybody trying to create sprites.

Share this post


Link to post
Share on other sites
Im not sure if that is exactly what i am looking for. The tutorials seem to cover textured quads and things, but arent sprites used to draw small quads that form one image and are then moved or rotated to create an animation? similar to the 'pixelated' games of the past?

Share this post


Link to post
Share on other sites
A bitmap/texture with many sprites is called a sprite-sheet.

Anyway, glOrtho and glViewport are the only things you need to set,
after that just draw GL_QUADS with appropriate vertex-positions and texture-coordinates.
Here's a game's main loop (the easiest way) :

void main(){
init_engine();
load_textures();
//load_gamestate();

while(!GameShouldExit){
getKeys();
moveOnKeys();
drawSprites();
SwapBuffers();
}
//save_gamestate();
free_textures();
free_engine();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!