Original Post
Hi, I am generating a texture, with a red color and varying alpha value. Alpha is 0 for half of the texture and 255 for the other half. But when I display the texture, its shows the entire texture red. Code for generating the texture: I have debugged to see if data is populated in the array correctly and it does. code for displaying the texture; any hints about why the entire screen is colored red best wishes [Edited by - me_here_me on August 18, 2008 9:10:57 AM]
int fbSize = fbWidth * fbHeight;
GLubyte *txHexagonData = new GLubyte[fbSize * 4];
for (int i=0;i<fbSize * 4;){
txHexagonData[i++] = 255;
txHexagonData[i++] = 0;
txHexagonData[i++] = 0;
if(i > (fbSize/2))
txHexagonData[i++] = 0;
else
txHexagonData[i++] = 255;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, txHexagon);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
fbWidth, fbHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, txHexagonData);
if (txHexagonData)
delete [] txHexagonData;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, txHexagon);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(0, 1); glVertex2f(-1, 1);
glTexCoord2f(1, 1); glVertex2f( 1, 1);
glTexCoord2f(1, 0); glVertex2f( 1, -1);
glEnd();