diff options
author | Phil Jones <philj56@gmail.com> | 2021-11-01 18:56:56 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2021-11-01 18:56:56 +0000 |
commit | b05f788969cf664062774eed6a74fe1eb1e66d11 (patch) | |
tree | 8d9b35985493445cb6f7e8a9b9ff5b1746c198ae /src | |
parent | a2197fe121e5de992a041b4d11495600cd7204ce (diff) |
Change texture swizzling to work with ES 2.
Diffstat (limited to 'src')
-rw-r--r-- | src/gl.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -117,7 +117,11 @@ void gl_initialise(struct gl *gl, struct image *texture) texture->width, texture->height, 0, - GL_RGBA, + /* + * On little-endian processors, textures from Cairo + * have to have their red and blue channels swapped. + */ + texture->swizzle ? GL_BGRA : GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)texture->buffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -125,17 +129,6 @@ void gl_initialise(struct gl *gl, struct image *texture) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - /* - * On little-endian processors, textures from Cairo have to have their - * red and blue channels swapped. - */ - if (texture->swizzle) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); - } - /* Bind the actual bits we'll be using to render */ glBindVertexArray(gl->vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl->ebo); @@ -172,7 +165,7 @@ void gl_draw_texture( 0, texture->width, texture->height, - GL_RGBA, + texture->swizzle ? GL_BGRA : GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)texture->buffer); glGetError(); |