I did something in my project and all poly become transparent.
I downloaded my old git there all was okey, but it still transparent.
Tick event: In render all poly drawings
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.925f, 0.98f, 0.988f, 1f);
glPushMatrix();
game.render();
glPopMatrix();
}
Last changed function:
public void drawModel(Vector3f camLocation) {
for (int i = 0; i < count; i++) {
glPushMatrix();
glTranslated(copies[i].x, copies[i].y, copies[i].z);
glRotatef(rotations[i], 0, 1, 0);
texture.bind();
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
if (Stereometry.getVectorLenght(camLocation, copies[i]) < lodRange) {
k = 0;
} else {
k = m.length - 1;
}
for (Model.Face face : m[k].getFaces()) {
//Первая точка
Vector3f n1 = m[k].getNormals().get(face.getNormalIndices()[0] - 1);
glNormal3f(n1.x, n1.y, n1.z);
if (m[k].hasTextureCoordinates() && hasText) {
Vector2f t1 = m[k].getTextureCoordinates().get(face.getTextureCoordinateIndices()[0] - 1);
glTexCoord2f(t1.x, t1.y);
}
Vector3f v1 = m[k].getVertices().get(face.getVertexIndices()[0] - 1);
glVertex3f(v1.x * scale, v1.y * scale, v1.z * scale);
...2 More Vertex...
glEnd();
glDisable(GL_TEXTURE_2D);
glRotatef(-rotations[i], 0, 1, 0);
glTranslated(-copies[i].x, -copies[i].y, -copies[i].z);
}
}
How it looks: https://yadi.sk/i/D7XQhyBICB6sug
If texturing is enabled, then by default the color of the texel is multiplied by the current color, because by default the texture environment mode (GL_TEXTURE_ENV_MODE
) is GL_MODULATE
. See glTexEnv
.
This causes that the color and the alpha channel of the texels of the texture is "mixed" by the last color which has been set by glColor4f
.
Set a "white" color and an alpha channel of 1 before you render the texture, to solve your issue:
glColor4f(1, 1, 1, 1);
Note, if the current color has an alpha channel below 1 and Blending is enabled, this may cause an unexpected transparency effect.
An alternative solution would be to change the environment mode to GL_REPLACE
, instead:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);