Sign in to follow this  
me_here_me

texture rendering [SOLVED]

Recommended Posts

me_here_me    102
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:
	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;


I have debugged to see if data is populated in the array correctly and it does. code for displaying the texture;
	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();


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]

Share this post


Link to post
Share on other sites
Emark    122
what is your blend function?

im using:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

and works fine.

are you sure you have anything in the background? so you draw the alpha blended image last.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this