| Index: ddraw/glDirect3DDevice.cpp |
| — | — | @@ -145,8 +145,10 @@ |
| 146 | 146 | 0,
|
| 147 | 147 | D3DTTFF_DISABLE,
|
| 148 | 148 | NULL,
|
| | 149 | + false,
|
| 149 | 150 | 0,
|
| 150 | | - 0
|
| | 151 | + GL_NEAREST,
|
| | 152 | + GL_NEAREST
|
| 151 | 153 | };
|
| 152 | 154 | const TEXTURESTAGE texstagedefault1 =
|
| 153 | 155 | {
|
| — | — | @@ -995,16 +997,101 @@ |
| 996 | 998 | if(!dwValue || (dwValue > 5)) return DDERR_INVALIDPARAMS;
|
| 997 | 999 | texstages[dwStage].magfilter = (D3DTEXTUREMAGFILTER)dwValue;
|
| 998 | 1000 | texstages[dwStage].dirty = true;
|
| | 1001 | + switch(texstages[dwStage].magfilter)
|
| | 1002 | + {
|
| | 1003 | + case 1:
|
| | 1004 | + default:
|
| | 1005 | + texstages[dwStage].glmagfilter = GL_NEAREST;
|
| | 1006 | + break;
|
| | 1007 | + case 2:
|
| | 1008 | + case 3:
|
| | 1009 | + case 4:
|
| | 1010 | + case 5:
|
| | 1011 | + texstages[dwStage].glmagfilter = GL_LINEAR;
|
| | 1012 | + break;
|
| | 1013 | + }
|
| 999 | 1014 | return D3D_OK;
|
| 1000 | 1015 | case D3DTSS_MINFILTER:
|
| 1001 | 1016 | if(!dwValue || (dwValue > 3)) return DDERR_INVALIDPARAMS;
|
| 1002 | 1017 | texstages[dwStage].minfilter = (D3DTEXTUREMINFILTER)dwValue;
|
| 1003 | 1018 | texstages[dwStage].dirty = true;
|
| | 1019 | + switch(texstages[dwStage].minfilter)
|
| | 1020 | + {
|
| | 1021 | + case 1:
|
| | 1022 | + default:
|
| | 1023 | + switch(texstages[dwStage].mipfilter)
|
| | 1024 | + {
|
| | 1025 | + case 1:
|
| | 1026 | + default:
|
| | 1027 | + texstages[dwStage].glminfilter = GL_NEAREST;
|
| | 1028 | + break;
|
| | 1029 | + case 2:
|
| | 1030 | + texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
| | 1031 | + break;
|
| | 1032 | + case 3:
|
| | 1033 | + texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
| | 1034 | + break;
|
| | 1035 | + }
|
| | 1036 | + break;
|
| | 1037 | + case 2:
|
| | 1038 | + case 3:
|
| | 1039 | + switch(texstages[dwStage].mipfilter)
|
| | 1040 | + {
|
| | 1041 | + case 1:
|
| | 1042 | + default:
|
| | 1043 | + texstages[dwStage].glminfilter = GL_LINEAR;
|
| | 1044 | + break;
|
| | 1045 | + case 2:
|
| | 1046 | + texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
| | 1047 | + break;
|
| | 1048 | + case 3:
|
| | 1049 | + texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
| | 1050 | + break;
|
| | 1051 | + }
|
| | 1052 | + break;
|
| | 1053 | + }
|
| 1004 | 1054 | return D3D_OK;
|
| 1005 | 1055 | case D3DTSS_MIPFILTER:
|
| 1006 | 1056 | if(!dwValue || (dwValue > 3)) return DDERR_INVALIDPARAMS;
|
| 1007 | 1057 | texstages[dwStage].mipfilter = (D3DTEXTUREMIPFILTER)dwValue;
|
| 1008 | 1058 | texstages[dwStage].dirty = true;
|
| | 1059 | + switch(texstages[dwStage].mipfilter)
|
| | 1060 | + {
|
| | 1061 | + case 1:
|
| | 1062 | + default:
|
| | 1063 | + switch(texstages[dwStage].minfilter)
|
| | 1064 | + {
|
| | 1065 | + case 1:
|
| | 1066 | + default:
|
| | 1067 | + texstages[dwStage].glminfilter = GL_NEAREST;
|
| | 1068 | + case 2:
|
| | 1069 | + case 3:
|
| | 1070 | + texstages[dwStage].glminfilter = GL_LINEAR;
|
| | 1071 | + }
|
| | 1072 | + break;
|
| | 1073 | + case 2:
|
| | 1074 | + switch(texstages[dwStage].minfilter)
|
| | 1075 | + {
|
| | 1076 | + case 1:
|
| | 1077 | + default:
|
| | 1078 | + texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_NEAREST;
|
| | 1079 | + case 2:
|
| | 1080 | + case 3:
|
| | 1081 | + texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_NEAREST;
|
| | 1082 | + }
|
| | 1083 | + break;
|
| | 1084 | + case 3:
|
| | 1085 | + switch(texstages[dwStage].minfilter)
|
| | 1086 | + {
|
| | 1087 | + case 1:
|
| | 1088 | + default:
|
| | 1089 | + texstages[dwStage].glminfilter = GL_NEAREST_MIPMAP_LINEAR;
|
| | 1090 | + case 2:
|
| | 1091 | + case 3:
|
| | 1092 | + texstages[dwStage].glminfilter = GL_LINEAR_MIPMAP_LINEAR;
|
| | 1093 | + }
|
| | 1094 | + break;
|
| | 1095 | + }
|
| 1009 | 1096 | return D3D_OK;
|
| 1010 | 1097 | case D3DTSS_MIPMAPLODBIAS:
|
| 1011 | 1098 | memcpy(&texstages[dwStage].lodbias,&dwValue,sizeof(D3DVALUE));
|
| Index: ddraw/glDirect3DDevice.h |
| — | — | @@ -50,6 +50,8 @@ |
| 51 | 51 | glDirectDrawSurface7 *texture;
|
| 52 | 52 | bool dirty;
|
| 53 | 53 | __int64 shaderid;
|
| | 54 | + GLint glmagfilter;
|
| | 55 | + GLint glminfilter;
|
| 54 | 56 | };
|
| 55 | 57 |
|
| 56 | 58 | class glDirect3DLight;
|
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -56,7 +56,7 @@ |
| 57 | 57 | bigbuffer = NULL;
|
| 58 | 58 | zbuffer = NULL;
|
| 59 | 59 | DWORD colormasks[3];
|
| 60 | | - filter = GL_NEAREST;
|
| | 60 | + magfilter = minfilter = GL_NEAREST;
|
| 61 | 61 | if(copysurface)
|
| 62 | 62 | {
|
| 63 | 63 | FIXME("glDirectDrawSurface7::glDirectDrawSurface7: copy surface stub\n");
|
| — | — | @@ -197,8 +197,8 @@ |
| 198 | 198 | case 2:
|
| 199 | 199 | maketex:
|
| 200 | 200 | buffer = NULL;
|
| 201 | | - if((dxglcfg.scalingfilter == 0) || (ddInterface->GetBPP() == 8)) filter = GL_NEAREST;
|
| 202 | | - else filter = GL_LINEAR;
|
| | 201 | + if((dxglcfg.scalingfilter == 0) || (ddInterface->GetBPP() == 8)) magfilter = minfilter = GL_NEAREST;
|
| | 202 | + else magfilter = minfilter = GL_LINEAR;
|
| 203 | 203 | if(ddsd.dwFlags & DDSD_PIXELFORMAT)
|
| 204 | 204 | {
|
| 205 | 205 | if(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)
|
| — | — | @@ -388,7 +388,7 @@ |
| 389 | 389 | return;
|
| 390 | 390 | }
|
| 391 | 391 | }
|
| 392 | | - texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| | 392 | + texture = renderer->MakeTexture(minfilter,magfilter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| 393 | 393 | }
|
| 394 | 394 |
|
| 395 | 395 | if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
|
| — | — | @@ -973,7 +973,7 @@ |
| 974 | 974 | if(backbuffer) backbuffer->Restore2();
|
| 975 | 975 | if(zbuffer) zbuffer->Restore2();
|
| 976 | 976 | if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
|
| 977 | | - texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| | 977 | + texture = renderer->MakeTexture(minfilter,magfilter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| 978 | 978 | }
|
| 979 | 979 | }
|
| 980 | 980 | HRESULT WINAPI glDirectDrawSurface7::Restore()
|
| — | — | @@ -1017,7 +1017,7 @@ |
| 1018 | 1018 | if(zbuffer) zbuffer->Restore();
|
| 1019 | 1019 | }
|
| 1020 | 1020 | if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
|
| 1021 | | - texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| | 1021 | + texture = renderer->MakeTexture(minfilter,magfilter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
|
| 1022 | 1022 | return DD_OK;
|
| 1023 | 1023 | }
|
| 1024 | 1024 | else return DD_OK;
|
| — | — | @@ -1190,6 +1190,47 @@ |
| 1191 | 1191 | if(!this) return DDERR_INVALIDPARAMS;
|
| 1192 | 1192 | return Unlock((LPRECT)lpSurfaceData);
|
| 1193 | 1193 | }
|
| | 1194 | +void glDirectDrawSurface7::SetFilter(int level, GLint mag, GLint min)
|
| | 1195 | +{
|
| | 1196 | + switch(dxglcfg.texfilter)
|
| | 1197 | + {
|
| | 1198 | + default:
|
| | 1199 | + break;
|
| | 1200 | + case 1:
|
| | 1201 | + mag = min = GL_NEAREST;
|
| | 1202 | + break;
|
| | 1203 | + case 2:
|
| | 1204 | + mag = min = GL_LINEAR;
|
| | 1205 | + break;
|
| | 1206 | + case 3:
|
| | 1207 | + mag = GL_NEAREST;
|
| | 1208 | + min = GL_NEAREST_MIPMAP_NEAREST;
|
| | 1209 | + break;
|
| | 1210 | + case 4:
|
| | 1211 | + mag = GL_NEAREST;
|
| | 1212 | + min = GL_NEAREST_MIPMAP_LINEAR;
|
| | 1213 | + break;
|
| | 1214 | + case 5:
|
| | 1215 | + mag = GL_LINEAR;
|
| | 1216 | + min = GL_LINEAR_MIPMAP_NEAREST;
|
| | 1217 | + break;
|
| | 1218 | + case 6:
|
| | 1219 | + mag = GL_LINEAR;
|
| | 1220 | + min = GL_LINEAR_MIPMAP_LINEAR;
|
| | 1221 | + break;
|
| | 1222 | + }
|
| | 1223 | + if((magfilter != mag) || (minfilter != min)) ::SetTexture(level,texture);
|
| | 1224 | + if(magfilter != mag)
|
| | 1225 | + {
|
| | 1226 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mag);
|
| | 1227 | + magfilter = mag;
|
| | 1228 | + }
|
| | 1229 | + if(minfilter != min)
|
| | 1230 | + {
|
| | 1231 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,min);
|
| | 1232 | + minfilter = min;
|
| | 1233 | + }
|
| | 1234 | +}
|
| 1194 | 1235 |
|
| 1195 | 1236 | // DDRAW1 wrapper
|
| 1196 | 1237 | glDirectDrawSurface1::glDirectDrawSurface1(glDirectDrawSurface7 *gl_DDS7)
|
| Index: ddraw/glDirectDrawSurface.h |
| — | — | @@ -92,6 +92,7 @@ |
| 93 | 93 | HRESULT WINAPI GetPriority(LPDWORD lpdwPriority);
|
| 94 | 94 | HRESULT WINAPI SetLOD(DWORD dwMaxLOD);
|
| 95 | 95 | HRESULT WINAPI GetLOD(LPDWORD lpdwMaxLOD);
|
| | 96 | + void SetFilter(int level, GLint mag, GLint min);
|
| 96 | 97 | // internal functions
|
| 97 | 98 | GLuint GetTexture(){
|
| 98 | 99 | return texture;
|
| — | — | @@ -140,7 +141,7 @@ |
| 141 | 142 | glDirectDrawSurface7 *backbuffer;
|
| 142 | 143 | glDirectDrawClipper *clipper;
|
| 143 | 144 | int pagelocked;
|
| 144 | | - GLint filter;
|
| | 145 | + GLint magfilter,minfilter;
|
| 145 | 146 | };
|
| 146 | 147 |
|
| 147 | 148 | // Legacy DDRAW Interfaces
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -1053,7 +1053,6 @@ |
| 1054 | 1054 | }
|
| 1055 | 1055 | for(i = 0; i < 2; i++)
|
| 1056 | 1056 | {
|
| 1057 | | - GLint colorloc;
|
| 1058 | 1057 | if(vertices[i+8].data)
|
| 1059 | 1058 | {
|
| 1060 | 1059 | if(prog.attribs[8+i] != -1)
|
| — | — | @@ -1159,6 +1158,8 @@ |
| 1160 | 1159 | device->texstages[i].texture->texformat2,device->texstages[i].texture->texformat3);
|
| 1161 | 1160 | device->texstages[i].texture->dirty &= ~1;
|
| 1162 | 1161 | }
|
| | 1162 | + if(device->texstages[i].texture)
|
| | 1163 | + device->texstages[i].texture->SetFilter(i,device->texstages[i].glmagfilter,device->texstages[i].glminfilter);
|
| 1163 | 1164 | SetTexture(i,device->texstages[i].texture->texture);
|
| 1164 | 1165 | }
|
| 1165 | 1166 | else SetTexture(i,0);
|