Index: ddraw/glRenderer.cpp |
— | — | @@ -929,20 +929,19 @@ |
930 | 930 | {
|
931 | 931 | SetShader(PROG_CKEY,NULL,NULL,true);
|
932 | 932 | progtype = PROG_CKEY;
|
933 | | - GLint keyloc = glGetUniformLocation(shaders[PROG_CKEY].prog,"keyIn");
|
934 | 933 | switch(ddInterface->GetBPP())
|
935 | 934 | {
|
936 | 935 | case 8:
|
937 | | - glUniform3i(keyloc,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
|
| 936 | + glUniform3i(shaders[progtype].ckey,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
|
938 | 937 | src->colorkey[0].key.dwColorSpaceHighValue);
|
939 | 938 | break;
|
940 | 939 | case 15:
|
941 | | - glUniform3i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
|
| 940 | + glUniform3i(shaders[progtype].ckey,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
|
942 | 941 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 31),
|
943 | 942 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
944 | 943 | break;
|
945 | 944 | case 16:
|
946 | | - glUniform3i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
|
| 945 | + glUniform3i(shaders[progtype].ckey,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
|
947 | 946 | _6to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 63),
|
948 | 947 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
949 | 948 | break;
|
— | — | @@ -949,26 +948,22 @@ |
950 | 949 | case 24:
|
951 | 950 | case 32:
|
952 | 951 | default:
|
953 | | - glUniform3i(keyloc,(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
|
| 952 | + glUniform3i(shaders[progtype].ckey,(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
|
954 | 953 | (src->colorkey[0].key.dwColorSpaceHighValue>>8 & 255),
|
955 | 954 | (src->colorkey[0].key.dwColorSpaceHighValue & 255));
|
956 | 955 | break;
|
957 | 956 | }
|
958 | | - GLint texloc = glGetUniformLocation(shaders[PROG_CKEY].prog,"myTexture");
|
959 | | - glUniform1i(texloc,0);
|
| 957 | + glUniform1i(shaders[progtype].tex0,0);
|
960 | 958 | }
|
961 | 959 | else if(!(dwFlags & DDBLT_COLORFILL))
|
962 | 960 | {
|
963 | 961 | SetShader(PROG_TEXTURE,NULL,NULL,true);
|
964 | 962 | progtype = PROG_TEXTURE;
|
965 | | - GLint texloc = glGetUniformLocation(shaders[PROG_TEXTURE].prog,"Texture");
|
966 | | - glUniform1i(texloc,0);
|
| 963 | + glUniform1i(shaders[progtype].tex0,0);
|
967 | 964 | }
|
968 | 965 | SetActiveTexture(0);
|
969 | 966 | if(src) glBindTexture(GL_TEXTURE_2D,src->GetTexture());
|
970 | | - GLuint prog = GetProgram()&0xffffffff;
|
971 | | - GLint viewloc = glGetUniformLocation(prog,"view");
|
972 | | - glUniform4f(viewloc,0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
|
| 967 | + glUniform4f(shaders[progtype].view,0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
|
973 | 968 | dest->dirty |= 2;
|
974 | 969 | EnableArray(shaders[progtype].pos,true);
|
975 | 970 | glVertexAttribPointer(shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
|
— | — | @@ -1030,10 +1025,7 @@ |
1031 | 1026 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
1032 | 1027 | glBindTexture(GL_TEXTURE_2D,*texture);
|
1033 | 1028 | *texture = backbuffer;
|
1034 | | - GLuint prog = GetProgram();
|
1035 | | - GLint viewloc = glGetUniformLocation(prog,"view");
|
1036 | | - glUniform4f(viewloc,view[0],view[1],view[2],view[3]);
|
1037 | | -
|
| 1029 | + glUniform4f(shaders[progtype].view,view[0],view[1],view[2],view[3]);
|
1038 | 1030 | bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
|
1039 | 1031 | bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
|
1040 | 1032 | bltvertices[0].y = bltvertices[1].y = bltvertices[1].x = bltvertices[3].x = 0.;
|
— | — | @@ -1113,10 +1105,8 @@ |
1114 | 1106 | progtype = PROG_PAL256;
|
1115 | 1107 | glBindTexture(GL_TEXTURE_2D,paltex);
|
1116 | 1108 | glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,256,1,0,GL_RGBA,GL_UNSIGNED_BYTE,dest->palette->GetPalette(NULL));
|
1117 | | - GLint palloc = glGetUniformLocation(shaders[PROG_PAL256].prog,"ColorTable");
|
1118 | | - GLint texloc = glGetUniformLocation(shaders[PROG_PAL256].prog,"IndexTexture");
|
1119 | | - glUniform1i(texloc,0);
|
1120 | | - glUniform1i(palloc,1);
|
| 1109 | + glUniform1i(shaders[progtype].tex0,0);
|
| 1110 | + glUniform1i(shaders[progtype].pal,1);
|
1121 | 1111 | SetActiveTexture(0);
|
1122 | 1112 | glBindTexture(GL_TEXTURE_2D,texture);
|
1123 | 1113 | SetActiveTexture(1);
|
— | — | @@ -1128,9 +1118,7 @@ |
1129 | 1119 | SetShader(PROG_TEXTURE,NULL,NULL,true);
|
1130 | 1120 | progtype = PROG_TEXTURE;
|
1131 | 1121 | glBindTexture(GL_TEXTURE_2D,texture);
|
1132 | | - GLuint prog = GetProgram() & 0xFFFFFFFF;
|
1133 | | - GLint texloc = glGetUniformLocation(prog,"Texture");
|
1134 | | - glUniform1i(texloc,0);
|
| 1122 | + glUniform1i(shaders[progtype].tex0,0);
|
1135 | 1123 | }
|
1136 | 1124 | }
|
1137 | 1125 | else
|
— | — | @@ -1138,14 +1126,10 @@ |
1139 | 1127 | SetShader(PROG_TEXTURE,NULL,NULL,true);
|
1140 | 1128 | progtype = PROG_TEXTURE;
|
1141 | 1129 | glBindTexture(GL_TEXTURE_2D,texture);
|
1142 | | - GLuint prog = GetProgram() & 0xFFFFFFFF;
|
1143 | | - GLint texloc = glGetUniformLocation(prog,"Texture");
|
1144 | | - glUniform1i(texloc,0);
|
| 1130 | + glUniform1i(shaders[progtype].tex0,0);
|
1145 | 1131 | }
|
1146 | 1132 | SetViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
1147 | | - GLuint prog = GetProgram();
|
1148 | | - GLint viewloc = glGetUniformLocation(prog,"view");
|
1149 | | - glUniform4f(viewloc,view[0],view[1],view[2],view[3]);
|
| 1133 | + glUniform4f(shaders[progtype].view,view[0],view[1],view[2],view[3]);
|
1150 | 1134 | if(ddInterface->GetFullscreen())
|
1151 | 1135 | {
|
1152 | 1136 | bltvertices[0].x = bltvertices[2].x = (float)sizes[0];
|
Index: ddraw/shaders.cpp |
— | — | @@ -32,32 +32,32 @@ |
33 | 33 |
|
34 | 34 | const char frag_Texture[] = "\
|
35 | 35 | #version 110\n\
|
36 | | -uniform sampler2D Texture;\n\
|
| 36 | +uniform sampler2D tex0;\n\
|
37 | 37 | void main() \n\
|
38 | 38 | { \n\
|
39 | | - gl_FragColor = texture2D( Texture, gl_TexCoord[0].st ); \n\
|
| 39 | + gl_FragColor = texture2D( tex0, gl_TexCoord[0].st ); \n\
|
40 | 40 | } ";
|
41 | 41 |
|
42 | 42 | const char frag_Pal256[] = "\
|
43 | 43 | #version 110\n\
|
44 | | -uniform sampler2D ColorTable; \n\
|
45 | | -uniform sampler2D IndexTexture; \n\
|
| 44 | +uniform sampler2D pal; \n\
|
| 45 | +uniform sampler2D tex0; \n\
|
46 | 46 | void main() \n\
|
47 | 47 | { \n\
|
48 | | - vec4 myindex = texture2D(IndexTexture, gl_TexCoord[0].xy); \n\
|
49 | | - vec4 texel = texture2D(ColorTable, myindex.xy); \n\
|
| 48 | + vec4 myindex = texture2D(tex0, gl_TexCoord[0].xy); \n\
|
| 49 | + vec4 texel = texture2D(pal, myindex.xy); \n\
|
50 | 50 | gl_FragColor = texel; \n\
|
51 | 51 | } ";
|
52 | 52 |
|
53 | 53 | const char frag_ColorKey[] = "\
|
54 | 54 | #version 110\n\
|
55 | | -uniform sampler2D myTexture;\n\
|
56 | | -uniform ivec3 keyIn;\n\
|
| 55 | +uniform sampler2D tex0;\n\
|
| 56 | +uniform ivec3 ckey;\n\
|
57 | 57 | void main (void)\n\
|
58 | 58 | {\n\
|
59 | | - vec4 value = texture2D(myTexture, vec2(gl_TexCoord[0]));\n\
|
60 | | - ivec3 comp = ivec3(texture2D(myTexture, vec2(gl_TexCoord[0]))*255.0);\n\
|
61 | | - if (comp == keyIn)\n\
|
| 59 | + vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 60 | + ivec3 comp = ivec3(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
|
| 61 | + if (comp == ckey)\n\
|
62 | 62 | discard;\n\
|
63 | 63 | gl_FragColor = value;\n\
|
64 | 64 | } ";
|
— | — | @@ -64,13 +64,13 @@ |
65 | 65 |
|
66 | 66 | const char frag_ColorKeyMask[] = "\
|
67 | 67 | #version 110\n\
|
68 | | -uniform sampler2D myTexture;\n\
|
69 | | -uniform ivec4 keyIn;\n\
|
| 68 | +uniform sampler2D tex0;\n\
|
| 69 | +uniform ivec4 ckey;\n\
|
70 | 70 | void main (void)\n\
|
71 | 71 | {\n\
|
72 | | - vec4 value = texture2D(myTexture, vec2(gl_TexCoord[0]));\n\
|
73 | | - ivec4 comp = ivec4(texture2D(myTexture, vec2(gl_TexCoord[0]))*255.0);\n\
|
74 | | - if (comp == keyIn)\n\
|
| 72 | + vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 73 | + ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
|
| 74 | + if (comp == ckey)\n\
|
75 | 75 | gl_FragColor[0] = 1.0;\n\
|
76 | 76 | else gl_FragColor[0] = 0.0;\n\
|
77 | 77 | } ";
|
— | — | @@ -77,16 +77,16 @@ |
78 | 78 |
|
79 | 79 | const char frag_2ColorKey[] = "\
|
80 | 80 | #version 110\n\
|
81 | | -uniform sampler2D myTexture;\n\
|
82 | | -uniform sampler2D maskTexture;\n\
|
83 | | -uniform ivec4 keyIn;\n\
|
| 81 | +uniform sampler2D tex0;\n\
|
| 82 | +uniform sampler2D tex1;\n\
|
| 83 | +uniform ivec4 ckey;\n\
|
84 | 84 | void main (void)\n\
|
85 | 85 | {\n\
|
86 | | - vec4 value = texture2D(myTexture, vec2(gl_TexCoord[0]));\n\
|
87 | | - ivec4 comp = ivec4(texture2D(myTexture, vec2(gl_TexCoord[0]))*255.0);\n\
|
88 | | - if (comp == keyIn)\n\
|
| 86 | + vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 87 | + ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.0);\n\
|
| 88 | + if (comp == ckey)\n\
|
89 | 89 | discard;\n\
|
90 | | - ivec4 comp2 = ivec4(texture2D(maskTexture,vec2(gl_TexCoord[1]))*255.0);\n\
|
| 90 | + ivec4 comp2 = ivec4(texture2D(tex1,vec2(gl_TexCoord[1]))*255.0);\n\
|
91 | 91 | if(comp2[0] == 0)\n\
|
92 | 92 | discard;\n\
|
93 | 93 | gl_FragColor = value;\n\
|
— | — | @@ -160,6 +160,11 @@ |
161 | 161 | shaders[i].pos = glGetAttribLocation(shaders[i].prog,"xy");
|
162 | 162 | shaders[i].rgb = glGetAttribLocation(shaders[i].prog,"rgb");
|
163 | 163 | shaders[i].texcoord = glGetAttribLocation(shaders[i].prog,"st");
|
| 164 | + shaders[i].tex0 = glGetUniformLocation(shaders[i].prog,"tex0");
|
| 165 | + shaders[i].tex1 = glGetUniformLocation(shaders[i].prog,"tex1");
|
| 166 | + shaders[i].ckey = glGetUniformLocation(shaders[i].prog,"ckey");
|
| 167 | + shaders[i].pal = glGetUniformLocation(shaders[i].prog,"pal");
|
| 168 | + shaders[i].view = glGetUniformLocation(shaders[i].prog,"view");
|
164 | 169 | }
|
165 | 170 | }
|
166 | 171 |
|
Index: ddraw/shaders.h |
— | — | @@ -29,6 +29,11 @@ |
30 | 30 | GLint pos;
|
31 | 31 | GLint rgb;
|
32 | 32 | GLint texcoord;
|
| 33 | + GLint tex0;
|
| 34 | + GLint tex1;
|
| 35 | + GLint ckey;
|
| 36 | + GLint pal;
|
| 37 | + GLint view;
|
33 | 38 | } SHADER;
|
34 | 39 |
|
35 | 40 | extern SHADER shaders[];
|