From f6af3ab3fb6fa7964117b17b3f01733864d2696a Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Wed, 27 Feb 2019 20:11:14 +0000 Subject: [PATCH] Implement new conversion --- GL/texture.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GL/texture.c b/GL/texture.c index b1f16a0..18c1db8 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -532,6 +532,10 @@ static inline void _rgba8888_to_rgba8888(const GLubyte* source, GLubyte* dest) { dst[3] = source[3]; } +static inline void _rgba8888_to_rgb565(const GLubyte* source, GLubyte* dest) { + *((GLushort*) dest) = ((source[0] & 0b11111000) << 8) | ((source[1] & 0b11111100) << 3) | (source[2] >> 3); +} + static inline void _rgb888_to_rgba8888(const GLubyte* source, GLubyte* dest) { /* Noop */ GLubyte* dst = (GLubyte*) dest; @@ -592,6 +596,8 @@ static TextureConversionFunc _determineConversion(GLint internalFormat, GLenum f case GL_RGB: { if(type == GL_UNSIGNED_BYTE && format == GL_RGB) { return _rgb888_to_rgb565; + } else if(type == GL_UNSIGNED_BYTE && format == GL_RGBA) { + return _rgba8888_to_rgb565; } else if(type == GL_BYTE && format == GL_RGB) { return _rgb888_to_rgb565; } else if(type == GL_UNSIGNED_BYTE && format == GL_RED) {