Support transparent textures

master
Elias Fleckenstein 2021-07-12 17:39:21 +02:00
parent 77bd45b977
commit e991ab5c6d
2 changed files with 3 additions and 1 deletions

View File

@ -9,4 +9,6 @@ uniform sampler2D texture0;
void main() void main()
{ {
outColor = texture(texture0, fragmentTextureCoords); outColor = texture(texture0, fragmentTextureCoords);
if (outColor.a == 0.0)
discard;
} }

View File

@ -45,7 +45,7 @@ static void *create_texture(void *key)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture->width, texture->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->width, texture->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
stbi_image_free(data); stbi_image_free(data);