Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGL (3D) with transparency?  (Read 1942 times)

0 Members and 2 Guests are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
OpenGL (3D) with transparency?
« on: August 31, 2015, 10:14:21 pm »
Hello.
Now, this isn't exactly SFML related question but I bind textures to meshes by using sf::Texture->bind(), so...

The problem is: there is no transparency on PNG textures. Everything that is transparent draws as black color.
How do I fix it?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: OpenGL (3D) with transparency?
« Reply #1 on: August 31, 2015, 10:25:34 pm »
Do you use the alpha blend mode? Is blending enabled?

How do you draw?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: OpenGL (3D) with transparency?
« Reply #2 on: August 31, 2015, 10:47:38 pm »
Yes, I use both. (glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);).
The drawing is performed by passing vertex, texture and index arrays:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf(camera->GetTransformationMatrix());

float position[4] = {-1,1,-1,0};
glLightfv(GL_LIGHT0, GL_POSITION, position);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, &vertices.at(0));
glNormalPointer(GL_FLOAT, 0, &normals.at(0));
glTexCoordPointer(2, GL_FLOAT, 0, &tcoords.at(0));
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_SHORT, &indices.at(0));

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 

 

anything