1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

use shader for rgb555 color conversion

This commit is contained in:
FunkyFr3sh 2023-09-06 22:46:43 +02:00
parent a059fabf89
commit d93a78b2a0
2 changed files with 26 additions and 3 deletions

View File

@ -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

View File

@ -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)