Skip to content

Commit b19d3d8

Browse files
committed
Fix[glformats]: better handling for byte-compatible GL_UNSIGNED_INT_8_8_8_8(_REV)
1 parent cca0f94 commit b19d3d8

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ltw/src/main/tinywrapper/glformats.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,18 @@ CONVERT(GLubyte, GLubyte, 3, 4, {
398398
})
399399

400400
INTERNAL void convert_texture2d(GLenum type, GLenum format, GLuint width, GLuint height, GLvoid const* data, GLenum outtype, GLenum outformat, GLvoid** outdata) {
401-
if(type == GL_UNSIGNED_INT_8_8_8_8_REV && (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT)) {
401+
402+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
403+
#define U32_4C_COMPATIBLE_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
404+
#else
405+
#define U32_4C_COMPATIBLE_TYPE GL_UNSIGNED_INT_8_8_8_8
406+
#endif
407+
if(type == U32_4C_COMPATIBLE_TYPE && (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT)) {
402408
type = GL_UNSIGNED_BYTE;
403409
}
410+
// TODO: adjust swizzle for GL_UNSIGNED_INT_8_8_8_8
411+
#undef U32_4C_COMPATIBLE_TYPE
412+
404413
if(!is_type_basic(type) || !is_type_basic(outtype)) {
405414
LOGI("conversion between non-basic types %x and %x", type, outtype);
406415
return;

ltw/src/main/tinywrapper/of_buffer_copier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void glTexSubImage2D(GLenum target,
124124
return;
125125
}
126126

127+
// TODO: store this in LTW
127128
GLint internalformat;
128129
es3_functions.glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, &internalformat);
129130

0 commit comments

Comments
 (0)