diff options
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(); |