   Odd problem with loading transparent image files
I am using SDL and it's image loading library to load a 32-bit targa file.  This has also happened with png's so I suspect its something in the way I've set up OpenGL, (perhaps missed something?).The square is actually supposed to show a few jagged red lines (you can see them but they are grey), and instead is striped with shades of grey.  The image is 256x256.I am using SDL to load the image, then OpenGL to create a texture and apply it to a quad.  The problem only occurs when the image actually has a transparent background... I am using GL_BGR_EXT in my glTexImage2D function because its the only one that will _work_ without crashing the program (I believe it's something to do with SDL to OpenGL conversion).  I tried GL_RGB, GL_RGBA, etc, it just crashes the program on start up.I have GL_BLEND, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA all there.  I've been struggling with this for a while but I still can't find a goddamn solution.Any help would be appreciated.   
  Seeing as SDL can only load Bitmaps, I assume that you are using SDL_image to load the .tgas and .pngs.What's your glTexImage2D() call look like? If you have the wrong format, you might see something like what you describe.If you aren't doing this already, convert the surface to the display format with an SDL_DisplayFormatAlpha() call right after loading it.Your blending seems fine. The fact that its crashing when you don't use GL_BGR_EXT is bad. Try GL_BGR instead of GL_BGR_EXT. And for alpha, try GL_BGRA(if you use SDL_DisplayFormatAlpha(), you should probably be using this one).   ;  After tinkering for a while I discovered the start up crash was caused by the pngs.glTexImage2D(GL_TEXTURE_2D, 0, 3, temp->w, temp->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, temp->pixels);I've got it showing up fine with correct colours, unfortunately now the background transparency doesn't work ;).Regarding GL_BGRA/GL_BGR.  Visual Studio errors out those two as undeclared identifiers.   ;  Are you including "SDL_opengl.h" or a different OpenGL header? The SDL one has things like GL_BGR and GL_BGRA defined in them.   ;  Ah my bad.  I forgot to include that, compiles fine now.   ;Quote:Original post by JovanglTexImage2D(GL_TEXTURE_2D, 0, 3, temp->w, temp->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, temp->pixels);Change the underlined parameter (internal format) to GL_RGBA8 (or anything else with an alpha component) to preserve alpha.If GL_BGR_EXT works on load (I'm assuming you're talking about the dataformat parameter of glTexImage2D (3rd from last)), GL_RGB should not crash. On the other hand if you specify GL_RGBA for a 3 channel image, it's going to crash due to obvious reasons (read past end of an array). Each SDL_Surface struct (IIRC) has a bitsPerPixel member. Check that value before you set dataformat - if it is 24, make it GL_RGB, if 32 -> GL_RGBA, etc.GL_BGR_EXT and GL_BGR are actually the same integer values, it's just a matter of what is defined in your header files, you shouldn't worry about that.From your screenshot, I can't understand what the images are and what the compositing is that is going on - is the "red streaks" a separate image file?   ;  Well after messing around a bit on my own I _almost_ have it working...Yet still no matter what I bloody do the transparency won't work.   ;  glEnable(GL_BLEND)??   ;  already enabled   ;  Ah well, no worries.  I'll just use libpng and load everything directly into OpenGL instead of using SDL.  Thanks for your help!   