Index: ddraw/ShaderGen3D.cpp |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | Bit 11 - Specular highlights VS/FS
|
63 | 63 | Bit 12 - Stippled alpha FS
|
64 | 64 | Bit 13 - Color key transparency FS
|
65 | | -Bit 14-17 - Z bias FS
|
| 65 | +Bit 14-17 - Reserved
|
66 | 66 | Bits 18-20 - Number of lights VS/FS
|
67 | 67 | Bit 21 - Camera relative specular highlights VS/FS
|
68 | 68 | Bit 22 - Alpha blended color key FS
|
— | — | @@ -93,6 +93,9 @@ |
94 | 94 | Bits 28-33: Texture alpha argument 2 FS
|
95 | 95 | Bits 34-36: Texture coordinate index VS
|
96 | 96 | Bits 37-38: Texture coordinate flags VS
|
| 97 | + Bits in flags:
|
| 98 | + 00=passthru 01=cameraspacenormal
|
| 99 | + 10=cameraspaceposition 11=cameraspacereflectionvector
|
97 | 100 | Bits 39-40: U Texture address GL
|
98 | 101 | Bits 41-42: V Texture address GL
|
99 | 102 | Bits 43-45: Texture magnification filter GL/FS?
|
— | — | @@ -103,11 +106,7 @@ |
104 | 107 | Bit 53: Projected texcoord VS
|
105 | 108 | Bits in texcoord ID:
|
106 | 109 | 00=2dim 01=3dim 10=4dim 11=1dim
|
107 | | -Bits 54-56: Texture coordinate index VS
|
108 | | -Bits 57-58: Texture coordinate flags VS
|
109 | | -Bits in flags:
|
110 | | -00=passthru 01=cameraspacenormal
|
111 | | -10=cameraspaceposition 11=cameraspacereflectionvector
|
| 110 | +Bits 54-58: Reserved
|
112 | 111 | Bit 59: Texture image enabled
|
113 | 112 | Bit 60: Texture has color key
|
114 | 113 | */
|
— | — | @@ -145,7 +144,7 @@ |
146 | 145 | * @param id
|
147 | 146 | * 64-bit value containing current render states
|
148 | 147 | * @param texstate
|
149 | | - * Pointer to the texture stage state array, containing 8 64-bit state values
|
| 148 | + * Pointer to the texture state ID.
|
150 | 149 | * @param texcoords
|
151 | 150 | * Pointer to number of texture coordinates in each texture stage
|
152 | 151 | * @param type
|
— | — | @@ -154,7 +153,7 @@ |
155 | 154 | * 1 for generated 2D
|
156 | 155 | * 2 for generated 3D
|
157 | 156 | */
|
158 | | -void ShaderGen3D_SetShader(ShaderGen3D *This, __int64 id, TEXTURESTAGE *texstate, int *texcoords, int type, ShaderGen2D *gen2d)
|
| 157 | +void ShaderGen3D_SetShader(ShaderGen3D *This, __int64 id, __int64 *texstate, int *texcoords, int type, ShaderGen2D *gen2d)
|
159 | 158 | {
|
160 | 159 | int shaderindex = -1;
|
161 | 160 | switch(type)
|
— | — | @@ -215,7 +214,7 @@ |
216 | 215 | {
|
217 | 216 | bool texidmatch = true;
|
218 | 217 | for(int j = 0; j < 8; j++)
|
219 | | - if(This->genshaders[i].texids[j] != texstate[j].shaderid) texidmatch = false;
|
| 218 | + if(This->genshaders[i].texids[j] != texstate[j]) texidmatch = false;
|
220 | 219 | if(texidmatch)
|
221 | 220 | {
|
222 | 221 | if(!memcmp(This->genshaders[i].texcoords,texcoords,8*sizeof(int)))
|
— | — | @@ -247,7 +246,7 @@ |
248 | 247 | }
|
249 | 248 | This->genshaders[shaderindex].id = id;
|
250 | 249 | for(int i = 0; i < 8; i++)
|
251 | | - This->genshaders[shaderindex].texids[i] = texstate[i].shaderid;
|
| 250 | + This->genshaders[shaderindex].texids[i] = texstate[i];
|
252 | 251 | memcpy(This->genshaders[shaderindex].texcoords,texcoords,8*sizeof(int));
|
253 | 252 | This->ext->glUseProgram(This->genshaders[shaderindex].shader.prog);
|
254 | 253 | This->current_prog = This->genshaders[shaderindex].shader.prog;
|
— | — | @@ -485,7 +484,7 @@ |
486 | 485 | * @param texcoords
|
487 | 486 | * Pointer to number of texture coordinates in each texture stage
|
488 | 487 | */
|
489 | | -void ShaderGen3D_CreateShader(ShaderGen3D *This, int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords)
|
| 488 | +void ShaderGen3D_CreateShader(ShaderGen3D *This, int index, __int64 id, __int64 *texstate, int *texcoords)
|
490 | 489 | {
|
491 | 490 | STRING tmp;
|
492 | 491 | ZeroMemory(&tmp, sizeof(STRING));
|
— | — | @@ -684,7 +683,7 @@ |
685 | 684 | int texindex;
|
686 | 685 | for(i = 0; i < 8; i++)
|
687 | 686 | {
|
688 | | - if((texstate[i].shaderid>>50)&1)
|
| 687 | + if((texstate[i]>>50)&1)
|
689 | 688 | {
|
690 | 689 | FIXME("Support texture coordinate transform");
|
691 | 690 | }
|
— | — | @@ -693,7 +692,7 @@ |
694 | 693 | String_Assign(&tmp,op_texpassthru1);
|
695 | 694 | tmp.ptr[12] = *(_itoa(i,idstring,10));
|
696 | 695 | String_Append(vsrc, tmp.ptr);
|
697 | | - texindex = (texstate[i].shaderid>>54)&3;
|
| 696 | + texindex = (texstate[i]>>34)&3;
|
698 | 697 | switch(texcoords[texindex])
|
699 | 698 | {
|
700 | 699 | case -1: // No texcoords
|
— | — | @@ -785,7 +784,7 @@ |
786 | 785 | // Uniforms
|
787 | 786 | for(i = 0; i < 8; i++)
|
788 | 787 | {
|
789 | | - if((texstate[i].shaderid & 31) == D3DTOP_DISABLE)break;
|
| 788 | + if((texstate[i] & 31) == D3DTOP_DISABLE)break;
|
790 | 789 | String_Assign(&tmp, unif_tex);
|
791 | 790 | tmp.ptr[21] = *(_itoa(i,idstring,10));
|
792 | 791 | String_Append(fsrc, tmp.ptr);
|
— | — | @@ -794,7 +793,7 @@ |
795 | 794 | {
|
796 | 795 | for(i = 0; i < 8; i++)
|
797 | 796 | {
|
798 | | - if((texstate[i].shaderid>>60)&1)
|
| 797 | + if((texstate[i]>>60)&1)
|
799 | 798 | {
|
800 | 799 | String_Assign(&tmp, unif_key);
|
801 | 800 | tmp.ptr[17] = *(_itoa(i,idstring,10));
|
— | — | @@ -833,19 +832,19 @@ |
834 | 833 | if((id>>13)&1) usecolorkey = true;
|
835 | 834 | for(i = 0; i < 8; i++)
|
836 | 835 | {
|
837 | | - if((texstate[i].shaderid & 31) == D3DTOP_DISABLE)break;
|
838 | | - args[0] = (texstate[i].shaderid>>5)&63;
|
839 | | - args[1] = (texstate[i].shaderid>>11)&63;
|
840 | | - args[2] = (texstate[i].shaderid>>22)&63;
|
841 | | - args[3] = (texstate[i].shaderid>>28)&63;
|
| 836 | + if((texstate[i] & 31) == D3DTOP_DISABLE)break;
|
| 837 | + args[0] = (texstate[i]>>5)&63;
|
| 838 | + args[1] = (texstate[i]>>11)&63;
|
| 839 | + args[2] = (texstate[i]>>22)&63;
|
| 840 | + args[3] = (texstate[i]>>28)&63;
|
842 | 841 | // Color key
|
843 | 842 | if(usecolorkey)
|
844 | 843 | {
|
845 | | - if((texstate[i].shaderid>>60)&1)
|
| 844 | + if((texstate[i]>>60)&1)
|
846 | 845 | {
|
847 | 846 | String_Assign(&arg1, op_colorkeyin);
|
848 | 847 | arg1.ptr[33] = *(_itoa(i, idstring, 10));
|
849 | | - arg1.ptr[47] = *(_itoa((texstate[i].shaderid >> 54) & 7, idstring, 10));
|
| 848 | + arg1.ptr[47] = *(_itoa((texstate[i] >> 34) & 7, idstring, 10));
|
850 | 849 | arg1.ptr[63] = *(_itoa(i, idstring, 10));
|
851 | 850 | String_Append(fsrc, arg1.ptr);
|
852 | 851 | String_Assign(&arg1, op_colorkey);
|
— | — | @@ -865,11 +864,11 @@ |
866 | 865 | String_Assign(&arg1, blendargs[1]);
|
867 | 866 | break;
|
868 | 867 | case D3DTA_TEXTURE:
|
869 | | - if((texstate[i].shaderid >> 59)&1)
|
| 868 | + if((texstate[i] >> 59)&1)
|
870 | 869 | {
|
871 | 870 | String_Assign(&arg1, blendargs[2]);
|
872 | 871 | arg1.ptr[17] = *(_itoa(i,idstring,10));
|
873 | | - arg1.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 872 | + arg1.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
874 | 873 | }
|
875 | 874 | else texfail = true;
|
876 | 875 | break;
|
— | — | @@ -901,11 +900,11 @@ |
902 | 901 | String_Assign(&arg2, blendargs[1]);
|
903 | 902 | break;
|
904 | 903 | case D3DTA_TEXTURE:
|
905 | | - if((texstate[i].shaderid >> 59)&1)
|
| 904 | + if((texstate[i] >> 59)&1)
|
906 | 905 | {
|
907 | 906 | String_Assign(&arg2, blendargs[2]);
|
908 | 907 | arg2.ptr[17] = *(_itoa(i,idstring,10));
|
909 | | - arg2.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 908 | + arg2.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
910 | 909 | }
|
911 | 910 | else texfail = true;
|
912 | 911 | break;
|
— | — | @@ -927,7 +926,7 @@ |
928 | 927 | }
|
929 | 928 | if (args[1] & D3DTA_ALPHAREPLICATE) String_Append(&arg2, blendargs[10]);
|
930 | 929 | else String_Append(&arg2, blendargs[8]);
|
931 | | - if(!texfail) switch(texstate[i].shaderid & 31)
|
| 930 | + if(!texfail) switch(texstate[i] & 31)
|
932 | 931 | {
|
933 | 932 | case D3DTOP_DISABLE:
|
934 | 933 | default:
|
— | — | @@ -1012,7 +1011,7 @@ |
1013 | 1012 | case D3DTOP_BLENDTEXTUREALPHA:
|
1014 | 1013 | String_Assign(&texarg, blendargs[2]);
|
1015 | 1014 | texarg.ptr[17] = *(_itoa(i,idstring,10));
|
1016 | | - texarg.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1015 | + texarg.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1017 | 1016 | String_Append(fsrc, "color.rgb = ");
|
1018 | 1017 | String_Append(fsrc, arg1.ptr);
|
1019 | 1018 | String_Append(fsrc, " * ");
|
— | — | @@ -1033,7 +1032,7 @@ |
1034 | 1033 | case D3DTOP_BLENDTEXTUREALPHAPM:
|
1035 | 1034 | String_Assign(&texarg, blendargs[2]);
|
1036 | 1035 | texarg.ptr[17] = *(_itoa(i,idstring,10));
|
1037 | | - texarg.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1036 | + texarg.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1038 | 1037 | String_Append(fsrc, "color.rgb = ");
|
1039 | 1038 | String_Append(fsrc, arg1.ptr);
|
1040 | 1039 | String_Append(fsrc, " + ");
|
— | — | @@ -1050,7 +1049,7 @@ |
1051 | 1050 | String_Append(fsrc, " * (1.0-color.a);\n");
|
1052 | 1051 | break;
|
1053 | 1052 | }
|
1054 | | - if(((texstate[i].shaderid>>17) & 31) == D3DTOP_DISABLE)alphadisabled = true;
|
| 1053 | + if(((texstate[i]>>17) & 31) == D3DTOP_DISABLE)alphadisabled = true;
|
1055 | 1054 | if(alphadisabled) continue;
|
1056 | 1055 | // Alpha stage
|
1057 | 1056 | texfail = false;
|
— | — | @@ -1066,12 +1065,12 @@ |
1067 | 1066 | String_Append(&arg1, blendargs[9]);
|
1068 | 1067 | break;
|
1069 | 1068 | case D3DTA_TEXTURE:
|
1070 | | - if((texstate[i].shaderid >> 59)&1)
|
| 1069 | + if((texstate[i] >> 59)&1)
|
1071 | 1070 | {
|
1072 | 1071 | String_Assign(&arg1, blendargs[2]);
|
1073 | 1072 | String_Append(&arg1, blendargs[9]);
|
1074 | 1073 | arg1.ptr[17] = *(_itoa(i,idstring,10));
|
1075 | | - arg1.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1074 | + arg1.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1076 | 1075 | }
|
1077 | 1076 | else texfail = true;
|
1078 | 1077 | break;
|
— | — | @@ -1105,12 +1104,12 @@ |
1106 | 1105 | String_Append(&arg2, blendargs[9]);
|
1107 | 1106 | break;
|
1108 | 1107 | case D3DTA_TEXTURE:
|
1109 | | - if((texstate[i].shaderid >> 59)&1)
|
| 1108 | + if((texstate[i] >> 59)&1)
|
1110 | 1109 | {
|
1111 | 1110 | String_Assign(&arg2, blendargs[2]);
|
1112 | 1111 | String_Append(&arg2, blendargs[9]);
|
1113 | 1112 | arg2.ptr[17] = *(_itoa(i,idstring,10));
|
1114 | | - arg2.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1113 | + arg2.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1115 | 1114 | }
|
1116 | 1115 | else texfail = true;
|
1117 | 1116 | break;
|
— | — | @@ -1132,7 +1131,7 @@ |
1133 | 1132 | String_Append(&tmp, ")");
|
1134 | 1133 | String_Assign(&arg2, tmp.ptr);
|
1135 | 1134 | }
|
1136 | | - if (!texfail) switch ((texstate[i].shaderid >> 17) & 31)
|
| 1135 | + if (!texfail) switch ((texstate[i] >> 17) & 31)
|
1137 | 1136 | {
|
1138 | 1137 | case D3DTOP_DISABLE:
|
1139 | 1138 | default:
|
— | — | @@ -1217,7 +1216,7 @@ |
1218 | 1217 | case D3DTOP_BLENDTEXTUREALPHA:
|
1219 | 1218 | String_Assign(&texarg, blendargs[2]);
|
1220 | 1219 | texarg.ptr[17] = *(_itoa(i,idstring,10));
|
1221 | | - texarg.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1220 | + texarg.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1222 | 1221 | String_Append(fsrc, "color.a = ");
|
1223 | 1222 | String_Append(fsrc, arg1.ptr);
|
1224 | 1223 | String_Append(fsrc, " * ");
|
— | — | @@ -1238,7 +1237,7 @@ |
1239 | 1238 | case D3DTOP_BLENDTEXTUREALPHAPM:
|
1240 | 1239 | String_Assign(&texarg, blendargs[2]);
|
1241 | 1240 | texarg.ptr[17] = *(_itoa(i,idstring,10));
|
1242 | | - texarg.ptr[31] = *(_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 1241 | + texarg.ptr[31] = *(_itoa((texstate[i]>>34)&7,idstring,10));
|
1243 | 1242 | String_Append(fsrc, "color.a = ");
|
1244 | 1243 | String_Append(fsrc, arg1.ptr);
|
1245 | 1244 | String_Append(fsrc, " + ");
|
— | — | @@ -1305,7 +1304,7 @@ |
1306 | 1305 | String_Append(fsrc, op_fogclamp);
|
1307 | 1306 | String_Append(fsrc, op_fogblend);
|
1308 | 1307 | }
|
1309 | | - if(((id>>61)&1) && !vertexfog && !pixelfog) String_Append(fsrc, op_fogassign);
|
| 1308 | + //if(((id>>61)&1) && !vertexfog && !pixelfog) String_Append(fsrc, op_fogassign);
|
1310 | 1309 | if (dither) String_Append(fsrc,op_dither);
|
1311 | 1310 | String_Append(fsrc, op_colorfragout);
|
1312 | 1311 | String_Append(fsrc, mainend);
|
Index: ddraw/ShaderGen3D.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2014 William Feely
|
| 3 | +// Copyright (C) 2012-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -64,10 +64,10 @@ |
65 | 65 | void ShaderGen3D_Init(glExtensions *glext, ShaderManager *shaderman, ShaderGen3D *gen);
|
66 | 66 | void ShaderGen3D_Delete(ShaderGen3D *This);
|
67 | 67 | void ShaderGen3D_ClearShaders(ShaderGen3D *This);
|
68 | | -void ShaderGen3D_SetShader(ShaderGen3D *This, __int64 id, TEXTURESTAGE *texstate, int *texcoords, int type, ShaderGen2D *gen2d);
|
| 68 | +void ShaderGen3D_SetShader(ShaderGen3D *This, __int64 id, __int64 *texstate, int *texcoords, int type, ShaderGen2D *gen2d);
|
69 | 69 | GLuint ShaderGen3D_GetProgram(ShaderGen3D *This);
|
70 | 70 | void ShaderGen3D_ZeroShaderArray(ShaderGen3D *This);
|
71 | | -void ShaderGen3D_CreateShader(ShaderGen3D *This, int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords);
|
| 71 | +void ShaderGen3D_CreateShader(ShaderGen3D *This, int index, __int64 id, __int64 *texstate, int *texcoords);
|
72 | 72 |
|
73 | 73 | #ifdef __cplusplus
|
74 | 74 | }
|
Index: ddraw/ShaderManager.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | free(This->gen3d);
|
206 | 206 | }
|
207 | 207 |
|
208 | | -void ShaderManager_SetShader(ShaderManager *This, __int64 id, TEXTURESTAGE *texstate, int *texcoords, int type)
|
| 208 | +void ShaderManager_SetShader(ShaderManager *This, __int64 id, __int64 *texstate, int *texcoords, int type)
|
209 | 209 | {
|
210 | 210 | ShaderGen3D_SetShader(This->gen3d, id, texstate, texcoords, type, This->gen2d);
|
211 | 211 | }
|
Index: ddraw/ShaderManager.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -61,7 +61,7 @@ |
62 | 62 |
|
63 | 63 | void ShaderManager_Init(glExtensions *glext, ShaderManager *shaderman);
|
64 | 64 | void ShaderManager_Delete(ShaderManager *This);
|
65 | | -void ShaderManager_SetShader(ShaderManager *This, __int64 id, TEXTURESTAGE *texstate, int *texcoords, int type);
|
| 65 | +void ShaderManager_SetShader(ShaderManager *This, __int64 id, __int64 *texstate, int *texcoords, int type);
|
66 | 66 |
|
67 | 67 | #ifdef __cplusplus
|
68 | 68 | }
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -191,8 +191,6 @@ |
192 | 192 | 0,
|
193 | 193 | D3DTTFF_DISABLE,
|
194 | 194 | NULL,
|
195 | | - false,
|
196 | | - 0,
|
197 | 195 | GL_NEAREST,
|
198 | 196 | GL_NEAREST
|
199 | 197 | };
|
— | — | @@ -219,8 +217,6 @@ |
220 | 218 | 0,
|
221 | 219 | D3DTTFF_DISABLE,
|
222 | 220 | NULL,
|
223 | | - false,
|
224 | | - 0,
|
225 | 221 | GL_NEAREST,
|
226 | 222 | GL_NEAREST
|
227 | 223 | };
|
— | — | @@ -365,7 +361,7 @@ |
366 | 362 | d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
|
367 | 363 | scalex = scaley = 0;
|
368 | 364 | mhWorld = mhView = mhProjection = 0;
|
369 | | - glRenderer_InitD3D(renderer,zbuffer);
|
| 365 | + glRenderer_InitD3D(renderer,zbuffer,glDDS7->ddsd.dwWidth,glDDS7->ddsd.dwHeight);
|
370 | 366 | glD3DDev3 = new glDirect3DDevice3(this);
|
371 | 367 | glD3DDev2 = new glDirect3DDevice2(this);
|
372 | 368 | glD3DDev1 = new glDirect3DDevice1(this);
|
— | — | @@ -378,7 +374,7 @@ |
379 | 375 | TRACE_ENTER(1,14,this);
|
380 | 376 | for(int i = 0; i < lightsmax; i++)
|
381 | 377 | if(lights[i]) delete lights[i];
|
382 | | - delete lights;
|
| 378 | + free(lights);
|
383 | 379 | for(int i = 0; i < 8; i++)
|
384 | 380 | if(texstages[i].texture) texstages[i].texture->Release();
|
385 | 381 | for(int i = 0; i < materialcount; i++)
|
— | — | @@ -705,7 +701,7 @@ |
706 | 702 | TRACE_EXIT(0,0);
|
707 | 703 | }
|
708 | 704 |
|
709 | | -__int64 glDirect3DDevice7::SelectShader(GLVERTEX *VertexType)
|
| 705 | +/*__int64 glDirect3DDevice7::SelectShader(GLVERTEX *VertexType)
|
710 | 706 | {
|
711 | 707 | TRACE_ENTER(2,14,this,14,VertexType);
|
712 | 708 | int i;
|
— | — | @@ -730,7 +726,7 @@ |
731 | 727 | if(renderstate[D3DRENDERSTATE_SPECULARENABLE]) shader |= (1i64 << 11);
|
732 | 728 | if(renderstate[D3DRENDERSTATE_STIPPLEDALPHA]) shader |= (1i64 << 12);
|
733 | 729 | if(renderstate[D3DRENDERSTATE_COLORKEYENABLE]) shader |= (1i64 << 13);
|
734 | | - shader |= (((__int64)renderstate[D3DRENDERSTATE_ZBIAS] & 15) << 14);
|
| 730 | + //shader |= (((__int64)renderstate[D3DRENDERSTATE_ZBIAS] & 15) << 14);
|
735 | 731 | int numlights = 0;
|
736 | 732 | for(i = 0; i < 8; i++)
|
737 | 733 | if(gllights[i] != -1) numlights++;
|
— | — | @@ -768,7 +764,7 @@ |
769 | 765 | if(VertexType[1].data) shader |= (1i64 << 50);
|
770 | 766 | if(renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] == D3DTBLEND_MODULATE)
|
771 | 767 | {
|
772 | | - bool noalpha = false;;
|
| 768 | + bool noalpha = false;
|
773 | 769 | if(!texstages[0].texture) noalpha = true;
|
774 | 770 | if(texstages[0].texture)
|
775 | 771 | if(!(texstages[0].texture->ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS))
|
— | — | @@ -812,7 +808,7 @@ |
813 | 809 | }
|
814 | 810 | TRACE_EXIT(10,&shader);
|
815 | 811 | return shader;
|
816 | | -}
|
| 812 | +}*/
|
817 | 813 |
|
818 | 814 | HRESULT glDirect3DDevice7::fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr)
|
819 | 815 | {
|
— | — | @@ -1246,6 +1242,7 @@ |
1247 | 1243 | {
|
1248 | 1244 | foundlight = true;
|
1249 | 1245 | gllights[i] = dwLightIndex;
|
| 1246 | + glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light, FALSE);
|
1250 | 1247 | break;
|
1251 | 1248 | }
|
1252 | 1249 | }
|
— | — | @@ -1258,6 +1255,7 @@ |
1259 | 1256 | if(gllights[i] == dwLightIndex)
|
1260 | 1257 | {
|
1261 | 1258 | gllights[i] = -1;
|
| 1259 | + glRenderer_SetLight(renderer, i, NULL, TRUE);
|
1262 | 1260 | }
|
1263 | 1261 | }
|
1264 | 1262 | TRACE_EXIT(23,D3D_OK);
|
— | — | @@ -1321,6 +1319,10 @@ |
1322 | 1320 | }
|
1323 | 1321 | if(!lights[dwLightIndex]) lights[dwLightIndex] = new glDirect3DLight;
|
1324 | 1322 | lights[dwLightIndex]->SetLight7(lpLight);
|
| 1323 | + for (int i = 0; i < 8; i++)
|
| 1324 | + {
|
| 1325 | + if (gllights[i] == dwLightIndex) glRenderer_SetLight(renderer, i, &lights[gllights[i]]->light, FALSE);
|
| 1326 | + }
|
1325 | 1327 | TRACE_EXIT(23,D3D_OK);
|
1326 | 1328 | return D3D_OK;
|
1327 | 1329 | }
|
— | — | @@ -1330,6 +1332,7 @@ |
1331 | 1333 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1332 | 1334 | if(!lpMaterial) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1333 | 1335 | memcpy(&material,lpMaterial,sizeof(D3DMATERIAL7));
|
| 1336 | + glRenderer_SetMaterial(renderer, lpMaterial);
|
1334 | 1337 | TRACE_EXIT(23,D3D_OK);
|
1335 | 1338 | return D3D_OK;
|
1336 | 1339 | }
|
— | — | @@ -1336,11 +1339,14 @@ |
1337 | 1340 |
|
1338 | 1341 | HRESULT WINAPI glDirect3DDevice7::SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
1339 | 1342 | {
|
1340 | | - TRACE_ENTER(3,14,this,27,dwRendStateType,9,dwRenderState);
|
| 1343 | + BOOL devstate = TRUE;
|
| 1344 | + BOOL noalpha = FALSE;
|
| 1345 | + TRACE_ENTER(3, 14, this, 27, dwRendStateType, 9, dwRenderState);
|
1341 | 1346 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1342 | 1347 | switch(dwRendStateType)
|
1343 | 1348 | {
|
1344 | 1349 | case D3DRENDERSTATE_TEXTUREHANDLE:
|
| 1350 | + devstate = FALSE;
|
1345 | 1351 | if(dwRenderState > texturecount-1) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1346 | 1352 | if(dwRenderState)
|
1347 | 1353 | {
|
— | — | @@ -1350,18 +1356,24 @@ |
1351 | 1357 | else SetTexture(0,NULL);
|
1352 | 1358 | break;
|
1353 | 1359 | case D3DRENDERSTATE_TEXTUREADDRESS:
|
| 1360 | + devstate = FALSE;
|
1354 | 1361 | SetRenderState(D3DRENDERSTATE_TEXTUREADDRESSU,dwRenderState);
|
1355 | 1362 | SetRenderState(D3DRENDERSTATE_TEXTUREADDRESSV,dwRenderState);
|
1356 | 1363 | break;
|
1357 | 1364 | case D3DRENDERSTATE_WRAPU:
|
| 1365 | + devstate = FALSE;
|
1358 | 1366 | if(dwRenderState) renderstate[D3DRENDERSTATE_WRAP0] |= D3DWRAP_U;
|
1359 | 1367 | else renderstate[D3DRENDERSTATE_WRAP0] &= ~D3DWRAP_U;
|
| 1368 | + SetRenderState(D3DRENDERSTATE_WRAP0, renderstate[D3DRENDERSTATE_WRAP0]);
|
1360 | 1369 | break;
|
1361 | 1370 | case D3DRENDERSTATE_WRAPV:
|
1362 | | - if(dwRenderState) renderstate[D3DRENDERSTATE_WRAP0] |= D3DWRAP_V;
|
| 1371 | + devstate = FALSE;
|
| 1372 | + if (dwRenderState) renderstate[D3DRENDERSTATE_WRAP0] |= D3DWRAP_V;
|
1363 | 1373 | else renderstate[D3DRENDERSTATE_WRAP0] &= ~D3DWRAP_V;
|
| 1374 | + SetRenderState(D3DRENDERSTATE_WRAP0, renderstate[D3DRENDERSTATE_WRAP0]);
|
1364 | 1375 | break;
|
1365 | 1376 | case D3DRENDERSTATE_TEXTUREMAG:
|
| 1377 | + devstate = FALSE;
|
1366 | 1378 | switch(dwRenderState)
|
1367 | 1379 | {
|
1368 | 1380 | case D3DFILTER_NEAREST:
|
— | — | @@ -1373,6 +1385,7 @@ |
1374 | 1386 | }
|
1375 | 1387 | break;
|
1376 | 1388 | case D3DRENDERSTATE_TEXTUREMIN:
|
| 1389 | + devstate = FALSE;
|
1377 | 1390 | switch(dwRenderState)
|
1378 | 1391 | {
|
1379 | 1392 | case D3DFILTER_NEAREST:
|
— | — | @@ -1420,7 +1433,13 @@ |
1421 | 1434 | SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
|
1422 | 1435 | SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_CURRENT);
|
1423 | 1436 | SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
1424 | | - break; // Automatically selected based on texture
|
| 1437 | + if (!texstages[0].texture) noalpha = TRUE;
|
| 1438 | + if (texstages[0].texture)
|
| 1439 | + if (!(texstages[0].texture->ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS))
|
| 1440 | + noalpha = TRUE;
|
| 1441 | + if (noalpha) SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2);
|
| 1442 | + else SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
| 1443 | + break;
|
1425 | 1444 | case D3DTBLEND_DECALALPHA:
|
1426 | 1445 | SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
1427 | 1446 | SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT);
|
— | — | @@ -1453,6 +1472,7 @@ |
1454 | 1473 | if(dwRendStateType > 152) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1455 | 1474 | if(dwRendStateType < 0) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1456 | 1475 | renderstate[dwRendStateType] = dwRenderState;
|
| 1476 | + if (devstate) glRenderer_SetRenderState(renderer, dwRendStateType, dwRenderState);
|
1457 | 1477 | TRACE_EXIT(23,D3D_OK);
|
1458 | 1478 | return D3D_OK;
|
1459 | 1479 | }
|
— | — | @@ -1487,13 +1507,24 @@ |
1488 | 1508 | if(dwStage > 7) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1489 | 1509 | if(texstages[dwStage].texture) texstages[dwStage].texture->Release();
|
1490 | 1510 | texstages[dwStage].texture = (glDirectDrawSurface7*)lpTexture;
|
1491 | | - texstages[dwStage].dirty = true;
|
1492 | 1511 | if(lpTexture) lpTexture->AddRef();
|
| 1512 | + glRenderer_SetTexture(renderer, dwStage, texstages[dwStage].texture);
|
| 1513 | + if (renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] == D3DTBLEND_MODULATE)
|
| 1514 | + {
|
| 1515 | + bool noalpha = false;
|
| 1516 | + if (!texstages[0].texture) noalpha = true;
|
| 1517 | + if (texstages[0].texture)
|
| 1518 | + if (!(texstages[0].texture->ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS))
|
| 1519 | + noalpha = true;
|
| 1520 | + if (noalpha) SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);
|
| 1521 | + else SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
| 1522 | + }
|
1493 | 1523 | TRACE_EXIT(23,D3D_OK);
|
1494 | 1524 | return D3D_OK;
|
1495 | 1525 | }
|
1496 | 1526 | HRESULT WINAPI glDirect3DDevice7::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
1497 | 1527 | {
|
| 1528 | + BOOL devstate = TRUE;
|
1498 | 1529 | TRACE_ENTER(4,14,this,8,dwStage,28,dwState,9,dwValue);
|
1499 | 1530 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1500 | 1531 | if(dwStage > 7) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
— | — | @@ -1501,238 +1532,107 @@ |
1502 | 1533 | {
|
1503 | 1534 | case D3DTSS_COLOROP:
|
1504 | 1535 | if(!dwValue || (dwValue > 24)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1505 | | - if(dwStage == 0)renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] = 0;
|
| 1536 | + if (dwStage == 0)SetRenderState(D3DRENDERSTATE_TEXTUREMAPBLEND, 0);
|
1506 | 1537 | texstages[dwStage].colorop = (D3DTEXTUREOP)dwValue;
|
1507 | | - texstages[dwStage].dirty = true;
|
1508 | | - TRACE_EXIT(23,D3D_OK);
|
1509 | | - return D3D_OK;
|
| 1538 | + break;
|
1510 | 1539 | case D3DTSS_COLORARG1:
|
1511 | 1540 | if((dwValue & D3DTA_SELECTMASK) > 4) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1512 | 1541 | if(dwValue > 0x34) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1513 | 1542 | texstages[dwStage].colorarg1 = dwValue;
|
1514 | | - texstages[dwStage].dirty = true;
|
1515 | | - TRACE_EXIT(23,D3D_OK);
|
1516 | | - return D3D_OK;
|
| 1543 | + break;
|
1517 | 1544 | case D3DTSS_COLORARG2:
|
1518 | 1545 | if((dwValue & D3DTA_SELECTMASK) > 4) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1519 | 1546 | if(dwValue > 0x34) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1520 | 1547 | texstages[dwStage].colorarg2 = dwValue;
|
1521 | | - texstages[dwStage].dirty = true;
|
1522 | | - TRACE_EXIT(23,D3D_OK);
|
1523 | | - return D3D_OK;
|
| 1548 | + break;
|
1524 | 1549 | case D3DTSS_ALPHAOP:
|
1525 | 1550 | if(!dwValue || (dwValue > 24)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1526 | | - if(dwStage == 0)renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] = 0;
|
1527 | | - texstages[dwStage].alphaop = (D3DTEXTUREOP )dwValue;
|
1528 | | - texstages[dwStage].dirty = true;
|
1529 | | - TRACE_EXIT(23,D3D_OK);
|
1530 | | - return D3D_OK;
|
| 1551 | + if (dwStage == 0)SetRenderState(D3DRENDERSTATE_TEXTUREMAPBLEND, 0);
|
| 1552 | + texstages[dwStage].alphaop = (D3DTEXTUREOP)dwValue;
|
| 1553 | + break;
|
1531 | 1554 | case D3DTSS_ALPHAARG1:
|
1532 | 1555 | if((dwValue & D3DTA_SELECTMASK) > 4) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1533 | 1556 | if(dwValue > 0x34) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1534 | 1557 | texstages[dwStage].alphaarg1 = dwValue;
|
1535 | | - texstages[dwStage].dirty = true;
|
1536 | | - TRACE_RET(HRESULT,23,D3D_OK);
|
1537 | | - return D3D_OK;
|
| 1558 | + break;
|
1538 | 1559 | case D3DTSS_ALPHAARG2:
|
1539 | 1560 | if((dwValue & D3DTA_SELECTMASK) > 4) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1540 | 1561 | if(dwValue > 0x34) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1541 | 1562 | texstages[dwStage].alphaarg2 = dwValue;
|
1542 | | - texstages[dwStage].dirty = true;
|
1543 | | - TRACE_EXIT(23,D3D_OK);
|
1544 | | - return D3D_OK;
|
| 1563 | + break;
|
1545 | 1564 | case D3DTSS_BUMPENVMAT00:
|
1546 | 1565 | memcpy(&texstages[dwStage].bumpenv00,&dwValue,sizeof(D3DVALUE));
|
1547 | | - texstages[dwStage].dirty = true;
|
1548 | | - TRACE_EXIT(23,D3D_OK);
|
1549 | | - return D3D_OK;
|
| 1566 | + break;
|
1550 | 1567 | case D3DTSS_BUMPENVMAT01:
|
1551 | 1568 | memcpy(&texstages[dwStage].bumpenv01,&dwValue,sizeof(D3DVALUE));
|
1552 | | - texstages[dwStage].dirty = true;
|
1553 | | - TRACE_EXIT(23,D3D_OK);
|
1554 | | - return D3D_OK;
|
| 1569 | + break;
|
1555 | 1570 | case D3DTSS_BUMPENVMAT10:
|
1556 | 1571 | memcpy(&texstages[dwStage].bumpenv10,&dwValue,sizeof(D3DVALUE));
|
1557 | | - texstages[dwStage].dirty = true;
|
1558 | | - TRACE_EXIT(23,D3D_OK);
|
1559 | | - return D3D_OK;
|
| 1572 | + break;
|
1560 | 1573 | case D3DTSS_BUMPENVMAT11:
|
1561 | 1574 | memcpy(&texstages[dwStage].bumpenv11,&dwValue,sizeof(D3DVALUE));
|
1562 | | - texstages[dwStage].dirty = true;
|
1563 | | - TRACE_EXIT(23,D3D_OK);
|
1564 | | - return D3D_OK;
|
| 1575 | + break;
|
1565 | 1576 | case D3DTSS_TEXCOORDINDEX:
|
1566 | 1577 | if((dwValue & 0xFFFF) > 7) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1567 | 1578 | if((dwValue >> 16) > 3) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1568 | 1579 | texstages[dwStage].texcoordindex = dwValue;
|
1569 | | - texstages[dwStage].dirty = true;
|
1570 | | - TRACE_EXIT(23,D3D_OK);
|
1571 | | - return D3D_OK;
|
| 1580 | + break;
|
1572 | 1581 | case D3DTSS_ADDRESS:
|
1573 | 1582 | if(!dwValue || (dwValue > 4)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1574 | | - texstages[dwStage].addressu = (D3DTEXTUREADDRESS)dwValue;
|
1575 | | - texstages[dwStage].addressv = (D3DTEXTUREADDRESS)dwValue;
|
1576 | | - texstages[dwStage].dirty = true;
|
1577 | | - TRACE_EXIT(23,D3D_OK);
|
1578 | | - return D3D_OK;
|
| 1583 | + devstate = FALSE;
|
| 1584 | + SetTextureStageState(dwStage, D3DTSS_ADDRESSU, dwValue);
|
| 1585 | + SetTextureStageState(dwStage, D3DTSS_ADDRESSV, dwValue);
|
| 1586 | + break;
|
1579 | 1587 | case D3DTSS_ADDRESSU:
|
1580 | 1588 | if(!dwValue || (dwValue > 4)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1581 | 1589 | texstages[dwStage].addressu = (D3DTEXTUREADDRESS)dwValue;
|
1582 | | - texstages[dwStage].dirty = true;
|
1583 | | - TRACE_EXIT(23,D3D_OK);
|
1584 | | - return D3D_OK;
|
| 1590 | + break;
|
1585 | 1591 | case D3DTSS_ADDRESSV:
|
1586 | 1592 | if(!dwValue || (dwValue > 4)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1587 | 1593 | texstages[dwStage].addressv = (D3DTEXTUREADDRESS)dwValue;
|
1588 | | - texstages[dwStage].dirty = true;
|
1589 | | - TRACE_EXIT(23,D3D_OK);
|
1590 | | - return D3D_OK;
|
| 1594 | + break;
|
1591 | 1595 | case D3DTSS_BORDERCOLOR:
|
1592 | 1596 | texstages[dwStage].bordercolor = dwValue;
|
1593 | | - texstages[dwStage].dirty = true;
|
1594 | | - TRACE_EXIT(23,D3D_OK);
|
1595 | | - return D3D_OK;
|
| 1597 | + break;
|
1596 | 1598 | case D3DTSS_MAGFILTER:
|
1597 | 1599 | if(!dwValue || (dwValue > 5)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1598 | 1600 | texstages[dwStage].magfilter = (D3DTEXTUREMAGFILTER)dwValue;
|
1599 | | - texstages[dwStage].dirty = true;
|
1600 | | - switch(texstages[dwStage].magfilter)
|
1601 | | - {
|
1602 | | - case 1:
|
1603 | | - default:
|
1604 | | - texstages[dwStage].glmagfilter = GL_NEAREST;
|
1605 | | - break;
|
1606 | | - case 2:
|
1607 | | - case 3:
|
1608 | | - case 4:
|
1609 | | - case 5:
|
1610 | | - texstages[dwStage].glmagfilter = GL_LINEAR;
|
1611 | | - break;
|
1612 | | - }
|
1613 | | - TRACE_EXIT(23,D3D_OK);
|
1614 | | - return D3D_OK;
|
| 1601 | + break;
|
1615 | 1602 | case D3DTSS_MINFILTER:
|
1616 | 1603 | if(!dwValue || (dwValue > 3)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1617 | 1604 | texstages[dwStage].minfilter = (D3DTEXTUREMINFILTER)dwValue;
|
1618 | | - texstages[dwStage].dirty = true;
|
1619 | | - switch(texstages[dwStage].minfilter)
|
1620 | | - {
|
1621 | | - case 1:
|
1622 | | - default:
|
1623 | | - switch(texstages[dwStage].mipfilter)
|
1624 | | - {
|
1625 | | - case 1:
|
1626 | | - default:
|
1627 | | - texstages[dwStage].glminfilter = GL_NEAREST;
|
1628 | | - break;
|
1629 | | - case 2:
|
1630 | | - texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
1631 | | - break;
|
1632 | | - case 3:
|
1633 | | - texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
1634 | | - break;
|
1635 | | - }
|
1636 | | - break;
|
1637 | | - case 2:
|
1638 | | - case 3:
|
1639 | | - switch(texstages[dwStage].mipfilter)
|
1640 | | - {
|
1641 | | - case 1:
|
1642 | | - default:
|
1643 | | - texstages[dwStage].glminfilter = GL_LINEAR;
|
1644 | | - break;
|
1645 | | - case 2:
|
1646 | | - texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
1647 | | - break;
|
1648 | | - case 3:
|
1649 | | - texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
1650 | | - break;
|
1651 | | - }
|
1652 | | - break;
|
1653 | | - }
|
1654 | | - TRACE_EXIT(23,D3D_OK);
|
1655 | | - return D3D_OK;
|
| 1605 | + break;
|
1656 | 1606 | case D3DTSS_MIPFILTER:
|
1657 | 1607 | if(!dwValue || (dwValue > 3)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1658 | 1608 | texstages[dwStage].mipfilter = (D3DTEXTUREMIPFILTER)dwValue;
|
1659 | | - texstages[dwStage].dirty = true;
|
1660 | | - switch(texstages[dwStage].mipfilter)
|
1661 | | - {
|
1662 | | - case 1:
|
1663 | | - default:
|
1664 | | - switch(texstages[dwStage].minfilter)
|
1665 | | - {
|
1666 | | - case 1:
|
1667 | | - default:
|
1668 | | - texstages[dwStage].glminfilter = GL_NEAREST;
|
1669 | | - case 2:
|
1670 | | - case 3:
|
1671 | | - texstages[dwStage].glminfilter = GL_LINEAR;
|
1672 | | - }
|
1673 | | - break;
|
1674 | | - case 2:
|
1675 | | - switch(texstages[dwStage].minfilter)
|
1676 | | - {
|
1677 | | - case 1:
|
1678 | | - default:
|
1679 | | - texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
1680 | | - case 2:
|
1681 | | - case 3:
|
1682 | | - texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
1683 | | - }
|
1684 | | - break;
|
1685 | | - case 3:
|
1686 | | - switch(texstages[dwStage].minfilter)
|
1687 | | - {
|
1688 | | - case 1:
|
1689 | | - default:
|
1690 | | - texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
1691 | | - case 2:
|
1692 | | - case 3:
|
1693 | | - texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
1694 | | - }
|
1695 | | - break;
|
1696 | | - }
|
1697 | | - TRACE_EXIT(23,D3D_OK);
|
1698 | | - return D3D_OK;
|
| 1609 | + break;
|
1699 | 1610 | case D3DTSS_MIPMAPLODBIAS:
|
1700 | 1611 | memcpy(&texstages[dwStage].lodbias,&dwValue,sizeof(D3DVALUE));
|
1701 | | - texstages[dwStage].dirty = true;
|
1702 | | - TRACE_EXIT(23,D3D_OK);
|
1703 | | - return D3D_OK;
|
| 1612 | + break;
|
1704 | 1613 | case D3DTSS_MAXMIPLEVEL:
|
1705 | 1614 | texstages[dwStage].miplevel = dwValue;
|
1706 | | - texstages[dwStage].dirty = true;
|
1707 | | - TRACE_EXIT(23,D3D_OK);
|
1708 | | - return D3D_OK;
|
| 1615 | + break;
|
1709 | 1616 | case D3DTSS_MAXANISOTROPY:
|
1710 | 1617 | texstages[dwStage].anisotropy = dwValue;
|
1711 | | - texstages[dwStage].dirty = true;
|
1712 | | - TRACE_EXIT(23,D3D_OK);
|
1713 | | - return D3D_OK;
|
| 1618 | + break;
|
1714 | 1619 | case D3DTSS_BUMPENVLSCALE:
|
1715 | 1620 | memcpy(&texstages[dwStage].bumpenvlscale,&dwValue,sizeof(D3DVALUE));
|
1716 | | - texstages[dwStage].dirty = true;
|
1717 | | - TRACE_EXIT(23,D3D_OK);
|
1718 | | - return D3D_OK;
|
| 1621 | + break;
|
1719 | 1622 | case D3DTSS_BUMPENVLOFFSET:
|
1720 | 1623 | memcpy(&texstages[dwStage].bumpenvloffset,&dwValue,sizeof(D3DVALUE));
|
1721 | | - texstages[dwStage].dirty = true;
|
1722 | | - TRACE_EXIT(23,D3D_OK);
|
1723 | | - return D3D_OK;
|
| 1624 | + break;
|
1724 | 1625 | case D3DTSS_TEXTURETRANSFORMFLAGS:
|
1725 | 1626 | if((dwValue & 0xFF) > 4) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1726 | 1627 | if((dwValue >> 8) > 1) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1727 | 1628 | texstages[dwStage].textransform = (D3DTEXTURETRANSFORMFLAGS)dwValue;
|
1728 | | - texstages[dwStage].dirty = true;
|
1729 | | - TRACE_EXIT(23,D3D_OK);
|
1730 | | - return D3D_OK;
|
| 1629 | + break;
|
1731 | 1630 | default:
|
1732 | 1631 | TRACE_EXIT(23,DDERR_INVALIDPARAMS);
|
1733 | 1632 | return DDERR_INVALIDPARAMS;
|
1734 | 1633 | }
|
1735 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1736 | | - ERR(DDERR_GENERIC);
|
| 1634 | + if (devstate) glRenderer_SetTextureStageState(renderer, dwStage, dwState, dwValue);
|
| 1635 | + TRACE_EXIT(23, D3D_OK);
|
| 1636 | + return D3D_OK;
|
1737 | 1637 | }
|
1738 | 1638 | HRESULT WINAPI glDirect3DDevice7::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
1739 | 1639 | {
|
— | — | @@ -1744,25 +1644,23 @@ |
1745 | 1645 | memcpy(&matWorld,lpD3DMatrix,sizeof(D3DMATRIX));
|
1746 | 1646 | modelview_dirty = true;
|
1747 | 1647 | transform_dirty = true;
|
1748 | | - TRACE_EXIT(23,D3D_OK);
|
1749 | | - return D3D_OK;
|
| 1648 | + break;
|
1750 | 1649 | case D3DTRANSFORMSTATE_VIEW:
|
1751 | 1650 | memcpy(&matView,lpD3DMatrix,sizeof(D3DMATRIX));
|
1752 | 1651 | modelview_dirty = true;
|
1753 | 1652 | transform_dirty = true;
|
1754 | | - TRACE_EXIT(23,D3D_OK);
|
1755 | | - return D3D_OK;
|
| 1653 | + break;
|
1756 | 1654 | case D3DTRANSFORMSTATE_PROJECTION:
|
1757 | 1655 | memcpy(&matProjection,lpD3DMatrix,sizeof(D3DMATRIX));
|
1758 | 1656 | projection_dirty = true;
|
1759 | 1657 | transform_dirty = true;
|
1760 | | - TRACE_EXIT(23,D3D_OK);
|
1761 | | - return D3D_OK;
|
| 1658 | + break;
|
1762 | 1659 | default:
|
1763 | 1660 | TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1764 | 1661 | }
|
1765 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
1766 | | - return DDERR_GENERIC;
|
| 1662 | + glRenderer_SetTransform(renderer, dtstTransformStateType, lpD3DMatrix);
|
| 1663 | + TRACE_EXIT(23, D3D_OK);
|
| 1664 | + return D3D_OK;
|
1767 | 1665 | }
|
1768 | 1666 | HRESULT WINAPI glDirect3DDevice7::SetViewport(LPD3DVIEWPORT7 lpViewport)
|
1769 | 1667 | {
|
— | — | @@ -1770,6 +1668,7 @@ |
1771 | 1669 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1772 | 1670 | memcpy(&viewport,lpViewport,sizeof(D3DVIEWPORT7));
|
1773 | 1671 | transform_dirty = true;
|
| 1672 | + glRenderer_SetViewport(renderer, lpViewport);
|
1774 | 1673 | TRACE_EXIT(23,D3D_OK);
|
1775 | 1674 | return D3D_OK;
|
1776 | 1675 | }
|
— | — | @@ -1831,39 +1730,6 @@ |
1832 | 1731 | return D3D_OK;
|
1833 | 1732 | }
|
1834 | 1733 |
|
1835 | | -void glDirect3DDevice7::SetDepthComp(glUtil *util)
|
1836 | | -{
|
1837 | | - TRACE_ENTER(1,14,this,14,util);
|
1838 | | - switch(renderstate[D3DRENDERSTATE_ZFUNC])
|
1839 | | - {
|
1840 | | - case D3DCMP_NEVER:
|
1841 | | - util->SetDepthComp(GL_NEVER);
|
1842 | | - break;
|
1843 | | - case D3DCMP_LESS:
|
1844 | | - util->SetDepthComp(GL_LESS);
|
1845 | | - break;
|
1846 | | - case D3DCMP_EQUAL:
|
1847 | | - util->SetDepthComp(GL_EQUAL);
|
1848 | | - break;
|
1849 | | - case D3DCMP_LESSEQUAL:
|
1850 | | - util->SetDepthComp(GL_LEQUAL);
|
1851 | | - break;
|
1852 | | - case D3DCMP_GREATER:
|
1853 | | - util->SetDepthComp(GL_GREATER);
|
1854 | | - break;
|
1855 | | - case D3DCMP_NOTEQUAL:
|
1856 | | - util->SetDepthComp(GL_NOTEQUAL);
|
1857 | | - break;
|
1858 | | - case D3DCMP_GREATEREQUAL:
|
1859 | | - util->SetDepthComp(GL_GEQUAL);
|
1860 | | - break;
|
1861 | | - case D3DCMP_ALWAYS:
|
1862 | | - default:
|
1863 | | - util->SetDepthComp(GL_ALWAYS);
|
1864 | | - break;
|
1865 | | - }
|
1866 | | - TRACE_EXIT(0,0);
|
1867 | | -}
|
1868 | 1734 |
|
1869 | 1735 | D3DMATERIALHANDLE glDirect3DDevice7::AddMaterial(glDirect3DMaterial3 *material)
|
1870 | 1736 | {
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -22,38 +22,6 @@ |
23 | 23 | class glDirectDrawSurface7;
|
24 | 24 | class glDirect3D7;
|
25 | 25 |
|
26 | | -struct TEXTURESTAGE
|
27 | | -{
|
28 | | - D3DTEXTUREOP colorop;
|
29 | | - DWORD colorarg1;
|
30 | | - DWORD colorarg2;
|
31 | | - D3DTEXTUREOP alphaop;
|
32 | | - DWORD alphaarg1;
|
33 | | - DWORD alphaarg2;
|
34 | | - D3DVALUE bumpenv00;
|
35 | | - D3DVALUE bumpenv01;
|
36 | | - D3DVALUE bumpenv10;
|
37 | | - D3DVALUE bumpenv11;
|
38 | | - DWORD texcoordindex;
|
39 | | - D3DTEXTUREADDRESS addressu;
|
40 | | - D3DTEXTUREADDRESS addressv;
|
41 | | - DWORD bordercolor;
|
42 | | - D3DTEXTUREMAGFILTER magfilter;
|
43 | | - D3DTEXTUREMINFILTER minfilter;
|
44 | | - D3DTEXTUREMIPFILTER mipfilter;
|
45 | | - D3DVALUE lodbias;
|
46 | | - DWORD miplevel;
|
47 | | - DWORD anisotropy;
|
48 | | - D3DVALUE bumpenvlscale;
|
49 | | - D3DVALUE bumpenvloffset;
|
50 | | - D3DTEXTURETRANSFORMFLAGS textransform;
|
51 | | - glDirectDrawSurface7 *texture;
|
52 | | - bool dirty;
|
53 | | - __int64 shaderid;
|
54 | | - GLint glmagfilter;
|
55 | | - GLint glminfilter;
|
56 | | -};
|
57 | | -
|
58 | 26 | struct D3D1MATRIX
|
59 | 27 | {
|
60 | 28 | BOOL active;
|
— | — | @@ -133,7 +101,6 @@ |
134 | 102 | HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
|
135 | 103 | HRESULT err() {return error;}
|
136 | 104 | void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
|
137 | | - void SetDepthComp(glUtil *util);
|
138 | 105 | D3DMATERIALHANDLE AddMaterial(glDirect3DMaterial3* material);
|
139 | 106 | D3DTEXTUREHANDLE AddTexture(glDirectDrawSurface7* texture);
|
140 | 107 | HRESULT AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
|
— | — | @@ -169,7 +136,7 @@ |
170 | 137 | void UpdateTransform();
|
171 | 138 | void InitDX2();
|
172 | 139 | void InitDX5();
|
173 | | - __int64 SelectShader(GLVERTEX *VertexType);
|
| 140 | + //__int64 SelectShader(GLVERTEX *VertexType);
|
174 | 141 | void SetScale(D3DVALUE x, D3DVALUE y){scalex = x; scaley = y;}
|
175 | 142 | ULONG AddRefInternal();
|
176 | 143 | ULONG ReleaseInternal();
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -502,9 +502,12 @@ |
503 | 503 | * @param zbuffer
|
504 | 504 | * Nonzero if a Z buffer is present.
|
505 | 505 | */
|
506 | | -void glRenderer_InitD3D(glRenderer *This, int zbuffer)
|
| 506 | +void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y)
|
507 | 507 | {
|
508 | 508 | EnterCriticalSection(&This->cs);
|
| 509 | + This->inputs[0] = (void*)zbuffer;
|
| 510 | + This->inputs[1] = (void*)x;
|
| 511 | + This->inputs[2] = (void*)y;
|
509 | 512 | This->opcode = OP_INITD3D;
|
510 | 513 | SetEvent(This->start);
|
511 | 514 | WaitForSingleObject(This->busy,INFINITE);
|
— | — | @@ -713,8 +716,148 @@ |
714 | 717 | return (HRESULT)This->outputs[0];
|
715 | 718 | }
|
716 | 719 |
|
| 720 | +/**
|
| 721 | +* Sets a render state within the renderer.
|
| 722 | +* @param This
|
| 723 | +* Pointer to glRenderer object
|
| 724 | +* @param dwRendStateType
|
| 725 | +* Render state to change
|
| 726 | +* @param dwRenderState
|
| 727 | +* New render state value
|
| 728 | +*/
|
| 729 | +void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
| 730 | +{
|
| 731 | + EnterCriticalSection(&This->cs);
|
| 732 | + This->inputs[0] = (void*)dwRendStateType;
|
| 733 | + This->inputs[1] = (void*)dwRenderState;
|
| 734 | + This->opcode = OP_SETRENDERSTATE;
|
| 735 | + SetEvent(This->start);
|
| 736 | + WaitForSingleObject(This->busy, INFINITE);
|
| 737 | + LeaveCriticalSection(&This->cs);
|
| 738 | +}
|
717 | 739 |
|
718 | 740 | /**
|
| 741 | +* Binds a surface to a texture stage in the renderer.
|
| 742 | +* @param This
|
| 743 | +* Pointer to glRenderer object
|
| 744 | +* @param dwStage
|
| 745 | +* Texture stage to bind
|
| 746 | +* @param Texture
|
| 747 | +* Texture to bind to the stage; old texture will be released; NULL to unbind
|
| 748 | +*/
|
| 749 | +void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
|
| 750 | +{
|
| 751 | + EnterCriticalSection(&This->cs);
|
| 752 | + This->inputs[0] = (void*)dwStage;
|
| 753 | + This->inputs[1] = Texture;
|
| 754 | + This->opcode = OP_SETTEXTURE;
|
| 755 | + SetEvent(This->start);
|
| 756 | + WaitForSingleObject(This->busy, INFINITE);
|
| 757 | + LeaveCriticalSection(&This->cs);
|
| 758 | +}
|
| 759 | +
|
| 760 | +/**
|
| 761 | +* Sets a texture stage state within the renderer.
|
| 762 | +* @param This
|
| 763 | +* Pointer to glRenderer object
|
| 764 | +* @param dwStage
|
| 765 | +* Texture stage to modify
|
| 766 | +* @param dwState
|
| 767 | +* Texture stage state to modify
|
| 768 | +* @param dwValue
|
| 769 | +* New value for texture stage state.
|
| 770 | +*/
|
| 771 | +void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
| 772 | +{
|
| 773 | + EnterCriticalSection(&This->cs);
|
| 774 | + This->inputs[0] = (void*)dwStage;
|
| 775 | + This->inputs[1] = (void*)dwState;
|
| 776 | + This->inputs[2] = (void*)dwValue;
|
| 777 | + This->opcode = OP_SETTEXTURESTAGESTATE;
|
| 778 | + SetEvent(This->start);
|
| 779 | + WaitForSingleObject(This->busy, INFINITE);
|
| 780 | + LeaveCriticalSection(&This->cs);
|
| 781 | +}
|
| 782 | +
|
| 783 | +/**
|
| 784 | +* Sets a transform matrix in the renderer.
|
| 785 | +* @param This
|
| 786 | +* Pointer to glRenderer object
|
| 787 | +* @param dtstTransformStateType
|
| 788 | +* Transform matrix to replace
|
| 789 | +* @param lpD3DMatrix
|
| 790 | +* New transform matrix
|
| 791 | +*/
|
| 792 | +void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 793 | +{
|
| 794 | + EnterCriticalSection(&This->cs);
|
| 795 | + This->inputs[0] = (void*)dtstTransformStateType;
|
| 796 | + This->inputs[1] = lpD3DMatrix;
|
| 797 | + This->opcode = OP_SETTRANSFORM;
|
| 798 | + SetEvent(This->start);
|
| 799 | + WaitForSingleObject(This->busy, INFINITE);
|
| 800 | + LeaveCriticalSection(&This->cs);
|
| 801 | +}
|
| 802 | +
|
| 803 | +/**
|
| 804 | +* Sets the material in the renderer.
|
| 805 | +* @param This
|
| 806 | +* Pointer to glRenderer object
|
| 807 | +* @param lpMaterial
|
| 808 | +* New material parameters
|
| 809 | +*/
|
| 810 | +void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
|
| 811 | +{
|
| 812 | + EnterCriticalSection(&This->cs);
|
| 813 | + This->inputs[0] = lpMaterial;
|
| 814 | + This->opcode = OP_SETMATERIAL;
|
| 815 | + SetEvent(This->start);
|
| 816 | + WaitForSingleObject(This->busy, INFINITE);
|
| 817 | + LeaveCriticalSection(&This->cs);
|
| 818 | +}
|
| 819 | +
|
| 820 | +/**
|
| 821 | +* Sets a light in the renderer.
|
| 822 | +* @param This
|
| 823 | +* Pointer to glRenderer object
|
| 824 | +* @param index
|
| 825 | +* Index of light to set
|
| 826 | +* @param light
|
| 827 | +* Pointer to light to change, ignored if remove is TRUE
|
| 828 | +* @param remove
|
| 829 | +* TRUE to clear a light from the renderer.
|
| 830 | +*/
|
| 831 | +
|
| 832 | +void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
| 833 | +{
|
| 834 | + EnterCriticalSection(&This->cs);
|
| 835 | + This->inputs[0] = (void*)index;
|
| 836 | + This->inputs[1] = light;
|
| 837 | + This->inputs[2] = (void*)remove;
|
| 838 | + This->opcode = OP_SETLIGHT;
|
| 839 | + SetEvent(This->start);
|
| 840 | + WaitForSingleObject(This->busy, INFINITE);
|
| 841 | + LeaveCriticalSection(&This->cs);
|
| 842 | +}
|
| 843 | +
|
| 844 | +/**
|
| 845 | +* Sets the viewport for the renderer.
|
| 846 | +* @param This
|
| 847 | +* Pointer to glRenderer object
|
| 848 | +* @param lpViewport
|
| 849 | +* New viewport parameters for renderer.
|
| 850 | +*/
|
| 851 | +void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
| 852 | +{
|
| 853 | + EnterCriticalSection(&This->cs);
|
| 854 | + This->inputs[0] = lpViewport;
|
| 855 | + This->opcode = OP_SETVIEWPORT;
|
| 856 | + SetEvent(This->start);
|
| 857 | + WaitForSingleObject(This->busy, INFINITE);
|
| 858 | + LeaveCriticalSection(&This->cs);
|
| 859 | +}
|
| 860 | +
|
| 861 | +/**
|
719 | 862 | * Main loop for glRenderer class
|
720 | 863 | * @param This
|
721 | 864 | * Pointer to glRenderer object
|
— | — | @@ -809,7 +952,7 @@ |
810 | 953 | (glDirectDrawSurface7*)This->inputs[2],(glDirectDrawSurface7*)This->inputs[3],(GLint)This->inputs[4],true);
|
811 | 954 | break;
|
812 | 955 | case OP_INITD3D:
|
813 | | - glRenderer__InitD3D(This,(int)This->inputs[0]);
|
| 956 | + glRenderer__InitD3D(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2]);
|
814 | 957 | break;
|
815 | 958 | case OP_CLEAR:
|
816 | 959 | memcpy(&tmpfloats[0],&This->inputs[5],4);
|
— | — | @@ -834,6 +977,28 @@ |
835 | 978 | glRenderer__DepthFill(This, (LPRECT)This->inputs[0], (glDirectDrawSurface7*)This->inputs[1],
|
836 | 979 | (LPDDBLTFX)This->inputs[2]);
|
837 | 980 | break;
|
| 981 | + case OP_SETRENDERSTATE:
|
| 982 | + glRenderer__SetRenderState(This, (D3DRENDERSTATETYPE)(DWORD)This->inputs[0], (DWORD)This->inputs[1]);
|
| 983 | + break;
|
| 984 | + case OP_SETTEXTURE:
|
| 985 | + glRenderer__SetTexture(This, (DWORD)This->inputs[0], (glDirectDrawSurface7*)This->inputs[1]);
|
| 986 | + break;
|
| 987 | + case OP_SETTEXTURESTAGESTATE:
|
| 988 | + glRenderer__SetTextureStageState(This, (DWORD)This->inputs[0], (D3DTEXTURESTAGESTATETYPE)(DWORD)This->inputs[1],
|
| 989 | + (DWORD)This->inputs[2]);
|
| 990 | + break;
|
| 991 | + case OP_SETTRANSFORM:
|
| 992 | + glRenderer__SetTransform(This, (D3DTRANSFORMSTATETYPE)(DWORD)This->inputs[0], (LPD3DMATRIX)This->inputs[1]);
|
| 993 | + break;
|
| 994 | + case OP_SETMATERIAL:
|
| 995 | + glRenderer__SetMaterial(This, (LPD3DMATERIAL7)This->inputs[0]);
|
| 996 | + break;
|
| 997 | + case OP_SETLIGHT:
|
| 998 | + glRenderer__SetLight(This, (DWORD)This->inputs[0], (LPD3DLIGHT7)This->inputs[1], (BOOL)This->inputs[2]);
|
| 999 | + break;
|
| 1000 | + case OP_SETVIEWPORT:
|
| 1001 | + glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
|
| 1002 | + break;
|
838 | 1003 | }
|
839 | 1004 | }
|
840 | 1005 | return 0;
|
— | — | @@ -1632,8 +1797,102 @@ |
1633 | 1798 | SetEvent(This->busy);
|
1634 | 1799 | }
|
1635 | 1800 |
|
1636 | | -void glRenderer__InitD3D(glRenderer *This, int zbuffer)
|
| 1801 | +__int64 InitShaderState(glRenderer *renderer, DWORD *renderstate, TEXTURESTAGE *texstages, D3DLIGHT7 *lights)
|
1637 | 1802 | {
|
| 1803 | + int i;
|
| 1804 | + __int64 shader = 0;
|
| 1805 | + switch (renderstate[D3DRENDERSTATE_SHADEMODE])
|
| 1806 | + {
|
| 1807 | + case D3DSHADE_FLAT:
|
| 1808 | + default:
|
| 1809 | + break;
|
| 1810 | + case D3DSHADE_GOURAUD:
|
| 1811 | + shader |= 1;
|
| 1812 | + break;
|
| 1813 | + case D3DSHADE_PHONG:
|
| 1814 | + shader |= 3;
|
| 1815 | + break;
|
| 1816 | + }
|
| 1817 | + if (renderstate[D3DRENDERSTATE_ALPHATESTENABLE]) shader |= 4;
|
| 1818 | + shader |= ((((__int64)renderstate[D3DRENDERSTATE_ALPHAFUNC] - 1) & 7) << 3);
|
| 1819 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_FOGTABLEMODE] & 3) << 6);
|
| 1820 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_FOGVERTEXMODE] & 3) << 8);
|
| 1821 | + if (renderstate[D3DRENDERSTATE_RANGEFOGENABLE]) shader |= (1i64 << 10);
|
| 1822 | + if (renderstate[D3DRENDERSTATE_SPECULARENABLE]) shader |= (1i64 << 11);
|
| 1823 | + if (renderstate[D3DRENDERSTATE_STIPPLEDALPHA]) shader |= (1i64 << 12);
|
| 1824 | + if (renderstate[D3DRENDERSTATE_COLORKEYENABLE]) shader |= (1i64 << 13);
|
| 1825 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_ZBIAS] & 15) << 14);
|
| 1826 | + int numlights = 0;
|
| 1827 | + for (i = 0; i < 8; i++)
|
| 1828 | + if (lights[i].dltType) numlights++;
|
| 1829 | + shader |= (__int64)numlights << 18;
|
| 1830 | + if (renderstate[D3DRENDERSTATE_LOCALVIEWER]) shader |= (1i64 << 21);
|
| 1831 | + if (renderstate[D3DRENDERSTATE_COLORKEYBLENDENABLE]) shader |= (1i64 << 22);
|
| 1832 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE] & 3) << 23);
|
| 1833 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_SPECULARMATERIALSOURCE] & 3) << 25);
|
| 1834 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_AMBIENTMATERIALSOURCE] & 3) << 27);
|
| 1835 | + shader |= (((__int64)renderstate[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE] & 3) << 29);
|
| 1836 | + int lightindex = 0;
|
| 1837 | + for (i = 0; i < 8; i++)
|
| 1838 | + {
|
| 1839 | + if (lights[i].dltType)
|
| 1840 | + {
|
| 1841 | + if (lights[i].dltType != D3DLIGHT_DIRECTIONAL)
|
| 1842 | + shader |= (1i64 << (38 + lightindex));
|
| 1843 | + if (lights[i].dltType == D3DLIGHT_SPOT)
|
| 1844 | + shader |= (1i64 << (51 + lightindex));
|
| 1845 | + lightindex++;
|
| 1846 | + }
|
| 1847 | + }
|
| 1848 | + if (renderstate[D3DRENDERSTATE_NORMALIZENORMALS]) shader |= (1i64 << 49);
|
| 1849 | + if (renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] == D3DTBLEND_MODULATE)
|
| 1850 | + {
|
| 1851 | + bool noalpha = false;;
|
| 1852 | + if (!texstages[0].texture) noalpha = true;
|
| 1853 | + if (texstages[0].texture)
|
| 1854 | + if (!(texstages[0].texture->ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS))
|
| 1855 | + noalpha = true;
|
| 1856 | + if (noalpha) texstages[0].alphaop = D3DTOP_SELECTARG2;
|
| 1857 | + else texstages[0].alphaop = D3DTOP_MODULATE;
|
| 1858 | + }
|
| 1859 | + if (renderstate[D3DRENDERSTATE_LIGHTING]) shader |= (1i64 << 59);
|
| 1860 | + if (renderstate[D3DRENDERSTATE_COLORVERTEX]) shader |= (1i64 << 60);
|
| 1861 | + if (renderstate[D3DRENDERSTATE_FOGENABLE]) shader |= (1i64 << 61);
|
| 1862 | + if (renderstate[D3DRENDERSTATE_DITHERENABLE]) shader |= (1i64 << 62);
|
| 1863 | + for (i = 0; i < 8; i++)
|
| 1864 | + {
|
| 1865 | + renderer->shaderstate3d.texstageid[i] = texstages[i].colorop & 31;
|
| 1866 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].colorarg1 & 63) << 5;
|
| 1867 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].colorarg2 & 63) << 11;
|
| 1868 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].alphaop & 31) << 17;
|
| 1869 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].alphaarg1 & 63) << 22;
|
| 1870 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].alphaarg2 & 63) << 28;
|
| 1871 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].texcoordindex & 7) << 34;
|
| 1872 | + renderer->shaderstate3d.texstageid[i] |= (__int64)((texstages[i].texcoordindex >> 16) & 3) << 37;
|
| 1873 | + renderer->shaderstate3d.texstageid[i] |= (__int64)((texstages[i].addressu - 1) & 3) << 39;
|
| 1874 | + renderer->shaderstate3d.texstageid[i] |= (__int64)((texstages[i].addressv - 1) & 3) << 41;
|
| 1875 | + //renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].magfilter & 7) << 43;
|
| 1876 | + //renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].minfilter & 3) << 46;
|
| 1877 | + //renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].mipfilter & 3) << 48;
|
| 1878 | + if (texstages[i].textransform & 7)
|
| 1879 | + {
|
| 1880 | + renderer->shaderstate3d.texstageid[i] |= 1i64 << 50;
|
| 1881 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(((texstages[i].textransform & 7) - 1) & 3) << 51;
|
| 1882 | + }
|
| 1883 | + if (texstages[i].textransform & D3DTTFF_PROJECTED) renderer->shaderstate3d.texstageid[i] |= 1i64 << 53;
|
| 1884 | + renderer->shaderstate3d.texstageid[i] |= (__int64)(texstages[i].texcoordindex & 7) << 54;
|
| 1885 | + renderer->shaderstate3d.texstageid[i] |= (__int64)((texstages[i].texcoordindex >> 16) & 3) << 57;
|
| 1886 | + if (texstages[i].texture)
|
| 1887 | + {
|
| 1888 | + renderer->shaderstate3d.texstageid[i] |= 1i64 << 59;
|
| 1889 | + if (texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT) renderer->shaderstate3d.texstageid[i] |= 1i64 << 60;
|
| 1890 | + }
|
| 1891 | + }
|
| 1892 | + return shader;
|
| 1893 | +}
|
| 1894 | +
|
| 1895 | +void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y)
|
| 1896 | +{
|
1638 | 1897 | SetEvent(This->busy);
|
1639 | 1898 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
1640 | 1899 | GLfloat ambient[] = {0.0,0.0,0.0,0.0};
|
— | — | @@ -1643,9 +1902,24 @@ |
1644 | 1903 | __gluMakeIdentityf(identity);
|
1645 | 1904 | This->util->SetMatrix(GL_MODELVIEW,identity,identity,NULL);
|
1646 | 1905 | This->util->SetMatrix(GL_PROJECTION,identity,NULL,NULL);
|
| 1906 | + for (int i = 0; i < 24; i++)
|
| 1907 | + memcpy(&This->transform[i], identity, sizeof(D3DMATRIX));
|
1647 | 1908 | GLfloat one[4] = {1,1,1,1};
|
1648 | 1909 | GLfloat zero[4] = {0,0,0,1};
|
1649 | 1910 | This->util->SetMaterial(one,one,zero,zero,0);
|
| 1911 | + ZeroMemory(&This->material, sizeof(D3DMATERIAL7));
|
| 1912 | + ZeroMemory(&This->lights, 8 * sizeof(D3DLIGHT7));
|
| 1913 | + memcpy(&This->renderstate, &renderstate_default, 153 * sizeof(DWORD));
|
| 1914 | + This->texstages[0] = texstagedefault0;
|
| 1915 | + This->texstages[1] = This->texstages[2] = This->texstages[3] = This->texstages[4] =
|
| 1916 | + This->texstages[5] = This->texstages[6] = This->texstages[7] = texstagedefault1;
|
| 1917 | + This->viewport.dwX = 0;
|
| 1918 | + This->viewport.dwY = 0;
|
| 1919 | + This->viewport.dwWidth = x;
|
| 1920 | + This->viewport.dwHeight = y;
|
| 1921 | + This->viewport.dvMinZ = 0.0f;
|
| 1922 | + This->viewport.dvMaxZ = 1.0f;
|
| 1923 | + This->shaderstate3d.stateid = InitShaderState(This, This->renderstate, This->texstages, This->lights);
|
1650 | 1924 | }
|
1651 | 1925 |
|
1652 | 1926 | void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
— | — | @@ -1861,22 +2135,34 @@ |
1862 | 2136 | SetEvent(This->busy);
|
1863 | 2137 | return;
|
1864 | 2138 | }
|
1865 | | - __int64 shader = device->SelectShader(vertices);
|
1866 | | - ShaderManager_SetShader(This->shaders,shader,device->texstages,texformats,2);
|
1867 | | - device->SetDepthComp(This->util);
|
1868 | | - if(device->renderstate[D3DRENDERSTATE_ZENABLE]) This->util->DepthTest(true);
|
| 2139 | + This->shaderstate3d.stateid &= 0xFFFA3FFC7FFFFFFFi64;
|
| 2140 | + int numtextures = 0;
|
| 2141 | + for (i = 0; i < 8; i++)
|
| 2142 | + if (vertices[i + 10].data) numtextures++;
|
| 2143 | + This->shaderstate3d.stateid |= (__int64)numtextures << 31;
|
| 2144 | + int blendweights = 0;
|
| 2145 | + for (i = 0; i < 5; i++)
|
| 2146 | + if (vertices[i + 2].data) blendweights++;
|
| 2147 | + This->shaderstate3d.stateid |= (__int64)blendweights << 46;
|
| 2148 | + if (vertices[1].data) This->shaderstate3d.stateid |= (1i64 << 50);
|
| 2149 | + if (vertices[8].data) This->shaderstate3d.stateid |= (1i64 << 35);
|
| 2150 | + if (vertices[9].data) This->shaderstate3d.stateid |= (1i64 << 36);
|
| 2151 | + if (vertices[7].data) This->shaderstate3d.stateid |= (1i64 << 37);
|
| 2152 | + ShaderManager_SetShader(This->shaders,This->shaderstate3d.stateid,This->shaderstate3d.texstageid,texformats,2);
|
| 2153 | + glRenderer__SetDepthComp(This);
|
| 2154 | + if(This->renderstate[D3DRENDERSTATE_ZENABLE]) This->util->DepthTest(true);
|
1869 | 2155 | else This->util->DepthTest(false);
|
1870 | | - if(device->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) This->util->DepthWrite(true);
|
| 2156 | + if(This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) This->util->DepthWrite(true);
|
1871 | 2157 | else This->util->DepthWrite(false);
|
1872 | | - _GENSHADER prog = This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
|
1873 | | - This->util->EnableArray(prog.attribs[0],true);
|
1874 | | - This->ext->glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
| 2158 | + _GENSHADER *prog = &This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
|
| 2159 | + This->util->EnableArray(prog->attribs[0],true);
|
| 2160 | + This->ext->glVertexAttribPointer(prog->attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
1875 | 2161 | if(transformed)
|
1876 | 2162 | {
|
1877 | | - if(prog.attribs[1] != -1)
|
| 2163 | + if(prog->attribs[1] != -1)
|
1878 | 2164 | {
|
1879 | | - This->util->EnableArray(prog.attribs[1],true);
|
1880 | | - This->ext->glVertexAttribPointer(prog.attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
| 2165 | + This->util->EnableArray(prog->attribs[1],true);
|
| 2166 | + This->ext->glVertexAttribPointer(prog->attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
1881 | 2167 | }
|
1882 | 2168 | }
|
1883 | 2169 | for(i = 0; i < 5; i++)
|
— | — | @@ -1883,19 +2169,19 @@ |
1884 | 2170 | {
|
1885 | 2171 | if(vertices[i+2].data)
|
1886 | 2172 | {
|
1887 | | - if(prog.attribs[i+2] != -1)
|
| 2173 | + if(prog->attribs[i+2] != -1)
|
1888 | 2174 | {
|
1889 | | - This->util->EnableArray(prog.attribs[i+2],true);
|
1890 | | - This->ext->glVertexAttribPointer(prog.attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
| 2175 | + This->util->EnableArray(prog->attribs[i+2],true);
|
| 2176 | + This->ext->glVertexAttribPointer(prog->attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
1891 | 2177 | }
|
1892 | 2178 | }
|
1893 | 2179 | }
|
1894 | 2180 | if(vertices[7].data)
|
1895 | 2181 | {
|
1896 | | - if(prog.attribs[7] != -1)
|
| 2182 | + if(prog->attribs[7] != -1)
|
1897 | 2183 | {
|
1898 | | - This->util->EnableArray(prog.attribs[7],true);
|
1899 | | - This->ext->glVertexAttribPointer(prog.attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
| 2184 | + This->util->EnableArray(prog->attribs[7],true);
|
| 2185 | + This->ext->glVertexAttribPointer(prog->attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
1900 | 2186 | }
|
1901 | 2187 | }
|
1902 | 2188 | for(i = 0; i < 2; i++)
|
— | — | @@ -1902,10 +2188,10 @@ |
1903 | 2189 | {
|
1904 | 2190 | if(vertices[i+8].data)
|
1905 | 2191 | {
|
1906 | | - if(prog.attribs[8+i] != -1)
|
| 2192 | + if(prog->attribs[8+i] != -1)
|
1907 | 2193 | {
|
1908 | | - This->util->EnableArray(prog.attribs[8+i],true);
|
1909 | | - This->ext->glVertexAttribPointer(prog.attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
| 2194 | + This->util->EnableArray(prog->attribs[8+i],true);
|
| 2195 | + This->ext->glVertexAttribPointer(prog->attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
1910 | 2196 | }
|
1911 | 2197 | }
|
1912 | 2198 | }
|
— | — | @@ -1917,31 +2203,31 @@ |
1918 | 2204 | case -1: // Null
|
1919 | 2205 | break;
|
1920 | 2206 | case 0: // st
|
1921 | | - if(prog.attribs[i+18] != -1)
|
| 2207 | + if(prog->attribs[i+18] != -1)
|
1922 | 2208 | {
|
1923 | | - This->util->EnableArray(prog.attribs[i+18],true);
|
1924 | | - This->ext->glVertexAttribPointer(prog.attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2209 | + This->util->EnableArray(prog->attribs[i+18],true);
|
| 2210 | + This->ext->glVertexAttribPointer(prog->attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
1925 | 2211 | }
|
1926 | 2212 | break;
|
1927 | 2213 | case 1: // str
|
1928 | | - if(prog.attribs[i+26] != -1)
|
| 2214 | + if(prog->attribs[i+26] != -1)
|
1929 | 2215 | {
|
1930 | | - This->util->EnableArray(prog.attribs[i+26],true);
|
1931 | | - This->ext->glVertexAttribPointer(prog.attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2216 | + This->util->EnableArray(prog->attribs[i+26],true);
|
| 2217 | + This->ext->glVertexAttribPointer(prog->attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
1932 | 2218 | }
|
1933 | 2219 | break;
|
1934 | 2220 | case 2: // strq
|
1935 | | - if(prog.attribs[i+34] != -1)
|
| 2221 | + if(prog->attribs[i+34] != -1)
|
1936 | 2222 | {
|
1937 | | - This->util->EnableArray(prog.attribs[i+34],true);
|
1938 | | - This->ext->glVertexAttribPointer(prog.attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2223 | + This->util->EnableArray(prog->attribs[i+34],true);
|
| 2224 | + This->ext->glVertexAttribPointer(prog->attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
1939 | 2225 | }
|
1940 | 2226 | break;
|
1941 | 2227 | case 3: // s
|
1942 | | - if(prog.attribs[i+10] != -1)
|
| 2228 | + if(prog->attribs[i+10] != -1)
|
1943 | 2229 | {
|
1944 | | - This->util->EnableArray(prog.attribs[i+10],true);
|
1945 | | - This->ext->glVertexAttribPointer(prog.attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2230 | + This->util->EnableArray(prog->attribs[i+10],true);
|
| 2231 | + This->ext->glVertexAttribPointer(prog->attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
1946 | 2232 | }
|
1947 | 2233 | break;
|
1948 | 2234 | }
|
— | — | @@ -1948,98 +2234,100 @@ |
1949 | 2235 |
|
1950 | 2236 | }
|
1951 | 2237 | }
|
1952 | | - if (device->modelview_dirty) This->util->SetMatrix(GL_MODELVIEW, device->matView, device->matWorld, &device->modelview_dirty);
|
1953 | | - if (device->projection_dirty) This->util->SetMatrix(GL_PROJECTION, device->matProjection, NULL, &device->projection_dirty);
|
| 2238 | + This->util->SetMatrix(GL_MODELVIEW, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_VIEW],
|
| 2239 | + (GLfloat*)&This->transform[D3DTRANSFORMSTATE_WORLD],NULL);
|
| 2240 | + This->util->SetMatrix(GL_PROJECTION, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_PROJECTION], NULL, NULL);
|
1954 | 2241 |
|
1955 | | - This->util->SetMaterial((GLfloat*)&device->material.ambient,(GLfloat*)&device->material.diffuse,(GLfloat*)&device->material.specular,
|
1956 | | - (GLfloat*)&device->material.emissive,device->material.power);
|
| 2242 | + This->util->SetMaterial((GLfloat*)&This->material.ambient,(GLfloat*)&This->material.diffuse,(GLfloat*)&This->material.specular,
|
| 2243 | + (GLfloat*)&This->material.emissive,This->material.power);
|
1957 | 2244 |
|
1958 | 2245 | int lightindex = 0;
|
1959 | 2246 | char lightname[] = "lightX.xxxxxxxxxxxxxxxx";
|
1960 | 2247 | for(i = 0; i < 8; i++)
|
1961 | 2248 | {
|
1962 | | - if(device->gllights[i] != -1)
|
| 2249 | + if(This->lights[i].dltType)
|
1963 | 2250 | {
|
1964 | | - if(prog.uniforms[0] != -1) This->ext->glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
|
1965 | | - if(prog.uniforms[20+(i*12)] != -1)
|
1966 | | - This->ext->glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
|
1967 | | - if(prog.uniforms[21+(i*12)] != -1)
|
1968 | | - This->ext->glUniform4fv(prog.uniforms[21+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
|
1969 | | - if(prog.uniforms[22+(i*12)] != -1)
|
1970 | | - This->ext->glUniform4fv(prog.uniforms[22+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
|
1971 | | - if(prog.uniforms[24+(i*12)] != -1)
|
1972 | | - This->ext->glUniform3fv(prog.uniforms[24+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
|
1973 | | - if(device->lights[device->gllights[i]]->light.dltType != D3DLIGHT_DIRECTIONAL)
|
| 2251 | + if(prog->uniforms[0] != -1) This->ext->glUniformMatrix4fv(prog->uniforms[0],1,false,
|
| 2252 | + (GLfloat*)&This->transform[D3DTRANSFORMSTATE_WORLD]);
|
| 2253 | + if(prog->uniforms[20+(i*12)] != -1)
|
| 2254 | + This->ext->glUniform4fv(prog->uniforms[20+(i*12)],1,(GLfloat*)&This->lights[i].dcvDiffuse);
|
| 2255 | + if(prog->uniforms[21+(i*12)] != -1)
|
| 2256 | + This->ext->glUniform4fv(prog->uniforms[21+(i*12)],1,(GLfloat*)&This->lights[i].dcvSpecular);
|
| 2257 | + if(prog->uniforms[22+(i*12)] != -1)
|
| 2258 | + This->ext->glUniform4fv(prog->uniforms[22+(i*12)],1,(GLfloat*)&This->lights[i].dcvAmbient);
|
| 2259 | + if(prog->uniforms[24+(i*12)] != -1)
|
| 2260 | + This->ext->glUniform3fv(prog->uniforms[24+(i*12)],1,(GLfloat*)&This->lights[i].dvDirection);
|
| 2261 | + if(This->lights[i].dltType != D3DLIGHT_DIRECTIONAL)
|
1974 | 2262 | {
|
1975 | | - if(prog.uniforms[23+(i*12)] != -1)
|
1976 | | - This->ext->glUniform3fv(prog.uniforms[23+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
|
1977 | | - if(prog.uniforms[25+(i*12)] != -1)
|
1978 | | - This->ext->glUniform1f(prog.uniforms[25+(i*12)],device->lights[device->gllights[i]]->light.dvRange);
|
1979 | | - if(prog.uniforms[26+(i*12)] != -1)
|
1980 | | - This->ext->glUniform1f(prog.uniforms[26+(i*12)],device->lights[device->gllights[i]]->light.dvFalloff);
|
1981 | | - if(prog.uniforms[27+(i*12)] != -1)
|
1982 | | - This->ext->glUniform1f(prog.uniforms[27+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation0);
|
1983 | | - if(prog.uniforms[28+(i*12)] != -1)
|
1984 | | - This->ext->glUniform1f(prog.uniforms[28+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation1);
|
1985 | | - if(prog.uniforms[29+(i*12)] != -1)
|
1986 | | - This->ext->glUniform1f(prog.uniforms[29+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation2);
|
1987 | | - if(prog.uniforms[30+(i*12)] != -1)
|
1988 | | - This->ext->glUniform1f(prog.uniforms[30+(i*12)],device->lights[device->gllights[i]]->light.dvTheta);
|
1989 | | - if(prog.uniforms[31+(i*12)] != -1)
|
1990 | | - This->ext->glUniform1f(prog.uniforms[31+(i*12)],device->lights[device->gllights[i]]->light.dvPhi);
|
| 2263 | + if(prog->uniforms[23+(i*12)] != -1)
|
| 2264 | + This->ext->glUniform3fv(prog->uniforms[23+(i*12)],1,(GLfloat*)&This->lights[i].dvPosition);
|
| 2265 | + if(prog->uniforms[25+(i*12)] != -1)
|
| 2266 | + This->ext->glUniform1f(prog->uniforms[25+(i*12)],This->lights[i].dvRange);
|
| 2267 | + if(prog->uniforms[26+(i*12)] != -1)
|
| 2268 | + This->ext->glUniform1f(prog->uniforms[26+(i*12)],This->lights[i].dvFalloff);
|
| 2269 | + if(prog->uniforms[27+(i*12)] != -1)
|
| 2270 | + This->ext->glUniform1f(prog->uniforms[27+(i*12)],This->lights[i].dvAttenuation0);
|
| 2271 | + if(prog->uniforms[28+(i*12)] != -1)
|
| 2272 | + This->ext->glUniform1f(prog->uniforms[28+(i*12)],This->lights[i].dvAttenuation1);
|
| 2273 | + if(prog->uniforms[29+(i*12)] != -1)
|
| 2274 | + This->ext->glUniform1f(prog->uniforms[29+(i*12)],This->lights[i].dvAttenuation2);
|
| 2275 | + if(prog->uniforms[30+(i*12)] != -1)
|
| 2276 | + This->ext->glUniform1f(prog->uniforms[30+(i*12)],This->lights[i].dvTheta);
|
| 2277 | + if(prog->uniforms[31+(i*12)] != -1)
|
| 2278 | + This->ext->glUniform1f(prog->uniforms[31+(i*12)],This->lights[i].dvPhi);
|
1991 | 2279 | }
|
1992 | 2280 | }
|
1993 | 2281 | lightindex++;
|
1994 | 2282 | }
|
1995 | 2283 |
|
1996 | | - DWORD ambient = device->renderstate[D3DRENDERSTATE_AMBIENT];
|
1997 | | - if(prog.uniforms[136] != -1)
|
1998 | | - This->ext->glUniform4f(prog.uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
|
| 2284 | + DWORD ambient = This->renderstate[D3DRENDERSTATE_AMBIENT];
|
| 2285 | + if(prog->uniforms[136] != -1)
|
| 2286 | + This->ext->glUniform4f(prog->uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
|
1999 | 2287 | RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
|
2000 | 2288 | GLint keycolor[4];
|
2001 | 2289 | for(i = 0; i < 8; i++)
|
2002 | 2290 | {
|
2003 | | - if(device->texstages[i].colorop == D3DTOP_DISABLE) break;
|
2004 | | - if(device->texstages[i].texture)
|
| 2291 | + if(This->texstages[i].colorop == D3DTOP_DISABLE) break;
|
| 2292 | + if(This->texstages[i].texture)
|
2005 | 2293 | {
|
2006 | | - if(device->texstages[i].texture->dirty & 1)
|
| 2294 | + if(This->texstages[i].texture->dirty & 1)
|
2007 | 2295 | {
|
2008 | | - glRenderer__UploadTexture(This,device->texstages[i].texture->buffer,device->texstages[i].texture->bigbuffer,
|
2009 | | - device->texstages[i].texture->texture,device->texstages[i].texture->ddsd.dwWidth,
|
2010 | | - device->texstages[i].texture->ddsd.dwHeight,device->texstages[i].texture->fakex,
|
2011 | | - device->texstages[i].texture->fakey,device->texstages[i].texture->ddsd.lPitch,
|
2012 | | - (device->texstages[i].texture->ddsd.ddpfPixelFormat.dwRGBBitCount/8*device->texstages[i].texture->fakex),
|
2013 | | - device->texstages[i].texture->ddsd.ddpfPixelFormat.dwRGBBitCount, device->texstages[i].texture->miplevel);
|
2014 | | - device->texstages[i].texture->dirty &= ~1;
|
| 2296 | + glRenderer__UploadTexture(This,This->texstages[i].texture->buffer,This->texstages[i].texture->bigbuffer,
|
| 2297 | + This->texstages[i].texture->texture,This->texstages[i].texture->ddsd.dwWidth,
|
| 2298 | + This->texstages[i].texture->ddsd.dwHeight,This->texstages[i].texture->fakex,
|
| 2299 | + This->texstages[i].texture->fakey,This->texstages[i].texture->ddsd.lPitch,
|
| 2300 | + (This->texstages[i].texture->ddsd.ddpfPixelFormat.dwRGBBitCount/8*This->texstages[i].texture->fakex),
|
| 2301 | + This->texstages[i].texture->ddsd.ddpfPixelFormat.dwRGBBitCount, This->texstages[i].texture->miplevel);
|
| 2302 | + This->texstages[i].texture->dirty &= ~1;
|
2015 | 2303 | }
|
2016 | | - if(device->texstages[i].texture)
|
2017 | | - device->texstages[i].texture->SetFilter(i,device->texstages[i].glmagfilter,device->texstages[i].glminfilter,This->ext,This->texman);
|
2018 | | - TextureManager_SetTexture(This->texman,i,device->texstages[i].texture->texture);
|
2019 | | - This->util->SetWrap(i,0,device->texstages[i].addressu,This->texman);
|
2020 | | - This->util->SetWrap(i,1,device->texstages[i].addressv,This->texman);
|
| 2304 | + if(This->texstages[i].texture)
|
| 2305 | + This->texstages[i].texture->SetFilter(i,This->texstages[i].glmagfilter,This->texstages[i].glminfilter,This->ext,This->texman);
|
| 2306 | + TextureManager_SetTexture(This->texman,i,This->texstages[i].texture->texture);
|
| 2307 | + This->util->SetWrap(i,0,This->texstages[i].addressu,This->texman);
|
| 2308 | + This->util->SetWrap(i,1,This->texstages[i].addressv,This->texman);
|
2021 | 2309 | }
|
2022 | 2310 | TextureManager_SetTexture(This->texman,i,0);
|
2023 | | - This->ext->glUniform1i(prog.uniforms[128+i],i);
|
2024 | | - if(device->renderstate[D3DRENDERSTATE_COLORKEYENABLE] && device->texstages[i].texture && (prog.uniforms[142+i] != -1))
|
| 2311 | + This->ext->glUniform1i(prog->uniforms[128+i],i);
|
| 2312 | + if(This->renderstate[D3DRENDERSTATE_COLORKEYENABLE] && This->texstages[i].texture && (prog->uniforms[142+i] != -1))
|
2025 | 2313 | {
|
2026 | | - if(device->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
|
| 2314 | + if(This->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
|
2027 | 2315 | {
|
2028 | | - SetColorKeyUniform(device->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,
|
2029 | | - device->texstages[i].texture->texture->colorsizes, device->texstages[i].texture->texture->colororder,
|
2030 | | - prog.uniforms[142 + i], device->texstages[i].texture->texture->colorbits, This->ext);
|
2031 | | - This->ext->glUniform4i(prog.uniforms[153+i], device->texstages[i].texture->texture->colorsizes[0],
|
2032 | | - device->texstages[i].texture->texture->colorsizes[1],
|
2033 | | - device->texstages[i].texture->texture->colorsizes[2],
|
2034 | | - device->texstages[i].texture->texture->colorsizes[3]);
|
| 2316 | + SetColorKeyUniform(This->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,
|
| 2317 | + This->texstages[i].texture->texture->colorsizes, This->texstages[i].texture->texture->colororder,
|
| 2318 | + prog->uniforms[142 + i], This->texstages[i].texture->texture->colorbits, This->ext);
|
| 2319 | + This->ext->glUniform4i(prog->uniforms[153+i], This->texstages[i].texture->texture->colorsizes[0],
|
| 2320 | + This->texstages[i].texture->texture->colorsizes[1],
|
| 2321 | + This->texstages[i].texture->texture->colorsizes[2],
|
| 2322 | + This->texstages[i].texture->texture->colorsizes[3]);
|
2035 | 2323 | }
|
2036 | 2324 | }
|
2037 | 2325 | }
|
2038 | | - if(prog.uniforms[137]!= -1) This->ext->glUniform1f(prog.uniforms[137],device->viewport.dwWidth);
|
2039 | | - if(prog.uniforms[138]!= -1) This->ext->glUniform1f(prog.uniforms[138],device->viewport.dwHeight);
|
2040 | | - if(prog.uniforms[139]!= -1) This->ext->glUniform1f(prog.uniforms[139],device->viewport.dwX);
|
2041 | | - if(prog.uniforms[140]!= -1) This->ext->glUniform1f(prog.uniforms[140],device->viewport.dwY);
|
2042 | | - if(prog.uniforms[141]!= -1) This->ext->glUniform1i(prog.uniforms[141],device->renderstate[D3DRENDERSTATE_ALPHAREF]);
|
2043 | | - if(prog.uniforms[150]!= -1) This->ext->glUniform4iv(prog.uniforms[150],1,(GLint*)device->glDDS7->texture->colorbits);
|
| 2326 | + if(prog->uniforms[137]!= -1) This->ext->glUniform1f(prog->uniforms[137],This->viewport.dwWidth);
|
| 2327 | + if(prog->uniforms[138]!= -1) This->ext->glUniform1f(prog->uniforms[138],This->viewport.dwHeight);
|
| 2328 | + if(prog->uniforms[139]!= -1) This->ext->glUniform1f(prog->uniforms[139],This->viewport.dwX);
|
| 2329 | + if(prog->uniforms[140]!= -1) This->ext->glUniform1f(prog->uniforms[140],This->viewport.dwY);
|
| 2330 | + if(prog->uniforms[141]!= -1) This->ext->glUniform1i(prog->uniforms[141],This->renderstate[D3DRENDERSTATE_ALPHAREF]);
|
| 2331 | + if(prog->uniforms[150]!= -1) This->ext->glUniform4iv(prog->uniforms[150],1,(GLint*)device->glDDS7->texture->colorbits);
|
2044 | 2332 | do
|
2045 | 2333 | {
|
2046 | 2334 | if (This->util->SetFBO(device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
|
— | — | @@ -2050,21 +2338,21 @@ |
2051 | 2339 | device->glDDS7->fbo.fbcolor = NULL;
|
2052 | 2340 | device->glDDS7->fbo.fbz = NULL;
|
2053 | 2341 | } while (1);
|
2054 | | - This->util->SetViewport((int)((float)device->viewport.dwX*device->glDDS7->mulx),
|
2055 | | - (int)((float)device->viewport.dwY*device->glDDS7->muly),
|
2056 | | - (int)((float)device->viewport.dwWidth*device->glDDS7->mulx),
|
2057 | | - (int)((float)device->viewport.dwHeight*device->glDDS7->muly));
|
2058 | | - This->util->SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
|
2059 | | - if(device->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) This->util->BlendEnable(true);
|
| 2342 | + This->util->SetViewport((int)((float)This->viewport.dwX*device->glDDS7->mulx),
|
| 2343 | + (int)((float)This->viewport.dwY*device->glDDS7->muly),
|
| 2344 | + (int)((float)This->viewport.dwWidth*device->glDDS7->mulx),
|
| 2345 | + (int)((float)This->viewport.dwHeight*device->glDDS7->muly));
|
| 2346 | + This->util->SetDepthRange(This->viewport.dvMinZ,This->viewport.dvMaxZ);
|
| 2347 | + if(This->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) This->util->BlendEnable(true);
|
2060 | 2348 | else This->util->BlendEnable(false);
|
2061 | | - glRenderer__SetBlend(This,device->renderstate[D3DRENDERSTATE_SRCBLEND],device->renderstate[D3DRENDERSTATE_DESTBLEND]);
|
2062 | | - This->util->SetCull((D3DCULL)device->renderstate[D3DRENDERSTATE_CULLMODE]);
|
2063 | | - glRenderer__SetFogColor(This,device->renderstate[D3DRENDERSTATE_FOGCOLOR]);
|
2064 | | - glRenderer__SetFogStart(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
|
2065 | | - glRenderer__SetFogEnd(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
|
2066 | | - glRenderer__SetFogDensity(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
|
2067 | | - This->util->SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
|
2068 | | - This->util->SetShadeMode((D3DSHADEMODE)device->renderstate[D3DRENDERSTATE_SHADEMODE]);
|
| 2349 | + glRenderer__SetBlend(This,This->renderstate[D3DRENDERSTATE_SRCBLEND],This->renderstate[D3DRENDERSTATE_DESTBLEND]);
|
| 2350 | + This->util->SetCull((D3DCULL)This->renderstate[D3DRENDERSTATE_CULLMODE]);
|
| 2351 | + glRenderer__SetFogColor(This,This->renderstate[D3DRENDERSTATE_FOGCOLOR]);
|
| 2352 | + glRenderer__SetFogStart(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGSTART]));
|
| 2353 | + glRenderer__SetFogEnd(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGEND]));
|
| 2354 | + glRenderer__SetFogDensity(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGDENSITY]));
|
| 2355 | + This->util->SetPolyMode((D3DFILLMODE)This->renderstate[D3DRENDERSTATE_FILLMODE]);
|
| 2356 | + This->util->SetShadeMode((D3DSHADEMODE)This->renderstate[D3DRENDERSTATE_SHADEMODE]);
|
2069 | 2357 | if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
|
2070 | 2358 | else glDrawArrays(mode,0,count);
|
2071 | 2359 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
— | — | @@ -2182,6 +2470,371 @@ |
2183 | 2471 | SetEvent(This->busy);
|
2184 | 2472 | }
|
2185 | 2473 |
|
| 2474 | +void glRenderer__SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
| 2475 | +{
|
| 2476 | + SetEvent(This->busy);
|
| 2477 | + if (This->renderstate[dwRendStateType] == dwRenderState) return;
|
| 2478 | + This->renderstate[dwRendStateType] = dwRenderState;
|
| 2479 | + switch (dwRendStateType)
|
| 2480 | + {
|
| 2481 | + case D3DRENDERSTATE_SHADEMODE:
|
| 2482 | + This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFFFCi64;
|
| 2483 | + switch (dwRenderState)
|
| 2484 | + {
|
| 2485 | + case D3DSHADE_FLAT:
|
| 2486 | + default:
|
| 2487 | + break;
|
| 2488 | + case D3DSHADE_GOURAUD:
|
| 2489 | + This->shaderstate3d.stateid |= 1;
|
| 2490 | + break;
|
| 2491 | + case D3DSHADE_PHONG:
|
| 2492 | + This->shaderstate3d.stateid |= 3;
|
| 2493 | + break;
|
| 2494 | + }
|
| 2495 | + break;
|
| 2496 | + case D3DRENDERSTATE_ALPHATESTENABLE:
|
| 2497 | + if (dwRenderState) This->shaderstate3d.stateid |= 4;
|
| 2498 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFFFBi64;
|
| 2499 | + break;
|
| 2500 | + case D3DRENDERSTATE_ALPHAFUNC:
|
| 2501 | + This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFFC7i64;
|
| 2502 | + This->shaderstate3d.stateid |= ((((__int64)dwRenderState - 1) & 7) << 3);
|
| 2503 | + break;
|
| 2504 | + case D3DRENDERSTATE_FOGTABLEMODE:
|
| 2505 | + This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFF3Fi64;
|
| 2506 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 6);
|
| 2507 | + break;
|
| 2508 | + case D3DRENDERSTATE_FOGVERTEXMODE:
|
| 2509 | + This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFCFFi64;
|
| 2510 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 8);
|
| 2511 | + break;
|
| 2512 | + case D3DRENDERSTATE_RANGEFOGENABLE:
|
| 2513 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 10);
|
| 2514 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFFBFFi64;
|
| 2515 | + break;
|
| 2516 | + case D3DRENDERSTATE_SPECULARENABLE:
|
| 2517 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 11);
|
| 2518 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFF7FFi64;
|
| 2519 | + break;
|
| 2520 | + case D3DRENDERSTATE_STIPPLEDALPHA:
|
| 2521 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 12);
|
| 2522 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFEFFFi64;
|
| 2523 | + break;
|
| 2524 | + case D3DRENDERSTATE_COLORKEYENABLE:
|
| 2525 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 13);
|
| 2526 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFFFDFFFi64;
|
| 2527 | + break;
|
| 2528 | + case D3DRENDERSTATE_LOCALVIEWER:
|
| 2529 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 21);
|
| 2530 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFDFFFFFi64;
|
| 2531 | + break;
|
| 2532 | + case D3DRENDERSTATE_COLORKEYBLENDENABLE:
|
| 2533 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 22);
|
| 2534 | + else This->shaderstate3d.stateid &= 0xFFFFFFFFFFBFFFFFi64;
|
| 2535 | + break;
|
| 2536 | + case D3DRENDERSTATE_DIFFUSEMATERIALSOURCE:
|
| 2537 | + This->shaderstate3d.stateid &= 0xFFFFFFFFFE7FFFFFi64;
|
| 2538 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 23);
|
| 2539 | + break;
|
| 2540 | + case D3DRENDERSTATE_SPECULARMATERIALSOURCE:
|
| 2541 | + This->shaderstate3d.stateid &= 0xFFFFFFFFF9FFFFFFi64;
|
| 2542 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 25);
|
| 2543 | + break;
|
| 2544 | + case D3DRENDERSTATE_AMBIENTMATERIALSOURCE:
|
| 2545 | + This->shaderstate3d.stateid &= 0xFFFFFFFFE7FFFFFFi64;
|
| 2546 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 27);
|
| 2547 | + break;
|
| 2548 | + case D3DRENDERSTATE_EMISSIVEMATERIALSOURCE:
|
| 2549 | + This->shaderstate3d.stateid &= 0xFFFFFFFFBFFFFFFFi64;
|
| 2550 | + This->shaderstate3d.stateid |= (((__int64)dwRenderState & 3) << 29);
|
| 2551 | + break;
|
| 2552 | + case D3DRENDERSTATE_NORMALIZENORMALS:
|
| 2553 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 49);
|
| 2554 | + else This->shaderstate3d.stateid &= 0xFFFDFFFFFFFFFFFFi64;
|
| 2555 | + break;
|
| 2556 | + case D3DRENDERSTATE_LIGHTING:
|
| 2557 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 59);
|
| 2558 | + else This->shaderstate3d.stateid &= 0xF7FFFFFFFFFFFFFFi64;
|
| 2559 | + break;
|
| 2560 | + case D3DRENDERSTATE_COLORVERTEX:
|
| 2561 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 60);
|
| 2562 | + else This->shaderstate3d.stateid &= 0xEFFFFFFFFFFFFFFFi64;
|
| 2563 | + break;
|
| 2564 | + case D3DRENDERSTATE_FOGENABLE:
|
| 2565 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 61);
|
| 2566 | + else This->shaderstate3d.stateid &= 0xDFFFFFFFFFFFFFFFi64;
|
| 2567 | + break;
|
| 2568 | + case D3DRENDERSTATE_DITHERENABLE:
|
| 2569 | + if (dwRenderState) This->shaderstate3d.stateid |= (1i64 << 62);
|
| 2570 | + else This->shaderstate3d.stateid &= 0xBFFFFFFFFFFFFFFFi64;
|
| 2571 | + break;
|
| 2572 | + default:
|
| 2573 | + break;
|
| 2574 | + }
|
| 2575 | +}
|
| 2576 | +
|
| 2577 | +void glRenderer__SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
|
| 2578 | +{
|
| 2579 | + if (This->texstages[dwStage].texture == Texture)
|
| 2580 | + {
|
| 2581 | + SetEvent(This->busy);
|
| 2582 | + return;
|
| 2583 | + }
|
| 2584 | + This->texstages[dwStage].texture = Texture;
|
| 2585 | + if (Texture)
|
| 2586 | + {
|
| 2587 | + This->shaderstate3d.texstageid[dwStage] |= 1i64 << 59;
|
| 2588 | + if (Texture->ddsd.dwFlags & DDSD_CKSRCBLT) This->shaderstate3d.texstageid[dwStage] |= 1i64 << 60;
|
| 2589 | + else This->shaderstate3d.texstageid[dwStage] &= 0xEFFFFFFFFFFFFFFFi64;
|
| 2590 | + }
|
| 2591 | + else This->shaderstate3d.texstageid[dwStage] &= 0xE7FFFFFFFFFFFFFFi64;
|
| 2592 | + SetEvent(This->busy);
|
| 2593 | +}
|
| 2594 | +
|
| 2595 | +void glRenderer__SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
| 2596 | +{
|
| 2597 | + SetEvent(This->busy);
|
| 2598 | + switch (dwState)
|
| 2599 | + {
|
| 2600 | + case D3DTSS_COLOROP:
|
| 2601 | + This->texstages[dwStage].colorop = (D3DTEXTUREOP)dwValue;
|
| 2602 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFFFFFFFFE0i64;
|
| 2603 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)dwValue & 31);
|
| 2604 | + break;
|
| 2605 | + case D3DTSS_COLORARG1:
|
| 2606 | + This->texstages[dwStage].colorarg1 = dwValue;
|
| 2607 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFFFFFFF81Fi64;
|
| 2608 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 63) << 5);
|
| 2609 | + break;
|
| 2610 | + case D3DTSS_COLORARG2:
|
| 2611 | + This->texstages[dwStage].colorarg2 = dwValue;
|
| 2612 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFFFFFE07FFi64;
|
| 2613 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 63) << 11);
|
| 2614 | + break;
|
| 2615 | + case D3DTSS_ALPHAOP:
|
| 2616 | + This->texstages[dwStage].alphaop = (D3DTEXTUREOP)dwValue;
|
| 2617 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFFFFC1FFFFi64;
|
| 2618 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 31) << 17);
|
| 2619 | + break;
|
| 2620 | + case D3DTSS_ALPHAARG1:
|
| 2621 | + This->texstages[dwStage].alphaarg1 = dwValue;
|
| 2622 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFFF03FFFFFi64;
|
| 2623 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 63) << 22);
|
| 2624 | + break;
|
| 2625 | + case D3DTSS_ALPHAARG2:
|
| 2626 | + This->texstages[dwStage].alphaarg2 = dwValue;
|
| 2627 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFFFC0FFFFFFFi64;
|
| 2628 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 63) << 28);
|
| 2629 | + break;
|
| 2630 | + case D3DTSS_BUMPENVMAT00:
|
| 2631 | + This->texstages[dwStage].bumpenv00 = dwValue;
|
| 2632 | + break;
|
| 2633 | + case D3DTSS_BUMPENVMAT01:
|
| 2634 | + This->texstages[dwStage].bumpenv01 = dwValue;
|
| 2635 | + break;
|
| 2636 | + case D3DTSS_BUMPENVMAT10:
|
| 2637 | + This->texstages[dwStage].bumpenv10 = dwValue;
|
| 2638 | + break;
|
| 2639 | + case D3DTSS_BUMPENVMAT11:
|
| 2640 | + This->texstages[dwStage].bumpenv11 = dwValue;
|
| 2641 | + break;
|
| 2642 | + case D3DTSS_TEXCOORDINDEX:
|
| 2643 | + This->texstages[dwStage].texcoordindex = dwValue;
|
| 2644 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFF83FFFFFFFFi64;
|
| 2645 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 7) << 34);
|
| 2646 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)((dwValue>>16) & 7) << 37);
|
| 2647 | + break;
|
| 2648 | + case D3DTSS_ADDRESSU:
|
| 2649 | + This->texstages[dwStage].addressu = (D3DTEXTUREADDRESS)dwValue;
|
| 2650 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFFE7FFFFFFFFFi64;
|
| 2651 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 3) << 39);
|
| 2652 | + break;
|
| 2653 | + case D3DTSS_ADDRESSV:
|
| 2654 | + This->texstages[dwStage].addressv = (D3DTEXTUREADDRESS)dwValue;
|
| 2655 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFFFF9FFFFFFFFFFi64;
|
| 2656 | + This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 3) << 41);
|
| 2657 | + break;
|
| 2658 | + case D3DTSS_BORDERCOLOR:
|
| 2659 | + This->texstages[dwStage].bordercolor = dwValue;
|
| 2660 | + break;
|
| 2661 | + case D3DTSS_MAGFILTER:
|
| 2662 | + This->texstages[dwStage].magfilter = (D3DTEXTUREMAGFILTER)dwValue;
|
| 2663 | + //This->shaderstate3d.texstageid[dwStage] &= 0xFFFFC7FFFFFFFFFFi64;
|
| 2664 | + //This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 7) << 43);
|
| 2665 | + switch (This->texstages[dwStage].magfilter)
|
| 2666 | + {
|
| 2667 | + case 1:
|
| 2668 | + default:
|
| 2669 | + This->texstages[dwStage].glmagfilter = GL_NEAREST;
|
| 2670 | + break;
|
| 2671 | + case 2:
|
| 2672 | + case 3:
|
| 2673 | + case 4:
|
| 2674 | + case 5:
|
| 2675 | + This->texstages[dwStage].glmagfilter = GL_LINEAR;
|
| 2676 | + break;
|
| 2677 | + }
|
| 2678 | + break;
|
| 2679 | + case D3DTSS_MINFILTER:
|
| 2680 | + This->texstages[dwStage].minfilter = (D3DTEXTUREMINFILTER)dwValue;
|
| 2681 | + //This->shaderstate3d.texstageid[dwStage] &= 0xFFFF3FFFFFFFFFFFi64;
|
| 2682 | + //This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 7) << 46);
|
| 2683 | + switch (This->texstages[dwStage].minfilter)
|
| 2684 | + {
|
| 2685 | + case 1:
|
| 2686 | + default:
|
| 2687 | + switch (This->texstages[dwStage].mipfilter)
|
| 2688 | + {
|
| 2689 | + case 1:
|
| 2690 | + default:
|
| 2691 | + This->texstages[dwStage].glminfilter = GL_NEAREST;
|
| 2692 | + break;
|
| 2693 | + case 2:
|
| 2694 | + This->texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
| 2695 | + break;
|
| 2696 | + case 3:
|
| 2697 | + This->texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
| 2698 | + break;
|
| 2699 | + }
|
| 2700 | + break;
|
| 2701 | + case 2:
|
| 2702 | + case 3:
|
| 2703 | + switch (This->texstages[dwStage].mipfilter)
|
| 2704 | + {
|
| 2705 | + case 1:
|
| 2706 | + default:
|
| 2707 | + This->texstages[dwStage].glminfilter = GL_LINEAR;
|
| 2708 | + break;
|
| 2709 | + case 2:
|
| 2710 | + This->texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
| 2711 | + break;
|
| 2712 | + case 3:
|
| 2713 | + This->texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
| 2714 | + break;
|
| 2715 | + }
|
| 2716 | + break;
|
| 2717 | + }
|
| 2718 | + break;
|
| 2719 | + case D3DTSS_MIPFILTER:
|
| 2720 | + This->texstages[dwStage].mipfilter = (D3DTEXTUREMIPFILTER)dwValue;
|
| 2721 | + //This->shaderstate3d.texstageid[dwStage] &= 0xFFFCFFFFFFFFFFFFi64;
|
| 2722 | + //This->shaderstate3d.texstageid[dwStage] |= ((__int64)(dwValue & 7) << 48);
|
| 2723 | + switch (This->texstages[dwStage].mipfilter)
|
| 2724 | + {
|
| 2725 | + case 1:
|
| 2726 | + default:
|
| 2727 | + switch (This->texstages[dwStage].minfilter)
|
| 2728 | + {
|
| 2729 | + case 1:
|
| 2730 | + default:
|
| 2731 | + This->texstages[dwStage].glminfilter = GL_NEAREST;
|
| 2732 | + case 2:
|
| 2733 | + case 3:
|
| 2734 | + This->texstages[dwStage].glminfilter = GL_LINEAR;
|
| 2735 | + }
|
| 2736 | + break;
|
| 2737 | + case 2:
|
| 2738 | + switch (This->texstages[dwStage].minfilter)
|
| 2739 | + {
|
| 2740 | + case 1:
|
| 2741 | + default:
|
| 2742 | + This->texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
| 2743 | + case 2:
|
| 2744 | + case 3:
|
| 2745 | + This->texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
| 2746 | + }
|
| 2747 | + break;
|
| 2748 | + case 3:
|
| 2749 | + switch (This->texstages[dwStage].minfilter)
|
| 2750 | + {
|
| 2751 | + case 1:
|
| 2752 | + default:
|
| 2753 | + This->texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
| 2754 | + case 2:
|
| 2755 | + case 3:
|
| 2756 | + This->texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
| 2757 | + }
|
| 2758 | + break;
|
| 2759 | + }
|
| 2760 | + break;
|
| 2761 | + case D3DTSS_MIPMAPLODBIAS:
|
| 2762 | + memcpy(&This->texstages[dwStage].lodbias, &dwValue, sizeof(D3DVALUE));
|
| 2763 | + break;
|
| 2764 | + case D3DTSS_MAXMIPLEVEL:
|
| 2765 | + This->texstages[dwStage].miplevel = dwValue;
|
| 2766 | + break;
|
| 2767 | + case D3DTSS_MAXANISOTROPY:
|
| 2768 | + This->texstages[dwStage].anisotropy = dwValue;
|
| 2769 | + break;
|
| 2770 | + case D3DTSS_BUMPENVLSCALE:
|
| 2771 | + memcpy(&This->texstages[dwStage].bumpenvlscale, &dwValue, sizeof(D3DVALUE));
|
| 2772 | + break;
|
| 2773 | + case D3DTSS_BUMPENVLOFFSET:
|
| 2774 | + memcpy(&This->texstages[dwStage].bumpenvloffset, &dwValue, sizeof(D3DVALUE));
|
| 2775 | + break;
|
| 2776 | + case D3DTSS_TEXTURETRANSFORMFLAGS:
|
| 2777 | + This->texstages[dwStage].textransform = (D3DTEXTURETRANSFORMFLAGS)dwValue;
|
| 2778 | + This->shaderstate3d.texstageid[dwStage] &= 0xFFC3FFFFFFFFFFFFi64;
|
| 2779 | + if (dwValue & 7)
|
| 2780 | + {
|
| 2781 | + This->shaderstate3d.texstageid[dwStage] |= 1i64 << 50;
|
| 2782 | + This->shaderstate3d.texstageid[dwStage] |= (__int64)(((dwValue & 7) - 1) & 3) << 51;
|
| 2783 | + }
|
| 2784 | + if (dwValue & D3DTTFF_PROJECTED) This->shaderstate3d.texstageid[dwStage] |= 1i64 << 53;
|
| 2785 | + break;
|
| 2786 | + default:
|
| 2787 | + break;
|
| 2788 | + }
|
| 2789 | +}
|
| 2790 | +
|
| 2791 | +void glRenderer__SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 2792 | +{
|
| 2793 | + if (dtstTransformStateType > 23)
|
| 2794 | + {
|
| 2795 | + SetEvent(This->busy);
|
| 2796 | + return;
|
| 2797 | + }
|
| 2798 | + memcpy(&This->transform[dtstTransformStateType], lpD3DMatrix, sizeof(D3DMATRIX));
|
| 2799 | + SetEvent(This->busy);
|
| 2800 | +}
|
| 2801 | +
|
| 2802 | +void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
|
| 2803 | +{
|
| 2804 | + memcpy(&This->material, lpMaterial, sizeof(D3DMATERIAL));
|
| 2805 | + SetEvent(This->busy);
|
| 2806 | +}
|
| 2807 | +
|
| 2808 | +void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
| 2809 | +{
|
| 2810 | + int numlights = 0;
|
| 2811 | + int lightindex = 0;
|
| 2812 | + if(!remove)memcpy(&This->lights[index], light, sizeof(D3DLIGHT7));
|
| 2813 | + else ZeroMemory(&This->lights[index], sizeof(D3DLIGHT7));
|
| 2814 | + SetEvent(This->busy);
|
| 2815 | + for (int i = 0; i < 8; i++)
|
| 2816 | + if (This->lights[i].dltType) numlights++;
|
| 2817 | + This->shaderstate3d.stateid &= 0xF807C03FFFE3FFFFi64;
|
| 2818 | + This->shaderstate3d.stateid |= ((__int64)numlights << 18);
|
| 2819 | + for (int i = 0; i < 8; i++)
|
| 2820 | + {
|
| 2821 | + if (This->lights[i].dltType != 1)
|
| 2822 | + {
|
| 2823 | + if (This->lights[i].dltType != D3DLIGHT_DIRECTIONAL)
|
| 2824 | + This->shaderstate3d.stateid |= (1i64 << (38 + lightindex));
|
| 2825 | + if (This->lights[i].dltType == D3DLIGHT_SPOT)
|
| 2826 | + This->shaderstate3d.stateid |= (1i64 << (51 + lightindex));
|
| 2827 | + lightindex++;
|
| 2828 | + }
|
| 2829 | + }
|
| 2830 | +
|
| 2831 | +}
|
| 2832 | +
|
| 2833 | +void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
| 2834 | +{
|
| 2835 | + memcpy(&This->viewport, lpViewport, sizeof(D3DVIEWPORT7));
|
| 2836 | + SetEvent(This->busy);
|
| 2837 | +}
|
| 2838 | +
|
2186 | 2839 | void glRenderer__SetFogColor(glRenderer *This, DWORD color)
|
2187 | 2840 | {
|
2188 | 2841 | if (color == This->fogcolor) return;
|
— | — | @@ -2215,4 +2868,36 @@ |
2216 | 2869 | glFogf(GL_FOG_DENSITY, density);
|
2217 | 2870 | }
|
2218 | 2871 |
|
| 2872 | +void glRenderer__SetDepthComp(glRenderer *This)
|
| 2873 | +{
|
| 2874 | + switch (This->renderstate[D3DRENDERSTATE_ZFUNC])
|
| 2875 | + {
|
| 2876 | + case D3DCMP_NEVER:
|
| 2877 | + This->util->SetDepthComp(GL_NEVER);
|
| 2878 | + break;
|
| 2879 | + case D3DCMP_LESS:
|
| 2880 | + This->util->SetDepthComp(GL_LESS);
|
| 2881 | + break;
|
| 2882 | + case D3DCMP_EQUAL:
|
| 2883 | + This->util->SetDepthComp(GL_EQUAL);
|
| 2884 | + break;
|
| 2885 | + case D3DCMP_LESSEQUAL:
|
| 2886 | + This->util->SetDepthComp(GL_LEQUAL);
|
| 2887 | + break;
|
| 2888 | + case D3DCMP_GREATER:
|
| 2889 | + This->util->SetDepthComp(GL_GREATER);
|
| 2890 | + break;
|
| 2891 | + case D3DCMP_NOTEQUAL:
|
| 2892 | + This->util->SetDepthComp(GL_NOTEQUAL);
|
| 2893 | + break;
|
| 2894 | + case D3DCMP_GREATEREQUAL:
|
| 2895 | + This->util->SetDepthComp(GL_GEQUAL);
|
| 2896 | + break;
|
| 2897 | + case D3DCMP_ALWAYS:
|
| 2898 | + default:
|
| 2899 | + This->util->SetDepthComp(GL_ALWAYS);
|
| 2900 | + break;
|
| 2901 | + }
|
| 2902 | +}
|
| 2903 | +
|
2219 | 2904 | } |
\ No newline at end of file |
Index: ddraw/glRenderer.h |
— | — | @@ -51,6 +51,42 @@ |
52 | 52 | int stride;
|
53 | 53 | } GLVERTEX;
|
54 | 54 |
|
| 55 | +typedef struct
|
| 56 | +{
|
| 57 | + __int64 stateid;
|
| 58 | + __int64 texstageid[8];
|
| 59 | +} SHADERSTATE;
|
| 60 | +
|
| 61 | +struct TEXTURESTAGE
|
| 62 | +{
|
| 63 | + D3DTEXTUREOP colorop;
|
| 64 | + DWORD colorarg1;
|
| 65 | + DWORD colorarg2;
|
| 66 | + D3DTEXTUREOP alphaop;
|
| 67 | + DWORD alphaarg1;
|
| 68 | + DWORD alphaarg2;
|
| 69 | + D3DVALUE bumpenv00;
|
| 70 | + D3DVALUE bumpenv01;
|
| 71 | + D3DVALUE bumpenv10;
|
| 72 | + D3DVALUE bumpenv11;
|
| 73 | + DWORD texcoordindex;
|
| 74 | + D3DTEXTUREADDRESS addressu;
|
| 75 | + D3DTEXTUREADDRESS addressv;
|
| 76 | + DWORD bordercolor;
|
| 77 | + D3DTEXTUREMAGFILTER magfilter;
|
| 78 | + D3DTEXTUREMINFILTER minfilter;
|
| 79 | + D3DTEXTUREMIPFILTER mipfilter;
|
| 80 | + D3DVALUE lodbias;
|
| 81 | + DWORD miplevel;
|
| 82 | + DWORD anisotropy;
|
| 83 | + D3DVALUE bumpenvlscale;
|
| 84 | + D3DVALUE bumpenvloffset;
|
| 85 | + D3DTEXTURETRANSFORMFLAGS textransform;
|
| 86 | + glDirectDrawSurface7 *texture;
|
| 87 | + GLint glmagfilter;
|
| 88 | + GLint glminfilter;
|
| 89 | +};
|
| 90 | +
|
55 | 91 | #define OP_NULL 0
|
56 | 92 | #define OP_SETWND 1
|
57 | 93 | #define OP_DELETE 2
|
— | — | @@ -67,7 +103,18 @@ |
68 | 104 | #define OP_DELETEFBO 13
|
69 | 105 | #define OP_UPDATECLIPPER 14
|
70 | 106 | #define OP_DEPTHFILL 15
|
| 107 | +#define OP_SETRENDERSTATE 16
|
| 108 | +#define OP_SETTEXTURE 17
|
| 109 | +#define OP_SETTEXTURESTAGESTATE 18
|
| 110 | +#define OP_SETTRANSFORM 19
|
| 111 | +#define OP_SETMATERIAL 20
|
| 112 | +#define OP_SETLIGHT 21
|
| 113 | +#define OP_SETVIEWPORT 22
|
71 | 114 |
|
| 115 | +extern const DWORD renderstate_default[153];
|
| 116 | +extern const TEXTURESTAGE texstagedefault0;
|
| 117 | +extern const TEXTURESTAGE texstagedefault1;
|
| 118 | +
|
72 | 119 | #ifdef __cplusplus
|
73 | 120 | class glDirectDraw7;
|
74 | 121 | class glDirect3DDevice7;
|
— | — | @@ -117,6 +164,13 @@ |
118 | 165 | TextureManager *texman;
|
119 | 166 | glUtil *util;
|
120 | 167 | ShaderManager *shaders;
|
| 168 | + DWORD renderstate[153];
|
| 169 | + SHADERSTATE shaderstate3d;
|
| 170 | + TEXTURESTAGE texstages[8];
|
| 171 | + D3DMATERIAL7 material;
|
| 172 | + D3DLIGHT7 lights[8];
|
| 173 | + D3DMATRIX transform[24];
|
| 174 | + D3DVIEWPORT7 viewport;
|
121 | 175 | } glRenderer;
|
122 | 176 |
|
123 | 177 | void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
|
— | — | @@ -129,7 +183,7 @@ |
130 | 184 | void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height);
|
131 | 185 | void glRenderer_DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
|
132 | 186 | void glRenderer_DeleteTexture(glRenderer *This, TEXTURE *texture);
|
133 | | -void glRenderer_InitD3D(glRenderer *This, int zbuffer);
|
| 187 | +void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
134 | 188 | void glRenderer_Flush(glRenderer *This);
|
135 | 189 | void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
136 | 190 | HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
— | — | @@ -139,6 +193,13 @@ |
140 | 194 | void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
141 | 195 | unsigned int glRenderer_GetScanLine(glRenderer *This);
|
142 | 196 | HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
| 197 | +void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
| 198 | +void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture);
|
| 199 | +void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
| 200 | +void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 201 | +void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
| 202 | +void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 203 | +void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
143 | 204 | // In-thread APIs
|
144 | 205 | DWORD glRenderer__Entry(glRenderer *This);
|
145 | 206 | BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
— | — | @@ -151,7 +212,7 @@ |
152 | 213 | void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture);
|
153 | 214 | void glRenderer__DrawBackbuffer(glRenderer *This, TEXTURE **texture, int x, int y, int progtype);
|
154 | 215 | void glRenderer__DrawBackbufferRect(glRenderer *This, TEXTURE *texture, RECT srcrect, int progtype);
|
155 | | -void glRenderer__InitD3D(glRenderer *This, int zbuffer);
|
| 216 | +void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
156 | 217 | void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
157 | 218 | void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
|
158 | 219 | DWORD indexcount, DWORD flags);
|
— | — | @@ -166,6 +227,14 @@ |
167 | 228 | void glRenderer__SetFogDensity(glRenderer *This, GLfloat density);
|
168 | 229 | inline void glRenderer__SetSwap(glRenderer *This, int swap);
|
169 | 230 | void glRenderer__SetBlend(glRenderer *This, DWORD src, DWORD dest);
|
| 231 | +void glRenderer__SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
| 232 | +void glRenderer__SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture);
|
| 233 | +void glRenderer__SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
| 234 | +void glRenderer__SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
|
| 235 | +void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
| 236 | +void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 237 | +void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
| 238 | +void glRenderer__SetDepthComp(glRenderer *This);
|
170 | 239 |
|
171 | 240 | #ifdef __cplusplus
|
172 | 241 | }
|