Skip to content

Commit

Permalink
[HTML5] Fix OpenGL depth texture support
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed May 11, 2022
1 parent 3343e63 commit 1350456
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,15 @@ void kinc_g4_internal_init_window(int windowId, int depthBufferBits, int stencil

#ifdef KORE_OPENGL_ES
{
char *exts = (char *)glGetString(GL_EXTENSIONS);
Kinc_Internal_SupportsDepthTexture = exts != NULL && strstr(exts, "GL_OES_depth_texture") != NULL;
maxColorAttachments = 4;

int major = -1;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glCheckErrors();
kinc_internal_opengl_force_16bit_index_buffer = major < 3 && strstr(exts, "GL_OES_element_index_uint") == NULL;

gles_version = major;
char *exts = (char *)glGetString(GL_EXTENSIONS);

Kinc_Internal_SupportsDepthTexture = major >= 3 || (exts != NULL && strstr(exts, "GL_OES_depth_texture") != NULL);
maxColorAttachments = 4;
kinc_internal_opengl_force_16bit_index_buffer = major < 3 && strstr(exts, "GL_OES_element_index_uint") == NULL;
}
#else
kinc_internal_opengl_force_16bit_index_buffer = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ static void setupDepthStencil(kinc_g4_render_target_t *renderTarget, GLenum texT
glCheckErrors();
glBindTexture(texType, renderTarget->impl._depthTexture);
glCheckErrors();
#ifdef KORE_HTML5
GLint format = GL_DEPTH_COMPONENT16;
#else
GLint format = depthBufferBits == 16 ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT;
#endif
glTexImage2D(texType, 0, format, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0);
glCheckErrors();
glTexParameteri(texType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Expand Down

0 comments on commit 1350456

Please sign in to comment.