Drawing sprites with alpha

#1

Hello, I’m new to openGL and I’m having some trouble following the " opengl Rendering Sprites" tutorial, it won’t let me link the page, sorry.
Currently I’m looking into rendering sprites which I have working without the alpha channel (drawing a background on my sprite, unlike the tutorial). I have found that inputting GL_RGBA into the format of glTexImage2D crashes my program saying “nvoglv32.pdb not loaded”. I’m just a little confused because the tutorial can use either GL_RGBA or GL_RGB. I know I’m new and all but I don’t think anyone has asked something this specific, I’m not sure where I’m going wrong. GL_RGB works fine, just seems to be the alpha channel. Also I don’t think it’s the image because I’m using the same one they provided from the tutorial and have tried a few others.

#2

If you just change the format parameter without changing the data, it’s probably going to result in OpenGL reading past the end of the array and causing an address exception, because the array only contains 3widthheight bytes but GL_RGBA needs 4widthheight bytes.

If you’re loading the image from a file, you usually need to tell the image-loading library whether you want RGB or RGBA data.

1 Like
#3

Ah, I didn’t think of that. I have it loading properly now thanks very much for that. Sorry for the noob question. :slightly_smiling_face: