| Index: ReadMe.txt |
| — | — | @@ -1,4 +1,4 @@ |
| 2 | | -DXGL 0.5.0
|
| | 2 | +DXGL 0.5.1
|
| 3 | 3 | http://www.williamfeely.info/wiki/DXGL
|
| 4 | 4 |
|
| 5 | 5 | == Introduction ==
|
| — | — | @@ -35,7 +35,7 @@ |
| 36 | 36 | * 8-bit color emulated with GLSL shader
|
| 37 | 37 |
|
| 38 | 38 | What partially works:
|
| 39 | | -* 3D graphics are only partially supported, and only advertised in Debug builds.
|
| | 39 | +* 3D graphics are only partially supported.
|
| 40 | 40 |
|
| 41 | 41 | What doesn't work:
|
| 42 | 42 | * Many functions are stubbed out and return an error
|
| Index: common/releasever.h |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 |
|
| 6 | 6 | #define DXGLMAJORVER 0
|
| 7 | 7 | #define DXGLMINORVER 5
|
| 8 | | -#define DXGLPOINTVER 0
|
| | 8 | +#define DXGLPOINTVER 1
|
| 9 | 9 |
|
| 10 | 10 | #define STR2(x) #x
|
| 11 | 11 | #define STR(x) STR2(x)
|
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -1409,19 +1409,30 @@ |
| 1410 | 1410 | min = GL_LINEAR_MIPMAP_LINEAR;
|
| 1411 | 1411 | break;
|
| 1412 | 1412 | }
|
| 1413 | | - if(GLEXT_EXT_direct_state_access)
|
| | 1413 | + if(GLEXT_ARB_sampler_objects)
|
| 1414 | 1414 | {
|
| 1415 | | - glTextureParameteriEXT(texture->id,GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mag);
|
| 1416 | | - glTextureParameteriEXT(texture->id,GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,min);
|
| | 1415 | + glSamplerParameteri(samplers[level].id,GL_TEXTURE_MAG_FILTER,mag);
|
| | 1416 | + glSamplerParameteri(samplers[level].id,GL_TEXTURE_MIN_FILTER,min);
|
| 1417 | 1417 | }
|
| 1418 | 1418 | else
|
| 1419 | 1419 | {
|
| 1420 | | - ::SetTexture(level,texture);
|
| 1421 | | - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mag);
|
| 1422 | | - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,min);
|
| | 1420 | + if(GLEXT_EXT_direct_state_access)
|
| | 1421 | + {
|
| | 1422 | + glTextureParameteriEXT(texture->id,GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mag);
|
| | 1423 | + glTextureParameteriEXT(texture->id,GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,min);
|
| | 1424 | + }
|
| | 1425 | + else
|
| | 1426 | + {
|
| | 1427 | + ::SetTexture(level,texture);
|
| | 1428 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mag);
|
| | 1429 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,min);
|
| | 1430 | + }
|
| 1423 | 1431 | }
|
| 1424 | | - magfilter = mag;
|
| 1425 | | - minfilter = min;
|
| | 1432 | + if(this)
|
| | 1433 | + {
|
| | 1434 | + magfilter = mag;
|
| | 1435 | + minfilter = min;
|
| | 1436 | + }
|
| 1426 | 1437 | TRACE_EXIT(0,0);
|
| 1427 | 1438 | }
|
| 1428 | 1439 |
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -631,6 +631,7 @@ |
| 632 | 632 | if(dib.hdc) DeleteDC(dib.hdc);
|
| 633 | 633 | ZeroMemory(&dib,sizeof(DIB));
|
| 634 | 634 | }
|
| | 635 | + DeleteSamplers();
|
| 635 | 636 | DeleteShaders();
|
| 636 | 637 | ::DeleteFBO(&fbo);
|
| 637 | 638 | if(PBO)
|
| — | — | @@ -838,6 +839,7 @@ |
| 839 | 840 | glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
|
| 840 | 841 | glBufferData(GL_PIXEL_PACK_BUFFER,width*height*4,NULL,GL_STREAM_READ);
|
| 841 | 842 | glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
|
| | 843 | + InitSamplers();
|
| 842 | 844 | TRACE_SYSINFO();
|
| 843 | 845 | return TRUE;
|
| 844 | 846 | }
|
| — | — | @@ -962,7 +964,15 @@ |
| 963 | 965 | progtype = PROG_TEXTURE;
|
| 964 | 966 | glUniform1i(shaders[progtype].tex0,0);
|
| 965 | 967 | }
|
| 966 | | - if(src) SetTexture(0,src->GetTexture());
|
| | 968 | + if(src)
|
| | 969 | + {
|
| | 970 | + SetTexture(0,src->GetTexture());
|
| | 971 | + if(GLEXT_ARB_sampler_objects)
|
| | 972 | + {
|
| | 973 | + if((dxglcfg.scalingfilter == 0) || (ddInterface->GetBPP() == 8)) src->SetFilter(0,GL_NEAREST,GL_NEAREST);
|
| | 974 | + else src->SetFilter(0,GL_LINEAR,GL_LINEAR);
|
| | 975 | + }
|
| | 976 | + }
|
| 967 | 977 | else SetTexture(0,NULL);
|
| 968 | 978 | glUniform4f(shaders[progtype].view,0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
|
| 969 | 979 | dest->dirty |= 2;
|
| — | — | @@ -1028,6 +1038,7 @@ |
| 1029 | 1039 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
| 1030 | 1040 | SetTexture(0,*texture);
|
| 1031 | 1041 | *texture = backbuffer;
|
| | 1042 | + if(GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR);
|
| 1032 | 1043 | glUniform4f(shaders[progtype].view,view[0],view[1],view[2],view[3]);
|
| 1033 | 1044 | bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
|
| 1034 | 1045 | bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
|
| — | — | @@ -1122,6 +1133,7 @@ |
| 1123 | 1134 | SetTexture(0,texture);
|
| 1124 | 1135 | glUniform1i(shaders[progtype].tex0,0);
|
| 1125 | 1136 | }
|
| | 1137 | + if(GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(1,GL_NEAREST,GL_NEAREST);
|
| 1126 | 1138 | }
|
| 1127 | 1139 | else
|
| 1128 | 1140 | {
|
| Index: ddraw/glutil.cpp |
| — | — | @@ -214,9 +214,31 @@ |
| 215 | 215 | {
|
| 216 | 216 | texwrap[level*2+coord] = wrapmode;
|
| 217 | 217 | //int currtexture = texlevel;
|
| 218 | | - SetActiveTexture(level);
|
| 219 | | - if(coord) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,wrapmode);
|
| 220 | | - else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,wrapmode);
|
| | 218 | + if(GLEXT_ARB_sampler_objects)
|
| | 219 | + {
|
| | 220 | + if(coord)
|
| | 221 | + {
|
| | 222 | + if(samplers[level].wrapt != wrapmode)
|
| | 223 | + {
|
| | 224 | + glSamplerParameteri(samplers[level].id,GL_TEXTURE_WRAP_T,wrapmode);
|
| | 225 | + samplers[level].wrapt = wrapmode;
|
| | 226 | + }
|
| | 227 | + }
|
| | 228 | + else
|
| | 229 | + {
|
| | 230 | + if(samplers[level].wraps != wrapmode)
|
| | 231 | + {
|
| | 232 | + glSamplerParameteri(samplers[level].id,GL_TEXTURE_WRAP_S,wrapmode);
|
| | 233 | + samplers[level].wraps = wrapmode;
|
| | 234 | + }
|
| | 235 | + }
|
| | 236 | + }
|
| | 237 | + else
|
| | 238 | + {
|
| | 239 | + SetActiveTexture(level);
|
| | 240 | + if(coord) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,wrapmode);
|
| | 241 | + else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,wrapmode);
|
| | 242 | + }
|
| 221 | 243 | //SetActiveTexture(currtexture);
|
| 222 | 244 | }
|
| 223 | 245 | }
|
| Index: ddraw/texture.cpp |
| — | — | @@ -51,6 +51,37 @@ |
| 52 | 52 | GLint texlevel = 0;
|
| 53 | 53 | GLuint textures[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
| 54 | 54 |
|
| | 55 | +SAMPLER samplers[8];
|
| | 56 | +
|
| | 57 | +void InitSamplers()
|
| | 58 | +{
|
| | 59 | + if(GLEXT_ARB_sampler_objects)
|
| | 60 | + {
|
| | 61 | + memset(samplers,0,8*sizeof(SAMPLER));
|
| | 62 | + for(int i = 0; i < 8; i++)
|
| | 63 | + {
|
| | 64 | + glGenSamplers(1,&samplers[i].id);
|
| | 65 | + glBindSampler(i,samplers[i].id);
|
| | 66 | + glSamplerParameteri(samplers[i].id,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
|
| | 67 | + glSamplerParameteri(samplers[i].id,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
|
| | 68 | + glSamplerParameteri(samplers[i].id,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
| | 69 | + glSamplerParameteri(samplers[i].id,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
| | 70 | + }
|
| | 71 | + }
|
| | 72 | +}
|
| | 73 | +void DeleteSamplers()
|
| | 74 | +{
|
| | 75 | + if(GLEXT_ARB_sampler_objects)
|
| | 76 | + {
|
| | 77 | + for(int i = 0; i < 8; i++)
|
| | 78 | + {
|
| | 79 | + glBindSampler(i,0);
|
| | 80 | + glDeleteSamplers(1,&samplers[i].id);
|
| | 81 | + samplers[i].id = 0;
|
| | 82 | + }
|
| | 83 | + }
|
| | 84 | +}
|
| | 85 | +
|
| 55 | 86 | void CreateTextureClassic(TEXTURE *texture, int width, int height)
|
| 56 | 87 | {
|
| 57 | 88 | int texformat = -1;
|
| — | — | @@ -258,7 +289,7 @@ |
| 259 | 290 |
|
| 260 | 291 |
|
| 261 | 292 |
|
| 262 | | -/*
|
| | 293 | +/* old code
|
| 263 | 294 | if(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)
|
| 264 | 295 | {
|
| 265 | 296 | switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
| Index: ddraw/texture.h |
| — | — | @@ -37,6 +37,19 @@ |
| 38 | 38 | DDPIXELFORMAT pixelformat;
|
| 39 | 39 | } TEXTURE;
|
| 40 | 40 |
|
| | 41 | +typedef struct
|
| | 42 | +{
|
| | 43 | + GLuint id;
|
| | 44 | + GLint wraps;
|
| | 45 | + GLint wrapt;
|
| | 46 | + GLint minfilter;
|
| | 47 | + GLint magfilter;
|
| | 48 | +} SAMPLER;
|
| | 49 | +
|
| | 50 | +extern SAMPLER samplers[8];
|
| | 51 | +
|
| | 52 | +void InitSamplers();
|
| | 53 | +void DeleteSamplers();
|
| 41 | 54 | void InitTexture(DXGLCFG *cfg);
|
| 42 | 55 | void SetActiveTexture(int level);
|
| 43 | 56 | void SetTexture(unsigned int level, TEXTURE *texture);
|