]> git.lizzy.rs Git - dragonblocks_alpha.git/commitdiff
Support transparent textures
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 12 Jul 2021 15:39:21 +0000 (17:39 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 12 Jul 2021 15:39:21 +0000 (17:39 +0200)
shaders/fragment.glsl
src/texture.c

index 98b37dbe2b516812e3a1013c950da53b43d736a4..13793e95ae6acf32fae7ee486ccf2ee097b33172 100755 (executable)
@@ -9,4 +9,6 @@ uniform sampler2D texture0;
 void main()
 {
        outColor = texture(texture0, fragmentTextureCoords);
+       if (outColor.a == 0.0)
+        discard;
 }
index 17844b23be7b47fe5265b8e0666f651472b1962b..239c1a4ccb0e083d83a5b5c35c34b9dcb0d8e978 100644 (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_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);
 
        stbi_image_free(data);