Jump to content
  • Advertisement
Sign in to follow this  
clearly

OpenGL blending problem

This topic is 4468 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

the problem is that the "tank" is seening under the "background" instade of standing on it.. how can i change it ? //Sorry for the bad english heres the code: initliazion:
	LoadGLTextures();
		glEnable(GL_TEXTURE_2D);				
	glShadeModel(GL_SMOOTH);				
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);			
	glClearDepth(100.0f);					
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);			
	glEnable(GL_BLEND);	  

drawing:
 	glLoadIdentity(); // the tank
	glBindTexture(GL_TEXTURE_2D, texture[4]);
	glColor3f(1.0f,1.0f,1.5f);
	glTranslatef(x2rot,y2rot,-49.0f); //-39
	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f);glVertex3f(-7.0f, -7.0f,  5.0f);
	glTexCoord2f(1.0f, 0.0f);glVertex3f( 7.0f, -7.0f,  5.0f);
	glTexCoord2f(1.0f, 1.0f);glVertex3f( 7.0f,  7.0f,  5.0f);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(-7.0f,  7.0f,  5.0f);
	glEnd();


		glLoadIdentity(); // background 
	glBindTexture(GL_TEXTURE_2D, texture[7]);
	glColor3f(1.0f,1.0f,1.5f);
	glTranslatef(0.0f,0.0f,-98.0f);
	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f);glVertex3f(-50.0f, -50.0f,  -2.0f);
	glTexCoord2f(1.0f, 0.0f);glVertex3f( 50.0f, -50.0f,  -2.0f);
	glTexCoord2f(1.0f, 1.0f);glVertex3f( 50.0f,  50.0f,  -2.0f);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(-50.0f,  50.0f, -2.0f);
	glEnd();

textures: texture[4] = http://members.lycos.co.uk/clearly/RS_T.bmp texture[7] = http://members.lycos.co.uk/clearly/BG.bmp please help me :/

Share this post


Link to post
Share on other sites
Advertisement
glEnable(GL_DEPTH_TEST), prehaps? That makes OpenGL sort drawings based on the z-buffer.

And if you already have it enabled, try turning it off. One or the other might help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Ezbez
glEnable(GL_DEPTH_TEST), prehaps? That makes OpenGL sort drawings based on the z-buffer.

And if you already have it enabled, try turning it off. One or the other might help.


i tryed enableing it and disableing it
it just making it worst ;/

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
glEnable(GL_DEPTH_TEST), prehaps? That makes OpenGL sort drawings based on the z-buffer.

And if you already have it enabled, try turning it off. One or the other might help.


i tryed enableing it and disableing it
it just making it worst ;/
i mean
when i do it
u can see the black pixels of the tank picture.. and i dont want to see them
what can i do about it?

Share this post


Link to post
Share on other sites
Im assuming your doing 2d? Well either way if you have a texture with black parts that u dont want to draw, use the blend function GL_ONE, GL_ONE instead of what you have. The left parameter is what is already in the color buffer, the second is the color from the texture so if you have (255,0,0) already in the color buffer and draw a pixel from your texture (0,0,0) well your color is ( (255*1)+(0*1), 0*1 + 0*1, 0*1 + 0*1). :)

Share this post


Link to post
Share on other sites
Just to reiterate you are using GL_SRC_ALPHA, and its dealing with the alpha component currenty in the color buffer. Change to GL_ONE and let us know if it works.

Share this post


Link to post
Share on other sites
Dont know if this is why, but enable blending before giving a glblend function. Also try , in clear color: take out the .5 alpha value.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!