From: matthew Date: Tue, 21 Aug 2018 20:16:40 +0000 (+0100) Subject: fixed incorrect loading of RGBA formatted images, added blend calls in main to test X-Git-Url: https://git.owens.tech/assets/static/dummy.html/assets/static/dummy.html/git?a=commitdiff_plain;h=e1d86bbb7f46fb27bf624310cb7faa3ad53d4c1e;p=csrpg.git fixed incorrect loading of RGBA formatted images, added blend calls in main to test --- diff --git a/gl/main.c b/gl/main.c index d627dbc..6d5de9b 100644 --- a/gl/main.c +++ b/gl/main.c @@ -62,7 +62,7 @@ static void initShapes() // loading our textures stbi_set_flip_vertically_on_load(true); tex[0] = crpgTextureNew("textures/wall.jpg"); - tex[1] = crpgTextureNew("textures/awesomeface.png"); + tex[1] = crpgTextureNew("textures/target.png"); shader = crpgShaderNew("tri"); crpgShaderUse(shader); @@ -142,6 +142,8 @@ static void render() glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, crpgTextureGetID(tex[1])); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindVertexArray(vao); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); diff --git a/gl/texture.c b/gl/texture.c index 69ed0d4..0056a74 100644 --- a/gl/texture.c +++ b/gl/texture.c @@ -21,7 +21,7 @@ crpgTexture *crpgTextureNew(const char *filename){ if(chan == 3){ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data); } else if (chan == 4) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); } else { err_output("Error loading texture, images that are not formatted as\ RGB or RGBA are unsupported!"); diff --git a/textures/target.png b/textures/target.png new file mode 100644 index 0000000..75f96a3 Binary files /dev/null and b/textures/target.png differ