From b05f788969cf664062774eed6a74fe1eb1e66d11 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 1 Nov 2021 18:56:56 +0000 Subject: Change texture swizzling to work with ES 2. --- src/gl.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gl.c b/src/gl.c index 09c542e..897ff63 100644 --- a/src/gl.c +++ b/src/gl.c @@ -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(); -- cgit v1.2.3