Index: ddraw/glDirect3DDevice.h |
— | — | @@ -97,10 +97,10 @@ |
98 | 98 | D3DVIEWPORT7 viewport;
|
99 | 99 | glDirect3DLight **lights;
|
100 | 100 | int gllights[8];
|
| 101 | + glDirectDrawSurface7 *glDDS7;
|
101 | 102 |
|
102 | 103 | private:
|
103 | 104 | glDirect3D7 *glD3D7;
|
104 | | - glDirectDrawSurface7 *glDDS7;
|
105 | 105 | ULONG refcount;
|
106 | 106 | DWORD renderstate[153];
|
107 | 107 | GLuint gltextures[8];
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -128,6 +128,7 @@ |
129 | 129 | DDSURFACEDESC2 ddsd;
|
130 | 130 | glDirectDrawPalette *palette;
|
131 | 131 | HGLRC hRC;
|
| 132 | + glDirectDrawSurface7 *zbuffer;
|
132 | 133 | private:
|
133 | 134 | ULONG refcount;
|
134 | 135 | int locked;
|
— | — | @@ -137,7 +138,6 @@ |
138 | 139 | glDirectDraw7 *ddInterface;
|
139 | 140 | int surfacetype; // 0-generic memory, 1-GDI surface, 2-OpenGL Texture
|
140 | 141 | glDirectDrawSurface7 *backbuffer;
|
141 | | - glDirectDrawSurface7 *zbuffer;
|
142 | 142 | glDirectDrawClipper *clipper;
|
143 | 143 | int pagelocked;
|
144 | 144 | GLint filter;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -735,8 +735,11 @@ |
736 | 736 | glEnableVertexAttribArray(xyloc);
|
737 | 737 | glVertexAttribPointer(xyloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
|
738 | 738 | GLint rgbloc = glGetAttribLocation(prog,"rgb");
|
739 | | - glEnableVertexAttribArray(rgbloc);
|
740 | | - glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
|
| 739 | + if(rgbloc != -1)
|
| 740 | + {
|
| 741 | + glEnableVertexAttribArray(rgbloc);
|
| 742 | + glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
|
| 743 | + }
|
741 | 744 | if(!(dwFlags & DDBLT_COLORFILL))
|
742 | 745 | {
|
743 | 746 | GLint stloc = glGetAttribLocation(prog,"st");
|
— | — | @@ -928,8 +931,11 @@ |
929 | 932 | glEnableVertexAttribArray(stloc);
|
930 | 933 | glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
|
931 | 934 | GLint rgbloc = glGetAttribLocation(prog,"rgb");
|
932 | | - glEnableVertexAttribArray(rgbloc);
|
933 | | - glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
|
| 935 | + if(rgbloc != -1)
|
| 936 | + {
|
| 937 | + glEnableVertexAttribArray(rgbloc);
|
| 938 | + glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
|
| 939 | + }
|
934 | 940 | glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
935 | 941 | glDisable(GL_TEXTURE_2D);
|
936 | 942 | glFlush();
|
— | — | @@ -1092,8 +1098,31 @@ |
1093 | 1099 | colorptr[1] = ptr;
|
1094 | 1100 | ptr++;
|
1095 | 1101 | }
|
| 1102 | + int numtex = (dwVertexTypeDesc&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT;
|
| 1103 | + for(i = 0; i < numtex; i++)
|
| 1104 | + {
|
| 1105 | + texptr[0] = ptr;
|
| 1106 | + switch(dwVertexTypeDesc>>(16+(2*i))&3)
|
| 1107 | + {
|
| 1108 | + case 0: // st
|
| 1109 | + ptr += 2;
|
| 1110 | + break;
|
| 1111 | + case 1: // str
|
| 1112 | + ptr += 3;
|
| 1113 | + break;
|
| 1114 | + case 2: // strq
|
| 1115 | + ptr += 4;
|
| 1116 | + break;
|
| 1117 | + case 3: // s
|
| 1118 | + ptr++;
|
| 1119 | + break;
|
| 1120 | + }
|
| 1121 | + }
|
1096 | 1122 | int stride = NextMultipleOf8(ptr*4);
|
1097 | | - SetShader(device->SelectShader(dwVertexTypeDesc),NULL,0);
|
| 1123 | + TexState texstage;
|
| 1124 | + ZeroMemory(&texstage,sizeof(TexState));
|
| 1125 | + __int64 shader = device->SelectShader(dwVertexTypeDesc);
|
| 1126 | + SetShader(shader,&texstage,0);
|
1098 | 1127 | GLuint prog = GetProgram();
|
1099 | 1128 | if(transformed)
|
1100 | 1129 | {
|
— | — | @@ -1139,19 +1168,19 @@ |
1140 | 1169 | loc = glGetUniformLocation(prog,"view");
|
1141 | 1170 | glUniformMatrix4fv(loc,1,false,device->matView);
|
1142 | 1171 | loc = glGetUniformLocation(prog,"projection");
|
1143 | | - glUniformMatrix4fv(loc,1,false,device->matProjection);
|
| 1172 | + glUniformMatrix4fv(loc,1,true,device->matProjection);
|
1144 | 1173 | loc = glGetUniformLocation(prog,"normalmat");
|
1145 | 1174 | glUniformMatrix4fv(loc,1,true,device->matNormal);
|
1146 | 1175 | loc = glGetUniformLocation(prog,"material.diffuse");
|
1147 | | - glUniform4fv(prog,4,(GLfloat*)&device->material.diffuse);
|
| 1176 | + glUniform4fv(loc,1,(GLfloat*)&device->material.diffuse);
|
1148 | 1177 | loc = glGetUniformLocation(prog,"material.ambient");
|
1149 | | - glUniform4fv(prog,4,(GLfloat*)&device->material.ambient);
|
| 1178 | + glUniform4fv(loc,1,(GLfloat*)&device->material.ambient);
|
1150 | 1179 | loc = glGetUniformLocation(prog,"material.specular");
|
1151 | | - glUniform4fv(prog,4,(GLfloat*)&device->material.specular);
|
| 1180 | + glUniform4fv(loc,1,(GLfloat*)&device->material.specular);
|
1152 | 1181 | loc = glGetUniformLocation(prog,"material.emissive");
|
1153 | | - glUniform4fv(prog,4,(GLfloat*)&device->material.emissive);
|
| 1182 | + glUniform4fv(loc,1,(GLfloat*)&device->material.emissive);
|
1154 | 1183 | loc = glGetUniformLocation(prog,"material.power");
|
1155 | | - glUniform1f(prog,device->material.power);
|
| 1184 | + glUniform1f(loc,device->material.power);
|
1156 | 1185 | int lightindex = 0;
|
1157 | 1186 | char lightname[] = "lightX.xxxxxxxxxxxxxxxx";
|
1158 | 1187 | for(i = 0; i < 8; i++)
|
— | — | @@ -1159,21 +1188,52 @@ |
1160 | 1189 | if(device->gllights[i] != -1)
|
1161 | 1190 | {
|
1162 | 1191 | lightname[5] = lightindex+'0';
|
1163 | | - memcpy((void*)(lightindex+7),"diffuse",8);
|
| 1192 | + memcpy((void*)(lightname+7),"diffuse",8);
|
1164 | 1193 | loc = glGetUniformLocation(prog,lightname);
|
1165 | | - glUniform4fv(prog,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
|
1166 | | - memcpy((void*)(lightindex+7),"specular",9);
|
| 1194 | + glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
|
| 1195 | + memcpy((void*)(lightname+7),"specular",9);
|
1167 | 1196 | loc = glGetUniformLocation(prog,lightname);
|
1168 | | - glUniform4fv(prog,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
|
1169 | | - memcpy((void*)(lightindex+7),"ambient",8);
|
| 1197 | + glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
|
| 1198 | + memcpy((void*)(lightname+7),"ambient",8);
|
1170 | 1199 | loc = glGetUniformLocation(prog,lightname);
|
1171 | | - glUniform4fv(prog,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
|
| 1200 | + glUniform4fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
|
| 1201 | + memcpy((void*)(lightname+7),"direction",10);
|
| 1202 | + loc = glGetUniformLocation(prog,lightname);
|
| 1203 | + glUniform3fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
|
| 1204 | + if(device->lights[device->gllights[i]]->light.dltType != D3DLIGHT_DIRECTIONAL)
|
| 1205 | + {
|
| 1206 | + memcpy((void*)(lightname+7),"position",9);
|
| 1207 | + loc = glGetUniformLocation(prog,lightname);
|
| 1208 | + glUniform3fv(loc,1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
|
| 1209 | + memcpy((void*)(lightname+7),"range",6);
|
| 1210 | + loc = glGetUniformLocation(prog,lightname);
|
| 1211 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvRange);
|
| 1212 | + memcpy((void*)(lightname+7),"falloff",8);
|
| 1213 | + loc = glGetUniformLocation(prog,lightname);
|
| 1214 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvFalloff);
|
| 1215 | + memcpy((void*)(lightname+7),"constant",9);
|
| 1216 | + loc = glGetUniformLocation(prog,lightname);
|
| 1217 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation0);
|
| 1218 | + memcpy((void*)(lightname+7),"linear",7);
|
| 1219 | + loc = glGetUniformLocation(prog,lightname);
|
| 1220 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation1);
|
| 1221 | + memcpy((void*)(lightname+7),"quad",5);
|
| 1222 | + loc = glGetUniformLocation(prog,lightname);
|
| 1223 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvAttenuation2);
|
| 1224 | + memcpy((void*)(lightname+7),"theta",6);
|
| 1225 | + loc = glGetUniformLocation(prog,lightname);
|
| 1226 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvTheta);
|
| 1227 | + memcpy((void*)(lightname+7),"Phi",4);
|
| 1228 | + loc = glGetUniformLocation(prog,lightname);
|
| 1229 | + glUniform1f(loc,device->lights[device->gllights[i]]->light.dvPhi);
|
| 1230 | + }
|
1172 | 1231 | }
|
1173 | 1232 | }
|
1174 | | - // Uniforms
|
1175 | | - // struct Light vec3 position,direction float range,falloff,constant,linear,quad,theta,pi uniform lightX
|
1176 | | - FIXME("glDirect3DDevice::DrawIndexedPrimitive: stub");
|
1177 | | - outputs[0] = (void*)DDERR_GENERIC;
|
| 1233 | + SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
|
| 1234 | + glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
| 1235 | + glDrawRangeElements(drawmode,0,dwIndexCount,dwVertexCount,GL_UNSIGNED_SHORT,lpwIndices);
|
| 1236 | + if(dwFlags & D3DDP_WAIT) glFlush();
|
| 1237 | + outputs[0] = (void*)D3D_OK;
|
1178 | 1238 | wndbusy = false;
|
1179 | 1239 | return;
|
1180 | 1240 | }
|
Index: dxgltest/Tests3D.cpp |
— | — | @@ -443,6 +443,7 @@ |
444 | 444 |
|
445 | 445 | void RunTestTimed3D(int test)
|
446 | 446 | {
|
| 447 | + if(!d3d7dev) return;
|
447 | 448 | POINT p;
|
448 | 449 | RECT srcrect,destrect;
|
449 | 450 | HRESULT error;
|