After loading the image, I have separate bytes for each channel loaded into an array of unsigned characters. He passed a function that projects it as a texture onto a square. Everything seems to be working fine except for the alpha channel, which appears as the background color. I use OpenGL to draw an image. Do I get benefits by adding a layering mechanism? Also, how can I achieve the transparent effect that I want?
Note. This is the code that cheats on me:
void SetUpView()
{
glClearDepth(1.f);
glClearColor(1.f, 0.f, 0.f, 0.f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glDepthMask(GL_TRUE);
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
};
Also, here is the code for quad rendering.
void DrawTexturedRect(RectBounds *Verts, Image *Texture)
{
glBindTexture(GL_TEXTURE_2D, GetTextureID(Texture));
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelZoom(1, -1);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0);
glVertex3f(Verts->corners[0].x, Verts->corners[0].y, Verts->corners[0].z);
glTexCoord2f(1.0, 1.0);
glVertex3f(Verts->corners[1].x, Verts->corners[1].y, Verts->corners[1].z);
glTexCoord2f(1.0, 0.0);
glVertex3f(Verts->corners[2].x, Verts->corners[2].y, Verts->corners[2].z);
glTexCoord2f(0.0, 0.0);
glVertex3f(Verts->corners[3].x, Verts->corners[3].y, Verts->corners[3].z);
glEnd();
};
The Image class contains an array of unsigned characters obtained using OpenIL.
Relevant Code:
loaded = ilLoadImage(filename.c_str());
ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
unsigned char *bytes = ilGetData();
NewImage->data = bytes;
Problem http://img375.imageshack.us/img375/9585/j120192.png
thank