Sign in to follow this  

Image Class help

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

This topic is 3724 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this