Jump to content
  • Advertisement
Sign in to follow this  
me_here_me

OpenGL texture opacity

This topic is 3659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I wrote the following code for rendering two textures, one on top of another: txHexagonG on top of txSlicePlusHexagon:
glDepthMask( false );
glEnable(GL_BLEND);	
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, txSlicePlusHexagon);
	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();

	glDepthMask( true );

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, txHexagonG);
	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();



Now I want to dynamically control the opacity of txHexagonG (the texture rendered on top). So that I have a slider through which I can make txHexagonG totally opaque, or totally transparent or somewhere in between. Can someone guide me how can I do that? any openGL functions that can help? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
If lighting is off
glColor4ubv or one of the other glColor functions.
To multiply the color with the texels,
glTexEnvi(..., ..., GL_MODULATE);

If lighting is on
glMaterial(...., GL_DIFFUSE, ...)
To multiply the color with the texels,
glTexEnvi(..., ..., GL_MODULATE);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!