DXGL r378 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r377‎ | r378 | r379 >
Date:22:31, 15 May 2013
Author:admin
Status:new
Tags:
Comment:
Use GL_R8 format for 8-bit surfaces on GL 3.0 and above.
Set G and B values of color key shader uniform to 0 on GL 3.0 and above.
Adjust color key float-to-int conversion.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/shaders.cpp (modified) (history)
  • /ddraw/texture.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -930,7 +930,8 @@
931931 switch(ddInterface->GetBPP())
932932 {
933933 case 8:
934 - glUniform3i(shaders[progtype].ckey,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
 934+ if(glver_major >= 3) glUniform3i(shaders[progtype].ckey,src->colorkey[0].key.dwColorSpaceHighValue,0,0);
 935+ else glUniform3i(shaders[progtype].ckey,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
935936 src->colorkey[0].key.dwColorSpaceHighValue);
936937 break;
937938 case 15:
Index: ddraw/shaders.cpp
@@ -58,7 +58,7 @@
5959 void main (void)\n\
6060 {\n\
6161 vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
62 - ivec3 comp = ivec3(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
 62+ ivec3 comp = ivec3(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
6363 if (comp == ckey)\n\
6464 discard;\n\
6565 gl_FragColor = value;\n\
@@ -71,7 +71,7 @@
7272 void main (void)\n\
7373 {\n\
7474 vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
75 - ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
 75+ ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
7676 if (comp == ckey)\n\
7777 gl_FragColor[0] = 1.0;\n\
7878 else gl_FragColor[0] = 0.0;\n\
@@ -85,10 +85,10 @@
8686 void main (void)\n\
8787 {\n\
8888 vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
89 - ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
 89+ ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
9090 if (comp == ckey)\n\
9191 discard;\n\
92 - ivec4 comp2 = ivec4(texture2D(tex1,vec2(gl_TexCoord[1]))*255.0);\n\
 92+ ivec4 comp2 = ivec4(texture2D(tex1,vec2(gl_TexCoord[1]))*255.5);\n\
9393 if(comp2[0] == 0)\n\
9494 discard;\n\
9595 gl_FragColor = value;\n\
Index: ddraw/texture.cpp
@@ -69,8 +69,8 @@
7070 case 0: // 8-bit palette
7171 if(glver_major >= 3)
7272 {
73 - texture->internalformat = GL_LUMINANCE8;
74 - texture->format = GL_LUMINANCE;
 73+ texture->internalformat = GL_R8;
 74+ texture->format = GL_RED;
7575 }
7676 else
7777 {