Jump to content
  • Advertisement
Sign in to follow this  
ConorH

Image Class help

This topic is 3890 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

Iv created an image class, to handle loading SDL and OpenGL textures and drawing them to screen etc. When I design my other code around it, should I design them to take pointers of my image object, like SDL does. I assume this is so that there arent a load of images floating about in memory, but im not quite sure. Iv noticed that OpenGL just uses the un-pointed-to objects for textures, like GLuint. Maybe Im just confused, I seem it. Please help

Share this post


Link to post
Share on other sites
Advertisement
Ok, so you have an image class, which you have failed to describe. Here is my guess: It has functions that load the image, data to hold the pixels, data to hold the information on its dimensions and type. It also probably has a member variable for the texture id.

Now, from drawing purposes in OpenGL, we don't give a crap about anything but the texture id, so why copy the rest of the image data over and over? Just pass the point to the image data around for speed.

Also, some scenarios make pointers far more effective. Say you have a spritesheet and 300 sprites on the screen from that sprite. Its far more effective to have each sprite holding a pointer to that image than the image itself.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!