diff --git a/inc/openglshader.h b/inc/openglshader.h index 84c0748..525b5c6 100644 --- a/inc/openglshader.h +++ b/inc/openglshader.h @@ -84,6 +84,25 @@ static char PASSTHROUGH_FRAG_SHADER[] = "}\n"; +static char RBG555_FRAG_SHADER[] = + "#version 130\n" + "out vec4 FragColor;\n" + "uniform sampler2D Texture;\n" + "in vec4 TEX0;\n" + "\n" + "void main()\n" + "{\n" + " vec4 texel = texture(Texture, TEX0.xy);\n" + " int bytes = int(texel.r * 255.0 + 0.5) | int(texel.g * 255.0 + 0.5) << 8;\n" + " vec4 color;\n" + " color.r = float((bytes >> 10) & 31) / 31.0;\n" + " color.g = float((bytes >> 5) & 31) / 31.0;\n" + " color.b = float(bytes & 31) / 31.0;\n" + " color.a = 1.0;\n" + " FragColor = color;\n" + "}\n"; + + /* // The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae // Ported from code: https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1 diff --git a/src/render_ogl.c b/src/render_ogl.c index 160e0bd..c5d20db 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -141,6 +141,10 @@ static void ogl_build_programs() { g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PALETTE_FRAG_SHADER, core_profile); } + else if (g_ddraw->bpp == 16 && g_ddraw->rgb555) + { + g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, RBG555_FRAG_SHADER, core_profile); + } else if (g_ddraw->bpp == 16 || g_ddraw->bpp == 32) { g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PASSTHROUGH_FRAG_SHADER, core_profile); @@ -260,12 +264,12 @@ static void ogl_create_textures(int width, int height) glTexImage2D( GL_TEXTURE_2D, 0, - GL_RGB5_A1, + GL_RG8, 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, + g_ogl.surface_format = GL_RG, + g_ogl.surface_type = GL_UNSIGNED_BYTE, 0); } else if (g_ddraw->bpp == 16)