Skip to content

Commit 752a8af

Browse files
artdeellalexytomi
andcommitted
Fix[glformats]: add workaround for 1.21.5
This format isn't even supposed to be used in core contexts? ------- Keeping up with upstream. Removed unnoted changes from the commit which change hardcoded package names. That's a TODO right there if I've ever seen one. Co-authored-by: alexytomi <60690056+alexytomi@users.noreply.github.com>
1 parent c4f9196 commit 752a8af

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ltw/src/main/tinywrapper/glformats.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ void pick_format(GLint internalformat, GLenum* type, GLenum* format) {
133133
case GL_RGBA16I: *format=GL_RGBA_INTEGER; *type=GL_SHORT; break;
134134
case GL_RGBA32I: *format=GL_RGBA_INTEGER; *type=GL_INT; break;
135135
case GL_RGBA32UI: *format=GL_RGBA_INTEGER; *type=GL_UNSIGNED_INT; break;
136+
// Sized depth formats. Unsized formats handled before this function
137+
case GL_DEPTH_COMPONENT16: *format = GL_DEPTH_COMPONENT; *type = GL_UNSIGNED_SHORT; break;
138+
case GL_DEPTH_COMPONENT24: *format = GL_DEPTH_COMPONENT; *type = GL_UNSIGNED_INT; break;
139+
case GL_DEPTH_COMPONENT32F: *format = GL_DEPTH_COMPONENT; *type = GL_FLOAT; break;
140+
case GL_DEPTH24_STENCIL8: *format = GL_DEPTH_STENCIL; *type = GL_UNSIGNED_INT_24_8; break;
141+
case GL_DEPTH32F_STENCIL8: *format = GL_DEPTH_STENCIL; *type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV; break;
142+
case GL_STENCIL_INDEX8: *format = GL_STENCIL_INDEX; *type = GL_UNSIGNED_BYTE; break;
136143
}
137144
}
138145

@@ -142,6 +149,17 @@ INTERNAL void pick_internalformat(GLint *internalformat, GLenum* type, GLenum* f
142149
// This function converts appropriate unsized formats to sized ones according to the type.
143150
bool convert_data;
144151
switch (*internalformat) {
152+
case GL_DEPTH_COMPONENT32:
153+
// 1.21.5 workaround: fix internalformat (not handled in ES drivers cause it's from GL 1.4)
154+
// Work around by selecting the equivalent type (for float) or 24-bit (for int)
155+
if(*type == GL_FLOAT) {
156+
*internalformat = GL_DEPTH_COMPONENT32F;
157+
} else {
158+
*internalformat = GL_DEPTH_COMPONENT24;
159+
if(*type != GL_UNSIGNED_INT) convert_data = true;
160+
*type = GL_UNSIGNED_INT;
161+
}
162+
break;
145163
case GL_DEPTH_COMPONENT:
146164
*internalformat = pick_depth_internalformat(type, &convert_data);
147165
break;

0 commit comments

Comments
 (0)