Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -22,6 +22,8 @@ |
23 | 23 | #include "glDirectDrawSurface.h"
|
24 | 24 | #include "glDirect3DDevice.h"
|
25 | 25 | #include "glDirect3DLight.h"
|
| 26 | +#include <string>
|
| 27 | +using namespace std;
|
26 | 28 | #include "shadergen.h"
|
27 | 29 | #include "glutil.h"
|
28 | 30 | #include "matrix.h"
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | #include "glDirectDrawPalette.h"
|
27 | 27 | #include "glDirectDrawClipper.h"
|
28 | 28 | #include "glRenderer.h"
|
| 29 | +#include <string>
|
| 30 | +using namespace std;
|
29 | 31 | #include "shadergen.h"
|
30 | 32 | #include "shaders.h"
|
31 | 33 | #include "glutil.h"
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | #include "glutil.h"
|
27 | 27 | #include "ddraw.h"
|
28 | 28 | #include "scalers.h"
|
| 29 | +#include <string>
|
| 30 | +using namespace std;
|
29 | 31 | #include "shadergen.h"
|
30 | 32 | #include "matrix.h"
|
31 | 33 |
|
— | — | @@ -1002,8 +1004,6 @@ |
1003 | 1005 | DWORD indexcount, DWORD flags)
|
1004 | 1006 | {
|
1005 | 1007 | bool transformed;
|
1006 | | - char blendvar[] = "blendX";
|
1007 | | - char rgbavar[] = "rgbaX";
|
1008 | 1008 | char svar[] = "sX";
|
1009 | 1009 | char stvar[] = "stX";
|
1010 | 1010 | char strvar[] = "strX";
|
— | — | @@ -1019,34 +1019,35 @@ |
1020 | 1020 | }
|
1021 | 1021 | __int64 shader = device->SelectShader(vertices);
|
1022 | 1022 | SetShader(shader,device->texstages,texformats,0);
|
1023 | | - GLuint prog = GetProgram();
|
1024 | | - GLint xyzloc = glGetAttribLocation(prog,"xyz");
|
1025 | | - glEnableVertexAttribArray(xyzloc);
|
1026 | | - glVertexAttribPointer(xyzloc,3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
| 1023 | + _GENSHADER prog = genshaders[current_genshader].shader;
|
| 1024 | + glEnableVertexAttribArray(prog.attribs[0]);
|
| 1025 | + glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
1027 | 1026 | if(transformed)
|
1028 | 1027 | {
|
1029 | | - GLint xyzwloc = glGetAttribLocation(prog,"rhw");
|
1030 | | - if(xyzwloc != -1)
|
| 1028 | + if(prog.attribs[1] != -1)
|
1031 | 1029 | {
|
1032 | | - glEnableVertexAttribArray(xyzwloc);
|
1033 | | - glVertexAttribPointer(xyzwloc,4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
| 1030 | + glEnableVertexAttribArray(prog.attribs[1]);
|
| 1031 | + glVertexAttribPointer(prog.attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
1034 | 1032 | }
|
1035 | 1033 | }
|
1036 | 1034 | for(i = 0; i < 5; i++)
|
1037 | 1035 | {
|
1038 | | - GLint blendloc;
|
1039 | 1036 | if(vertices[i+2].data)
|
1040 | 1037 | {
|
1041 | | - blendvar[5] = i+'0';
|
1042 | | - blendloc = glGetAttribLocation(prog,blendvar);
|
1043 | | - glVertexAttribPointer(blendloc,1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
| 1038 | + if(prog.attribs[i+2] != -1)
|
| 1039 | + {
|
| 1040 | + glEnableVertexAttribArray(prog.attribs[i+2]);
|
| 1041 | + glVertexAttribPointer(prog.attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
| 1042 | + }
|
1044 | 1043 | }
|
1045 | 1044 | }
|
1046 | 1045 | if(vertices[7].data)
|
1047 | 1046 | {
|
1048 | | - GLint normalloc = glGetAttribLocation(prog,"nxyz");
|
1049 | | - glEnableVertexAttribArray(normalloc);
|
1050 | | - glVertexAttribPointer(normalloc,3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
| 1047 | + if(prog.attribs[7] != -1)
|
| 1048 | + {
|
| 1049 | + glEnableVertexAttribArray(prog.attribs[7]);
|
| 1050 | + glVertexAttribPointer(prog.attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
| 1051 | + }
|
1051 | 1052 | }
|
1052 | 1053 | for(i = 0; i < 2; i++)
|
1053 | 1054 | {
|
— | — | @@ -1053,9 +1054,11 @@ |
1054 | 1055 | GLint colorloc;
|
1055 | 1056 | if(vertices[i+8].data)
|
1056 | 1057 | {
|
1057 | | - rgbavar[4] = i + '0';
|
1058 | | - colorloc = glGetAttribLocation(prog,rgbavar);
|
1059 | | - glVertexAttribPointer(colorloc,4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
| 1058 | + if(prog.attribs[8+i] != -1)
|
| 1059 | + {
|
| 1060 | + glEnableVertexAttribArray(prog.attribs[8+i]);
|
| 1061 | + glVertexAttribPointer(prog.attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
| 1062 | + }
|
1060 | 1063 | }
|
1061 | 1064 | }
|
1062 | 1065 | for(i = 0; i < 8; i++)
|
— | — | @@ -1069,28 +1072,16 @@ |
1070 | 1073 | }
|
1071 | 1074 | }
|
1072 | 1075 | if(device->normal_dirty) device->UpdateNormalMatrix();
|
1073 | | - GLint loc = glGetUniformLocation(prog,"world");
|
1074 | | - glUniformMatrix4fv(loc,1,false,device->matWorld);
|
1075 | | - loc = glGetUniformLocation(prog,"view");
|
1076 | | - glUniformMatrix4fv(loc,1,false,device->matView);
|
1077 | | - loc = glGetUniformLocation(prog,"projection");
|
1078 | | - glUniformMatrix4fv(loc,1,false,device->matProjection);
|
1079 | | - loc = glGetUniformLocation(prog,"normalmat");
|
1080 | | - glUniformMatrix3fv(loc,1,true,device->matNormal);
|
1081 | | - loc = glGetUniformLocation(prog,"material.diffuse");
|
1082 | | - glUniform4fv(loc,1,(GLfloat*)&device->material.diffuse);
|
1083 | | - loc = glGetUniformLocation(prog,"material.ambient");
|
1084 | | - glUniform4fv(loc,1,(GLfloat*)&device->material.ambient);
|
1085 | | - loc = glGetUniformLocation(prog,"material.specular");
|
1086 | | - glUniform4fv(loc,1,(GLfloat*)&device->material.specular);
|
1087 | | - loc = glGetUniformLocation(prog,"material.emissive");
|
1088 | | - glUniform4fv(loc,1,(GLfloat*)&device->material.emissive);
|
1089 | | - loc = glGetUniformLocation(prog,"material.power");
|
1090 | | - glUniform1f(loc,device->material.power);
|
1091 | | - loc = glGetUniformLocation(prog,"ambientcolor");
|
1092 | | - DWORD ambient = device->renderstate[D3DRENDERSTATE_AMBIENT];
|
1093 | | - glUniform4f(loc,RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
|
1094 | | - RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
|
| 1076 | + if(prog.uniforms[0] != -1) glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
|
| 1077 | + if(prog.uniforms[1] != -1) glUniformMatrix4fv(prog.uniforms[1],1,false,device->matView);
|
| 1078 | + if(prog.uniforms[2] != -1) glUniformMatrix4fv(prog.uniforms[2],1,false,device->matProjection);
|
| 1079 | + if(prog.uniforms[3] != -1) glUniformMatrix3fv(prog.uniforms[3],1,true,device->matNormal);
|
| 1080 | +
|
| 1081 | + if(prog.uniforms[15] != -1) glUniform4fv(prog.uniforms[15],1,(GLfloat*)&device->material.ambient);
|
| 1082 | + if(prog.uniforms[16] != -1) glUniform4fv(prog.uniforms[16],1,(GLfloat*)&device->material.diffuse);
|
| 1083 | + if(prog.uniforms[17] != -1) glUniform4fv(prog.uniforms[17],1,(GLfloat*)&device->material.specular);
|
| 1084 | + if(prog.uniforms[18] != -1) glUniform4fv(prog.uniforms[18],1,(GLfloat*)&device->material.emissive);
|
| 1085 | + if(prog.uniforms[19] != -1) glUniform1f(prog.uniforms[19],device->material.power);
|
1095 | 1086 | int lightindex = 0;
|
1096 | 1087 | char lightname[] = "lightX.xxxxxxxxxxxxxxxx";
|
1097 | 1088 | for(i = 0; i < 8; i++)
|
— | — | @@ -1097,48 +1088,42 @@ |
1098 | 1089 | {
|
1099 | 1090 | if(device->gllights[i] != -1)
|
1100 | 1091 | {
|
1101 | | - lightname[5] = lightindex+'0';
|
1102 | | - memcpy((void*)(lightname+7),"diffuse",8);
|
1103 | | - loc = glGetUniformLocation(prog,lightname);
|
1104 | | - glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
|
1105 | | - memcpy((void*)(lightname+7),"specular",9);
|
1106 | | - loc = glGetUniformLocation(prog,lightname);
|
1107 | | - glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
|
1108 | | - memcpy((void*)(lightname+7),"ambient",8);
|
1109 | | - loc = glGetUniformLocation(prog,lightname);
|
1110 | | - glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
|
1111 | | - memcpy((void*)(lightname+7),"direction",10);
|
1112 | | - loc = glGetUniformLocation(prog,lightname);
|
1113 | | - glUniform3fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
|
| 1092 | + if(prog.uniforms[20+(i*12)] != -1)
|
| 1093 | + glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
|
| 1094 | + if(prog.uniforms[21+(i*12)] != -1)
|
| 1095 | + glUniform4fv(prog.uniforms[21+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
|
| 1096 | + if(prog.uniforms[22+(i*12)] != -1)
|
| 1097 | + glUniform4fv(prog.uniforms[22+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
|
| 1098 | + if(prog.uniforms[24+(i*12)] != -1)
|
| 1099 | + glUniform3fv(prog.uniforms[24+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
|
1114 | 1100 | if(device->lights[device->gllights[i]]->light.dltType != D3DLIGHT_DIRECTIONAL)
|
1115 | 1101 | {
|
1116 | | - memcpy((void*)(lightname+7),"position",9);
|
1117 | | - loc = glGetUniformLocation(prog,lightname);
|
1118 | | - glUniform3fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
|
1119 | | - memcpy((void*)(lightname+7),"range",6);
|
1120 | | - loc = glGetUniformLocation(prog,lightname);
|
1121 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvRange);
|
1122 | | - memcpy((void*)(lightname+7),"falloff",8);
|
1123 | | - loc = glGetUniformLocation(prog,lightname);
|
1124 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvFalloff);
|
1125 | | - memcpy((void*)(lightname+7),"constant",9);
|
1126 | | - loc = glGetUniformLocation(prog,lightname);
|
1127 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation0);
|
1128 | | - memcpy((void*)(lightname+7),"linear",7);
|
1129 | | - loc = glGetUniformLocation(prog,lightname);
|
1130 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation1);
|
1131 | | - memcpy((void*)(lightname+7),"quad",5);
|
1132 | | - loc = glGetUniformLocation(prog,lightname);
|
1133 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation2);
|
1134 | | - memcpy((void*)(lightname+7),"theta",6);
|
1135 | | - loc = glGetUniformLocation(prog,lightname);
|
1136 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvTheta);
|
1137 | | - memcpy((void*)(lightname+7),"Phi",4);
|
1138 | | - loc = glGetUniformLocation(prog,lightname);
|
1139 | | - glUniform1f(loc,device->lights[device->gllights[i]]->light.dvPhi);
|
| 1102 | + if(prog.uniforms[23+(i*12)] != -1)
|
| 1103 | + glUniform3fv(prog.uniforms[23+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
|
| 1104 | + if(prog.uniforms[25+(i*12)] != -1)
|
| 1105 | + glUniform1f(prog.uniforms[25+(i*12)],device->lights[device->gllights[i]]->light.dvRange);
|
| 1106 | + if(prog.uniforms[26+(i*12)] != -1)
|
| 1107 | + glUniform1f(prog.uniforms[26+(i*12)],device->lights[device->gllights[i]]->light.dvFalloff);
|
| 1108 | + if(prog.uniforms[27+(i*12)] != -1)
|
| 1109 | + glUniform1f(prog.uniforms[27+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation0);
|
| 1110 | + if(prog.uniforms[28+(i*12)] != -1)
|
| 1111 | + glUniform1f(prog.uniforms[28+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation1);
|
| 1112 | + if(prog.uniforms[29+(i*12)] != -1)
|
| 1113 | + glUniform1f(prog.uniforms[29+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation2);
|
| 1114 | + if(prog.uniforms[30+(i*12)] != -1)
|
| 1115 | + glUniform1f(prog.uniforms[30+(i*12)],device->lights[device->gllights[i]]->light.dvTheta);
|
| 1116 | + if(prog.uniforms[31+(i*12)] != -1)
|
| 1117 | + glUniform1f(prog.uniforms[31+(i*12)],device->lights[device->gllights[i]]->light.dvPhi);
|
1140 | 1118 | }
|
1141 | 1119 | }
|
| 1120 | + lightindex++;
|
1142 | 1121 | }
|
| 1122 | +
|
| 1123 | + DWORD ambient = device->renderstate[D3DRENDERSTATE_AMBIENT];
|
| 1124 | + if(prog.uniforms[136] != -1)
|
| 1125 | + glUniform4f(prog.uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
|
| 1126 | + RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
|
| 1127 | +
|
1143 | 1128 | if(device->glDDS7->zbuffer) SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
|
1144 | 1129 | else SetFBO(device->glDDS7->texture,0,false);
|
1145 | 1130 | glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
Index: ddraw/shadergen.cpp |
— | — | @@ -18,27 +18,11 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "glRenderer.h"
|
21 | 21 | #include "glDirect3DDevice.h"
|
| 22 | +#include <string>
|
| 23 | +using namespace std;
|
22 | 24 | #include "shadergen.h"
|
23 | 25 | #include "shaders.h"
|
24 | | -#include <string>
|
25 | | -using namespace std;
|
26 | 26 |
|
27 | | -typedef struct
|
28 | | -{
|
29 | | - GLint vs;
|
30 | | - GLint fs;
|
31 | | - string *vsrc;
|
32 | | - string *fsrc;
|
33 | | - GLint prog;
|
34 | | -} _GENSHADER;
|
35 | | -
|
36 | | -struct GenShader
|
37 | | -{
|
38 | | - _GENSHADER shader;
|
39 | | - __int64 id;
|
40 | | - __int64 texids[8];
|
41 | | - int texcoords[8];
|
42 | | -};
|
43 | 27 | GenShader genshaders[256];
|
44 | 28 | static __int64 current_shader = 0;
|
45 | 29 | static __int64 current_texid[8];
|
— | — | @@ -47,6 +31,7 @@ |
48 | 32 | static bool initialized = false;
|
49 | 33 | static bool isbuiltin = true;
|
50 | 34 | GLuint current_prog;
|
| 35 | +int current_genshader;
|
51 | 36 |
|
52 | 37 | /* Bits in Shader ID:
|
53 | 38 | Bits 0-1 - Shading mode: 00=flat 01=gouraud 11=phong 10=flat per-pixel
|
— | — | @@ -119,6 +104,7 @@ |
120 | 105 | if(genshaders[i].shader.vsrc) delete genshaders[i].shader.vsrc;
|
121 | 106 | ZeroMemory(&genshaders[i].shader,sizeof(_GENSHADER));
|
122 | 107 | }
|
| 108 | + current_genshader = -1;
|
123 | 109 | shadercount = 0;
|
124 | 110 | genindex = 0;
|
125 | 111 | }
|
— | — | @@ -132,6 +118,7 @@ |
133 | 119 | glUseProgram(shaders[id].prog);
|
134 | 120 | current_shader = shaders[id].prog;
|
135 | 121 | isbuiltin=true;
|
| 122 | + current_genshader = -1;
|
136 | 123 | }
|
137 | 124 | else
|
138 | 125 | {
|
— | — | @@ -179,6 +166,7 @@ |
180 | 167 | memcpy(genshaders[shaderindex].texcoords,texcoords,8*sizeof(int));
|
181 | 168 | glUseProgram(genshaders[shaderindex].shader.prog);
|
182 | 169 | current_prog = genshaders[shaderindex].shader.prog;
|
| 170 | + current_genshader = shaderindex;
|
183 | 171 | }
|
184 | 172 | }
|
185 | 173 |
|
— | — | @@ -476,4 +464,86 @@ |
477 | 465 | free(infolog);
|
478 | 466 | }
|
479 | 467 | #endif
|
| 468 | + // Attributes
|
| 469 | + genshaders[index].shader.attribs[0] = glGetAttribLocation(genshaders[index].shader.prog,"xyz");
|
| 470 | + genshaders[index].shader.attribs[1] = glGetAttribLocation(genshaders[index].shader.prog,"rhw");
|
| 471 | + genshaders[index].shader.attribs[2] = glGetAttribLocation(genshaders[index].shader.prog,"blend0");
|
| 472 | + genshaders[index].shader.attribs[3] = glGetAttribLocation(genshaders[index].shader.prog,"blend1");
|
| 473 | + genshaders[index].shader.attribs[4] = glGetAttribLocation(genshaders[index].shader.prog,"blend2");
|
| 474 | + genshaders[index].shader.attribs[5] = glGetAttribLocation(genshaders[index].shader.prog,"blend3");
|
| 475 | + genshaders[index].shader.attribs[6] = glGetAttribLocation(genshaders[index].shader.prog,"blend4");
|
| 476 | + genshaders[index].shader.attribs[7] = glGetAttribLocation(genshaders[index].shader.prog,"nxyz");
|
| 477 | + genshaders[index].shader.attribs[8] = glGetAttribLocation(genshaders[index].shader.prog,"rgba0");
|
| 478 | + genshaders[index].shader.attribs[9] = glGetAttribLocation(genshaders[index].shader.prog,"rgba1");
|
| 479 | + char attrS[] = "sX";
|
| 480 | + for(int i = 0; i < 8; i++)
|
| 481 | + {
|
| 482 | + attrS[1] = i + '0';
|
| 483 | + genshaders[index].shader.attribs[i+10] = glGetAttribLocation(genshaders[index].shader.prog,attrS);
|
| 484 | + }
|
| 485 | + char attrST[] = "stX";
|
| 486 | + for(int i = 0; i < 8; i++)
|
| 487 | + {
|
| 488 | + attrST[2] = i + '0';
|
| 489 | + genshaders[index].shader.attribs[i+18] = glGetAttribLocation(genshaders[index].shader.prog,attrST);
|
| 490 | + }
|
| 491 | + char attrSTR[] = "strX";
|
| 492 | + for(int i = 0; i < 8; i++)
|
| 493 | + {
|
| 494 | + attrSTR[3] = i + '0';
|
| 495 | + genshaders[index].shader.attribs[i+26] = glGetAttribLocation(genshaders[index].shader.prog,attrSTR);
|
| 496 | + }
|
| 497 | + char attrSTRQ[] = "strqX";
|
| 498 | + for(int i = 0; i < 8; i++)
|
| 499 | + {
|
| 500 | + attrSTRQ[4] = i + '0';
|
| 501 | + genshaders[index].shader.attribs[i+34] = glGetAttribLocation(genshaders[index].shader.prog,attrSTRQ);
|
| 502 | + }
|
| 503 | + // Uniforms
|
| 504 | + genshaders[index].shader.uniforms[0] = glGetUniformLocation(genshaders[index].shader.prog,"world");
|
| 505 | + genshaders[index].shader.uniforms[1] = glGetUniformLocation(genshaders[index].shader.prog,"view");
|
| 506 | + genshaders[index].shader.uniforms[2] = glGetUniformLocation(genshaders[index].shader.prog,"projection");
|
| 507 | + genshaders[index].shader.uniforms[3] = glGetUniformLocation(genshaders[index].shader.prog,"normalmat");
|
| 508 | + // TODO: 4-14 world1-3 and texture0-7
|
| 509 | + genshaders[index].shader.uniforms[15] = glGetUniformLocation(genshaders[index].shader.prog,"material.ambient");
|
| 510 | + genshaders[index].shader.uniforms[16] = glGetUniformLocation(genshaders[index].shader.prog,"material.diffuse");
|
| 511 | + genshaders[index].shader.uniforms[17] = glGetUniformLocation(genshaders[index].shader.prog,"material.specular");
|
| 512 | + genshaders[index].shader.uniforms[18] = glGetUniformLocation(genshaders[index].shader.prog,"material.emissive");
|
| 513 | + genshaders[index].shader.uniforms[19] = glGetUniformLocation(genshaders[index].shader.prog,"material.power");
|
| 514 | + char uniflight[] = "lightX. ";
|
| 515 | + for(int i = 0; i < 8; i++)
|
| 516 | + {
|
| 517 | + uniflight[5] = i + '0';
|
| 518 | + strcpy(uniflight+7,"diffuse");
|
| 519 | + genshaders[index].shader.uniforms[20+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 520 | + strcpy(uniflight+7,"specular");
|
| 521 | + genshaders[index].shader.uniforms[21+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 522 | + strcpy(uniflight+7,"ambient");
|
| 523 | + genshaders[index].shader.uniforms[22+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 524 | + strcpy(uniflight+7,"position");
|
| 525 | + genshaders[index].shader.uniforms[23+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 526 | + strcpy(uniflight+7,"direction");
|
| 527 | + genshaders[index].shader.uniforms[24+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 528 | + strcpy(uniflight+7,"range");
|
| 529 | + genshaders[index].shader.uniforms[25+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 530 | + strcpy(uniflight+7,"falloff");
|
| 531 | + genshaders[index].shader.uniforms[26+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 532 | + strcpy(uniflight+7,"constant");
|
| 533 | + genshaders[index].shader.uniforms[27+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 534 | + strcpy(uniflight+7,"linear");
|
| 535 | + genshaders[index].shader.uniforms[28+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 536 | + strcpy(uniflight+7,"quad");
|
| 537 | + genshaders[index].shader.uniforms[29+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 538 | + strcpy(uniflight+7,"theta");
|
| 539 | + genshaders[index].shader.uniforms[30+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 540 | + strcpy(uniflight+7,"phi");
|
| 541 | + genshaders[index].shader.uniforms[31+(i*12)] = glGetUniformLocation(genshaders[index].shader.prog,uniflight);
|
| 542 | + }
|
| 543 | + char uniftex[] = "texX";
|
| 544 | + for(int i = 0; i < 8; i++)
|
| 545 | + {
|
| 546 | + uniftex[3] = i + '0';
|
| 547 | + genshaders[index].shader.uniforms[128+i] = glGetUniformLocation(genshaders[index].shader.prog,uniftex);
|
| 548 | + }
|
| 549 | + genshaders[index].shader.uniforms[136] = glGetUniformLocation(genshaders[index].shader.prog,"ambientcolor");
|
480 | 550 | }
|
Index: ddraw/shadergen.h |
— | — | @@ -18,10 +18,30 @@ |
19 | 19 | #ifndef _SHADERGEN_H
|
20 | 20 | #define _SHADERGEN_H
|
21 | 21 |
|
| 22 | +typedef struct
|
| 23 | +{
|
| 24 | + GLint vs;
|
| 25 | + GLint fs;
|
| 26 | + string *vsrc;
|
| 27 | + string *fsrc;
|
| 28 | + GLint prog;
|
| 29 | + GLint attribs[42];
|
| 30 | + GLint uniforms[256];
|
| 31 | +} _GENSHADER;
|
| 32 | +
|
| 33 | +struct GenShader
|
| 34 | +{
|
| 35 | + _GENSHADER shader;
|
| 36 | + __int64 id;
|
| 37 | + __int64 texids[8];
|
| 38 | + int texcoords[8];
|
| 39 | +};
|
| 40 | +
|
22 | 41 | void ClearShaders();
|
23 | 42 | void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, bool builtin);
|
24 | 43 | GLuint GetProgram();
|
25 | 44 | void ZeroShaderArray();
|
26 | 45 | void CreateShader(int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords);
|
27 | | -
|
| 46 | +extern GenShader genshaders[256];
|
| 47 | +extern int current_genshader;
|
28 | 48 | #endif |
\ No newline at end of file |
Index: ddraw/shaders.cpp |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "glRenderer.h"
|
21 | 21 | #include "glDirect3DDevice.h"
|
| 22 | +#include <string>
|
| 23 | +using namespace std;
|
22 | 24 | #include "shaders.h"
|
23 | 25 | #include "shadergen.h"
|
24 | 26 |
|