Texture with a transparent color

Started by
15 comments, last by gtlpcl 20 years, 8 months ago
That''s too complicated for me. All I need to do is:
-Load a RBGA bitmap
-Mask out the alpha channel

I looked at the Alpha Blending tutorial (#32). Impossible to read.
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
Advertisement
wait, never mind. Photoshop 5.5 doesn''t save in RGBA bitmap format. I''ll just use the tga loading method.
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
btw, where is this so-called targa loading code anyways?
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
The TGA-load code is the tutorial 33 on NEHE site.

Good luck.

PCL
Thanks very much gtlpcl.

Lessons 24,32, and 33 all have the TGA loading code, but I''d say that it''s explained best in #24.
yes, I got the code from #24, but I can''t find out how to use the texture I get. it''s something like:
glBindTexture(GL_TEXTURE_2D,textures[0].&imageData)
right?
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
Hi,

Yes, you''re right, the function glBindTexture tells to the program which texture you eant to use, but your parameters are false.

First, I guess you use the structure Texture given by Nehe in his tutorials. If it''s the case, when you use the function glBindTexture, you use the value texture[0].texID and not imageData. imageData is empty now, after you attach an image to the Texture structure, you free this value (pointer to a part of memory) which is now obsolete (see the command imageData->free.)

Second, if you use the Texture structure as a pointer (ie you implement like this : Texture *texture), it''s not a point and/or ''&'' caracter for accessing value, but an array, like this : texture->texID

So, your source could seems like that :

glBindTexture(GL_TEXTURE_2D, texture[0].texID);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();

Remark : don''t forget to enable the textures.

Kind Regards.

PCL

This topic is closed to new replies.

Advertisement