Jump to content
  • Advertisement
Sign in to follow this  
Apoh

OpenGL 2d looping bitmap animation

This topic is 3409 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 expect this is a common question, so if there are any references for this please post them. I am making a pacman-like game to become more familiar with using OpenGl. I want to know how to render a 30x30 bitmap image to the screen, and specifically use a timer to loop through a few images to have a kind of animation of the character 'eating'. Thank you for any assistance.

Share this post


Link to post
Share on other sites
Advertisement
Do you know how to draw a polygon with OpenGL?

Do you know how to specify an orthographic camera projection with OpenGL?

Do you know how to texture (place an image on) a polygon with OpenGL?

Do you know how to create and user timers on your current platform?

Do you know how to swap the texture data in response to the timer notification?

When you answer yes to all of the above, you're done. Take it step by step and seek to answer those questions, and you'll be done before you know it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi

Do you know how to texture (place an image on) a polygon with OpenGL?



This is more or less the part I need help on. I've tried two techniques (one from a book I have and one from the nehe.gamedev.net tutorials), but it seems both are deprecated in some way or other (for instance, I get compiling errors when declaring the method AUX_RGBImageRec *LoadBMP(char *Filename) that the nehe tutorial uses...I'm not too familiar with c++ but I think it has something to do with there being a pointer on the method's name maybe?)

In any case, I've read a bit on the subject and understand how it should work in general, but a good working example would really help. Are there any other sites besides nehe that would be useful in this area? Or even a reference site that goes more in-depth than the stuff I've managed to find?

Share this post


Link to post
Share on other sites
My development Journal has a fully working TGA loader for loading TGA images onto an OpenGL Texture. Take a look at that for some information to loading files into memory and creating a texture.

The 2nd part of your problem is that you want your image to animate. The way that I do this is that I load all the 'frames' (without any image headers, all frames must be the same width,height and depth) and then have a single OpenGL Texture. When I query a function for the OpenGL Texture ID I do a quick calculation to work out the time difference from the start of the last animation frame, and the time the id is requested. If the time difference is less than the timestep of the animation, just return the Texture ID. If it is time for the next frame, then I call glTexSubImage() to update the OpenGL Texture.

Share this post


Link to post
Share on other sites
Thanks for the suggestions, especially the sample code. I'm definitely going to look into them :]

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!