Jump to content
  • Advertisement
Sign in to follow this  
ezradev

Photoshop and glTexImage2D

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

Hello, I started working on an existing project that uses glTexImage2D like this: glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, TextureImage->w, TextureImage->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage->pixels ); It works for tons of existing images. I created a new image in photoshop and tried to use it and glTexImage2D throws an exception: Unhandled exception at ... in myGame.exe 0xC000000005: Access violation reading location .... I have tried to save it as PNG-8, PNG-24, with transparency, no transparency, with variations of bicubic, and I can't remember what else. I have tried many Google searches and looked at the documentation for glTextImage2D. I can't figure the relation to Photoshop "save" settings. My question is: Do I have to use a utility to get my PNG ready to be used by glTextImage2D, or am I missing some settings in photoshop that I should be setting? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
If I recall correctly, photoshop does not save transparency by default as the alpha layer, you have to manually define an alpha layer to the image before saving it. I think this is true for .TGA, not sure about .PNG, but you might want to try to search some more information, some combination of "photoshop png alpha transparency", I don't know of a tutorial off the top of my head.

If your image type is RGBA, then you need to make sure your image is PNG-32, not PNG-8 or PNG-24.

Alternatively you can change your image type to GL_RGB and use a PNG-24.

Check out the .PNG file format too and make sure that the data is laid out as RGBARGBARGBA and not with some kind of compression. You have to get the data into a proper format before you can upload it to glTexImage.

Share this post


Link to post
Share on other sites
1) Are you sure the error is caused by glTexImage2D? What happens if you comment the line out?
2) How do you read and decode the png file before calling glTexImage2D? What library are suing for that?

Share this post


Link to post
Share on other sites
Thanks for your reply karwosts.

I think I figured out a process to do it, though I'm not sure why. I was previously using photoshop cs4, I went to my laptop which has photoshop cs2 on it and tried it there and it worked. cs2 asks you if you want interlacing before it commits the save, I chose "no" and it works.

Cheers!

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!