Jump to content

  • Log In with Google      Sign In   
  • Create Account


bregchel

Member Since 29 Apr 2013
Offline Last Active Apr 30 2013 12:59 AM

Topics I've Started

Texturing Issue with OpenGL

29 April 2013 - 01:03 PM

Hi, 

 

I'm working with opengl texturing in 2D, but I need help :) first of all, I'm new at OpenGL, so try not to be so technical in your explanation, i will thank you so much :)

 

To explain my problem, look at this picture:

 

texturing.png

 

as you can see, the ship and the asteroids are quads textured, but i want to "not print" the "black" parts of the quads.

I try to use BLENDING, and although the black parts disappear, the colors blend with the background.

 

 

This is how i am blending

 

 

glMatrixMode(GL_MODELVIEW);
glPushMatrix(); // guardamos la matriz actual
glTranslatef(centro.x, centro.y, 0.0);
glRotatef(theta, 0.0, 0.0, 1.0);
glTranslatef(-centro.x, -centro.y, 0.0);
 
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, texture.TexName());
 
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
 
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(centro.x - dx, centro.y + dy, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(centro.x + dx, centro.y + dy, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(centro.x + dx, centro.y - dy, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(centro.x - dx, centro.y - dy, 0.0);
glEnd();
 
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glPopMatrix(); // restablecemos la matriz original
 

 

Any ideas?

Thank you!!


PARTNERS