| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -799,6 +799,9 @@ |
| 800 | 800 | if(ddCaps.dwSize > sizeof(DDCAPS_DX7)) ddCaps.dwSize = sizeof(DDCAPS_DX7);
|
| 801 | 801 | ddCaps.dwCaps = DDCAPS_BLT | DDCAPS_BLTCOLORFILL | DDCAPS_BLTSTRETCH |
|
| 802 | 802 | DDCAPS_COLORKEY | DDCAPS_GDI | DDCAPS_PALETTE | DDCAPS_CANBLTSYSMEM;
|
| | 803 | +#ifdef _DEBUG
|
| | 804 | + ddCaps.dwCaps |= DDCAPS_3D;
|
| | 805 | +#endif
|
| 803 | 806 | ddCaps.dwCaps2 = DDCAPS2_CANRENDERWINDOWED | DDCAPS2_WIDESURFACES | DDCAPS2_NOPAGELOCKREQUIRED |
|
| 804 | 807 | DDCAPS2_FLIPINTERVAL | DDCAPS2_FLIPNOVSYNC;
|
| 805 | 808 | ddCaps.dwFXCaps = DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKY |
|
| — | — | @@ -808,6 +811,10 @@ |
| 809 | 812 | DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP |
|
| 810 | 813 | DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
|
| 811 | 814 | DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;
|
| | 815 | +#ifdef _DEBUG
|
| | 816 | + ddCaps.ddsOldCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
| | 817 | + ddCaps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
| | 818 | +#endif;
|
| 812 | 819 | ddCaps.dwCKeyCaps = DDCKEYCAPS_SRCBLT;
|
| 813 | 820 | if(lpDDDriverCaps)
|
| 814 | 821 | {
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -789,7 +789,9 @@ |
| 790 | 790 | InitGLExt();
|
| 791 | 791 | SetSwap(1);
|
| 792 | 792 | SetSwap(0);
|
| | 793 | + SetViewport(0,0,width,height);
|
| 793 | 794 | glViewport(0,0,width,height);
|
| | 795 | + SetDepthRange(0.0,1.0);
|
| 794 | 796 | DepthWrite(true);
|
| 795 | 797 | DepthTest(false);
|
| 796 | 798 | MatrixMode(GL_MODELVIEW);
|
| — | — | @@ -844,7 +846,7 @@ |
| 845 | 847 | ddInterface->GetSizes(sizes);
|
| 846 | 848 | int error;
|
| 847 | 849 | error = SetFBO(dest->texture,0,false);
|
| 848 | | - glViewport(0,0,dest->fakex,dest->fakey);
|
| | 850 | + SetViewport(0,0,dest->fakex,dest->fakey);
|
| 849 | 851 | RECT destrect;
|
| 850 | 852 | DDSURFACEDESC2 ddsd;
|
| 851 | 853 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| — | — | @@ -1020,7 +1022,7 @@ |
| 1021 | 1023 | view[0] = view[2] = 0;
|
| 1022 | 1024 | view[1] = (GLfloat)x;
|
| 1023 | 1025 | view[3] = (GLfloat)y;
|
| 1024 | | - glViewport(0,0,x,y);
|
| | 1026 | + SetViewport(0,0,x,y);
|
| 1025 | 1027 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
| 1026 | 1028 | glBindTexture(GL_TEXTURE_2D,*texture);
|
| 1027 | 1029 | *texture = backbuffer;
|
| — | — | @@ -1134,7 +1136,7 @@ |
| 1135 | 1137 | GLint texloc = glGetUniformLocation(prog,"Texture");
|
| 1136 | 1138 | glUniform1i(texloc,0);
|
| 1137 | 1139 | }
|
| 1138 | | - glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
| | 1140 | + SetViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
| 1139 | 1141 | GLuint prog = GetProgram();
|
| 1140 | 1142 | GLint viewloc = glGetUniformLocation(prog,"view");
|
| 1141 | 1143 | glUniform4f(viewloc,view[0],view[1],view[2],view[3]);
|
| — | — | @@ -1298,7 +1300,7 @@ |
| 1299 | 1301 | gllock = false;
|
| 1300 | 1302 | SetSwap(1);
|
| 1301 | 1303 | SetSwap(0);
|
| 1302 | | - glViewport(0,0,width,height);
|
| | 1304 | + SetViewport(0,0,width,height);
|
| 1303 | 1305 | }
|
| 1304 | 1306 |
|
| 1305 | 1307 | SetEvent(busy);
|
| — | — | @@ -1485,8 +1487,8 @@ |
| 1486 | 1488 | if(prog.uniforms[138]!= -1) glUniform1f(prog.uniforms[138],device->glDDS7->fakey);
|
| 1487 | 1489 | if(device->glDDS7->zbuffer) SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
|
| 1488 | 1490 | else SetFBO(device->glDDS7->texture,0,false);
|
| 1489 | | - glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
| 1490 | | - glDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
|
| | 1491 | + SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
| | 1492 | + SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
|
| 1491 | 1493 | if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
|
| 1492 | 1494 | else glDrawArrays(mode,0,count);
|
| 1493 | 1495 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
| Index: ddraw/glutil.cpp |
| — | — | @@ -29,6 +29,12 @@ |
| 30 | 30 | GLint scissory = 0;
|
| 31 | 31 | GLsizei scissorwidth = 0;
|
| 32 | 32 | GLsizei scissorheight = 0;
|
| | 33 | +GLint viewportx = 0;
|
| | 34 | +GLint viewporty = 0;
|
| | 35 | +GLsizei viewportwidth = 0;
|
| | 36 | +GLsizei viewportheight = 0;
|
| | 37 | +GLclampd depthnear = 0.0;
|
| | 38 | +GLclampd depthfar = 1.0;
|
| 33 | 39 | GLenum matrixmode = GL_MODELVIEW;
|
| 34 | 40 | GLfloat materialambient[4] = {0,0,0,0};
|
| 35 | 41 | GLfloat materialdiffuse[4] = {0,0,0,0};
|
| — | — | @@ -132,7 +138,7 @@ |
| 133 | 139 | void SetTexture(int level,GLuint texture)
|
| 134 | 140 | {
|
| 135 | 141 | SetActiveTexture(level);
|
| 136 | | - glBindTexture(GL_TEXTURE_2D,texture);
|
| | 142 | + if(texture) glBindTexture(GL_TEXTURE_2D,texture);
|
| 137 | 143 | }
|
| 138 | 144 |
|
| 139 | 145 | void SetWrap(int level, DWORD coord, DWORD address)
|
| — | — | @@ -238,22 +244,22 @@ |
| 239 | 245 |
|
| 240 | 246 | void SetMaterial(GLfloat ambient[4],GLfloat diffuse[4],GLfloat specular[4],GLfloat emission[4],GLfloat shininess)
|
| 241 | 247 | {
|
| 242 | | - if(ambient != materialambient)
|
| | 248 | + if(memcmp(ambient,materialambient,4*sizeof(GLfloat)))
|
| 243 | 249 | {
|
| 244 | 250 | memcpy(materialambient,ambient,4*sizeof(GLfloat));
|
| 245 | 251 | glMaterialfv(GL_FRONT,GL_AMBIENT,ambient);
|
| 246 | 252 | }
|
| 247 | | - if(diffuse != materialdiffuse)
|
| | 253 | + if(memcmp(diffuse,materialdiffuse,4*sizeof(GLfloat)))
|
| 248 | 254 | {
|
| 249 | 255 | memcpy(materialdiffuse,diffuse,4*sizeof(GLfloat));
|
| 250 | 256 | glMaterialfv(GL_FRONT,GL_DIFFUSE,diffuse);
|
| 251 | 257 | }
|
| 252 | | - if(specular != materialspecular)
|
| | 258 | + if(memcmp(specular,materialspecular,4*sizeof(GLfloat)))
|
| 253 | 259 | {
|
| 254 | 260 | memcpy(materialspecular,specular,4*sizeof(GLfloat));
|
| 255 | 261 | glMaterialfv(GL_FRONT,GL_SPECULAR,specular);
|
| 256 | 262 | }
|
| 257 | | - if(emission != materialemission)
|
| | 263 | + if(memcmp(emission,materialemission,4*sizeof(GLfloat)))
|
| 258 | 264 | {
|
| 259 | 265 | memcpy(materialemission,emission,4*sizeof(GLfloat));
|
| 260 | 266 | glMaterialfv(GL_FRONT,GL_EMISSION,emission);
|
| — | — | @@ -263,4 +269,26 @@ |
| 264 | 270 | materialshininess = shininess;
|
| 265 | 271 | glMaterialf(GL_FRONT,GL_SHININESS,shininess);
|
| 266 | 272 | }
|
| | 273 | +}
|
| | 274 | +
|
| | 275 | +void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
| | 276 | +{
|
| | 277 | + if((x != viewportx) || (y != viewporty) || (width != viewportwidth) || (height != viewportheight))
|
| | 278 | + {
|
| | 279 | + viewportx = x;
|
| | 280 | + viewporty = y;
|
| | 281 | + viewportwidth = width;
|
| | 282 | + viewportheight = height;
|
| | 283 | + glViewport(x,y,width,height);
|
| | 284 | + }
|
| | 285 | +}
|
| | 286 | +
|
| | 287 | +void SetDepthRange(GLclampd rangenear, GLclampd rangefar)
|
| | 288 | +{
|
| | 289 | + if((rangenear != depthnear) || (rangefar != depthfar))
|
| | 290 | + {
|
| | 291 | + depthnear = rangenear;
|
| | 292 | + depthfar = rangefar;
|
| | 293 | + glDepthRange(rangenear,rangefar);
|
| | 294 | + }
|
| 267 | 295 | } |
| \ No newline at end of file |
| Index: ddraw/glutil.h |
| — | — | @@ -36,5 +36,7 @@ |
| 37 | 37 | void SetMatrix(GLenum mode, GLfloat *mat1, GLfloat *mat2, bool *dirty);
|
| 38 | 38 | void MatrixMode(GLenum mode);
|
| 39 | 39 | void SetMaterial(GLfloat ambient[4],GLfloat diffuse[4],GLfloat specular[4],GLfloat emission[4],GLfloat shininess);
|
| | 40 | +void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
| | 41 | +void SetDepthRange(GLclampd rangenear, GLclampd rangefar);
|
| 40 | 42 |
|
| 41 | 43 | #endif //_GLUTIL_H |
| \ No newline at end of file |