From 0eda9d21e1b87b54a297b3ea97a691154a8fb256 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 6 Sep 2023 22:55:54 +0200 Subject: [PATCH] make rgb555 hack working on older hardware as well --- src/opengl_utils.c | 2 +- src/render_ogl.c | 36 ++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/opengl_utils.c b/src/opengl_utils.c index e775a90..0a0cfa7 100644 --- a/src/opengl_utils.c +++ b/src/opengl_utils.c @@ -205,7 +205,7 @@ void oglu_init() g_oglu_got_version2 = glGetUniformLocation && glActiveTexture && glUniform1i; - g_oglu_got_version3 = glGenFramebuffers && glBindFramebuffer && glFramebufferTexture2D && glDrawBuffers && + g_oglu_got_version3 = glGenFramebuffers&& glBindFramebuffer&& glFramebufferTexture2D&& glDrawBuffers&& glCheckFramebufferStatus && glUniform4f && glActiveTexture && glUniform1i && glGetAttribLocation && glGenBuffers && glBindBuffer && glBufferData && glVertexAttribPointer && glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray && diff --git a/src/render_ogl.c b/src/render_ogl.c index c5d20db..8976833 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -261,16 +261,32 @@ static void ogl_create_textures(int width, int height) } else if (g_ddraw->bpp == 16 && g_ddraw->rgb555) { - glTexImage2D( - GL_TEXTURE_2D, - 0, - GL_RG8, - g_ogl.surface_tex_width, - g_ogl.surface_tex_height, - 0, - g_ogl.surface_format = GL_RG, - g_ogl.surface_type = GL_UNSIGNED_BYTE, - 0); + if (g_oglu_got_version3) + { + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RG8, + g_ogl.surface_tex_width, + g_ogl.surface_tex_height, + 0, + g_ogl.surface_format = GL_RG, + g_ogl.surface_type = GL_UNSIGNED_BYTE, + 0); + } + else + { + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA8, + g_ogl.surface_tex_width, + g_ogl.surface_tex_height, + 0, + g_ogl.surface_format = GL_BGRA, + g_ogl.surface_type = GL_UNSIGNED_SHORT_1_5_5_5_REV, + 0); + } } else if (g_ddraw->bpp == 16) {