Jump to content
  • Advertisement
Sign in to follow this  
mikealexander

OpenGL newbie has a problem w/ tga.

This topic is 4055 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 hate to bother everyone with this, but I haven't been able to fix it by myself after several hours at it (like, 12). I have been working on tga loading code to load textures for an opengl scene. Everything appears to be alright, at least up to the actual image data. But when I go to texture an object in my scene, the square remains white... I was wondering if somebody could take a look through my code to see if they can find my screw-up? you can get the files here: PELoadTGA.cpp PELoadTGA.h Just as a forewarning, the code is probably a bit ugly, and there may be some incorrect naming conventions and such, but I'm sure you can figure it out. also, before anyone suggests I use code thats already out there, I'm trying to do this my own way (somewhat) so I can learn how it all works. Thanks for the help, and God bless! Mike (Im using dev-cpp if that matters)

Share this post


Link to post
Share on other sites
Advertisement
If the image appears to load correct, but the texturing is wrong, why show the image loading code which appears to work and not the texturing code which appears to not work?

Check the usual things like unsuported texture size (possible power of two limits) and filtering mode (default minification filter requires a complete mipmap set).

Share this post


Link to post
Share on other sites
Square remaining white usually means the data wasn't uploaded correctly, or you haven't enabled GL_TEXTURE_2D (or you have fog cranked up on white, or light.. but I doubt that's your problem).

Hope that helps,
~Zix

Share this post


Link to post
Share on other sites
Use GLAUX or something similar to load a simple BMP and use it with the same texturing code you use - if that doesn't work you probably texture incorrectly(and TGA loading might actually work).

If that does work, write a TGA saving routine, and then look at what you actually loaded.

Share this post


Link to post
Share on other sites
Thanks for the replies. I am reusing the code I have for a working bitmap loader, and so I know it isn't the texturing thats the problem. And I've been using iostream.h and debugging to watch all the variables throughout execution. The stuff seems to be right up until I actually loop through to load the image data.

Share this post


Link to post
Share on other sites
Does the fact that you call CleanupImage(); at the end of the loading procedure before I see any OpenGL upload code mean anything? This seems to be the problem... the rest of your code looks fine.

~Zix

Share this post


Link to post
Share on other sites
nope, never mind. I thought I commented out something needed, but I didn't, thats all good.

zix99 That part of the code is fine I think (if not logically, trial and error proves it)

Seroja - I tried your suggestion. The tga file that came out was corrupted in some way. So either I messed up that code too or the problem is with the actual loading.

Share this post


Link to post
Share on other sites
hang on a sec mikealexander:

don't dismiss zix99's observation so quickly:

tell me you are not deleting the texture as soon as you load it.

the code you presented loads the texture then promptly deletes it
with CleanupImage()!

Or are you magically hiding the gl code that must upload the texture to video memory before you use CleanupImage().

I expected to see something like:

//maybe Generate OpenGL texture IDs
glGenTextures(1, &ID);
//maybe Bind the texture to a texture object
glBindTexture(GL_TEXTURE_2D, ID);

// but definitely load up with
gluBuild2DMipmaps(..,..,..,..,ucImgData)
//and/or
GL_TEXTURE_2D.(..,..,..,..,ucImgData)

// before you delete ucImgData!

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!