Index: ddraw/TextureManager.c |
— | — | @@ -55,19 +55,6 @@ |
56 | 56 | } while (1);
|
57 | 57 | }
|
58 | 58 |
|
59 | | -int pixelsfrompitch(int pitch, int bpp)
|
60 | | -{
|
61 | | - int bytesperpixel = bpp / 8;
|
62 | | - return pitch / bytesperpixel;
|
63 | | -}
|
64 | | -
|
65 | | -int bufferalign(int pitch)
|
66 | | -{
|
67 | | - if (pitch & 1) return 1;
|
68 | | - if (pitch & 2) return 2;
|
69 | | - if (pitch & 4) return 4;
|
70 | | - return 8;
|
71 | | -}
|
72 | 59 | DWORD CalculateMipLevels(DWORD width, DWORD height)
|
73 | 60 | {
|
74 | 61 | DWORD x, y;
|
— | — | @@ -513,9 +500,6 @@ |
514 | 501 | GLenum error;
|
515 | 502 | texture->width = width;
|
516 | 503 | texture->height = height;
|
517 | | - //glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
518 | | - //glPixelStorei(GL_UNPACK_ALIGNMENT, bufferalign(texture->pitch));
|
519 | | - //glPixelStorei(GL_UNPACK_ROW_LENGTH, pixelsfrompitch(texture->pitch, texture->pixelformat.dwRGBBitCount));
|
520 | 504 | if (checkerror)
|
521 | 505 | {
|
522 | 506 | do
|
— | — | @@ -564,14 +548,10 @@ |
565 | 549 | else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
566 | 550 | }
|
567 | 551 | }
|
568 | | - //glPopClientAttrib();
|
569 | 552 | }
|
570 | 553 |
|
571 | 554 | void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data)
|
572 | 555 | {
|
573 | | - //glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
574 | | - //glPixelStorei(GL_PACK_ALIGNMENT, bufferalign(texture->pitch));
|
575 | | - //glPixelStorei(GL_PACK_ROW_LENGTH, bufferalign(texture->pixelformat.dwRGBBitCount));
|
576 | 556 | if(This->ext->GLEXT_EXT_direct_state_access) This->ext->glGetTextureImageEXT(texture->id,GL_TEXTURE_2D,level,texture->format,texture->type,data);
|
577 | 557 | else
|
578 | 558 | {
|
— | — | @@ -579,7 +559,6 @@ |
580 | 560 | TextureManager_SetTexture(This, 0,texture);
|
581 | 561 | glGetTexImage(GL_TEXTURE_2D,level,texture->format,texture->type,data);
|
582 | 562 | }
|
583 | | - //glPopClientAttrib();
|
584 | 563 | }
|
585 | 564 |
|
586 | 565 | void TextureManager_SetActiveTexture(TextureManager *This, int level)
|
Index: ddraw/TextureManager.h |
— | — | @@ -33,7 +33,6 @@ |
34 | 34 | GLint wraps;
|
35 | 35 | GLint wrapt;
|
36 | 36 | GLint miplevel;
|
37 | | - GLint pitch;
|
38 | 37 | DWORD bordercolor;
|
39 | 38 | GLint internalformats[8];
|
40 | 39 | DWORD colorsizes[4];
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -72,7 +72,6 @@ |
73 | 73 | glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
|
74 | 74 | buffer = gdibuffer = NULL;
|
75 | 75 | bigbuffer = NULL;
|
76 | | - bigpitch = 0;
|
77 | 76 | clientbuffer = NULL;
|
78 | 77 | zbuffer = NULL;
|
79 | 78 | this->miplevel = miplevel;
|
— | — | @@ -138,7 +137,6 @@ |
139 | 138 | paltex->pixelformat.dwGBitMask = 0xFF00;
|
140 | 139 | paltex->pixelformat.dwRBitMask = 0xFF;
|
141 | 140 | paltex->pixelformat.dwRGBBitCount = 32;
|
142 | | - paltex->pitch = 1024;
|
143 | 141 | glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
|
144 | 142 | }
|
145 | 143 | else paltex = NULL;
|
— | — | @@ -223,11 +221,8 @@ |
224 | 222 | {
|
225 | 223 | case 0:
|
226 | 224 | buffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
|
227 | | - if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
228 | | - {
|
229 | | - bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8) * fakey);
|
230 | | - bigpitch = NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8);
|
231 | | - }
|
| 225 | + if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
| 226 | + bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
|
232 | 227 | if(!buffer) *error = DDERR_OUTOFMEMORY;
|
233 | 228 | goto maketex;
|
234 | 229 | break;
|
— | — | @@ -326,7 +321,6 @@ |
327 | 322 | texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
|
328 | 323 | if (ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) texture->miplevel = ddsd.dwMipMapCount;
|
329 | 324 | else texture->miplevel = 1;
|
330 | | - texture->pitch = ddsd.lPitch;
|
331 | 325 | glRenderer_MakeTexture(ddInterface->renderer, texture, fakex, fakey);
|
332 | 326 | }
|
333 | 327 | }
|
— | — | @@ -770,7 +764,8 @@ |
771 | 765 | if (pattern->dirty & 1)
|
772 | 766 | glRenderer_UploadTexture(ddInterface->renderer, pattern->buffer, pattern->bigbuffer, pattern->texture,
|
773 | 767 | pattern->ddsd.dwWidth, pattern->ddsd.dwHeight, pattern->fakex, pattern->fakey, pattern->ddsd.lPitch,
|
774 | | - pattern->bigpitch, pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
|
| 768 | + (NextMultipleOf4((ddInterface->GetBPPMultipleOf8() / 8)*pattern->fakex)),
|
| 769 | + pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
|
775 | 770 | }
|
776 | 771 | }
|
777 | 772 | if (dwFlags & DDBLT_KEYSRC)
|
— | — | @@ -783,13 +778,16 @@ |
784 | 779 | if(dirty & 1)
|
785 | 780 | {
|
786 | 781 | glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
787 | | - fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 782 | + fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
| 783 | + ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
788 | 784 | dirty &= ~1;
|
789 | 785 | }
|
790 | 786 | if(src && (src->dirty & 1))
|
791 | 787 | {
|
792 | 788 | glRenderer_UploadTexture(ddInterface->renderer,src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
|
793 | | - src->fakex,src->fakey,src->ddsd.lPitch,src->bigpitch,src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
|
| 789 | + src->fakex,src->fakey,src->ddsd.lPitch,
|
| 790 | + (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
| 791 | + src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
|
794 | 792 | src->dirty &= ~1;
|
795 | 793 | }
|
796 | 794 | if (clipper)
|
— | — | @@ -809,7 +807,6 @@ |
810 | 808 | stencil->pixelformat.dwRBitMask = 0xF00;
|
811 | 809 | stencil->pixelformat.dwRGBAlphaBitMask = 0xF000;
|
812 | 810 | stencil->pixelformat.dwRGBBitCount = 16;
|
813 | | - stencil->pitch = ddsd.lPitch;
|
814 | 811 | glRenderer_MakeTexture(ddInterface->renderer, stencil, ddsd.dwWidth, ddsd.dwHeight);
|
815 | 812 | }
|
816 | 813 | if (clipper->dirty)
|
— | — | @@ -981,7 +978,8 @@ |
982 | 979 | if(dirty & 1)
|
983 | 980 | {
|
984 | 981 | glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
985 | | - fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 982 | + fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
| 983 | + ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
986 | 984 | dirty &= ~1;
|
987 | 985 | }
|
988 | 986 | this->dirty |= 2;
|
— | — | @@ -991,7 +989,8 @@ |
992 | 990 | if(tmp->dirty & 1)
|
993 | 991 | {
|
994 | 992 | glRenderer_UploadTexture(ddInterface->renderer,tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
|
995 | | - tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,tmp->bigpitch,tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 993 | + tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
|
| 994 | + tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
996 | 995 | tmp->dirty &= ~1;
|
997 | 996 | }
|
998 | 997 | tmp->dirty |= 2;
|
— | — | @@ -1263,7 +1262,7 @@ |
1264 | 1263 | case 0:
|
1265 | 1264 | if(dirty & 2)
|
1266 | 1265 | glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
|
1267 | | - bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 1266 | + (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
1268 | 1267 | ddsd.lpSurface = buffer;
|
1269 | 1268 | dirty &= ~2;
|
1270 | 1269 | break;
|
— | — | @@ -1274,14 +1273,11 @@ |
1275 | 1274 | break;
|
1276 | 1275 | case 2:
|
1277 | 1276 | buffer = (char *)malloc(ddsd.lPitch * ddsd.dwHeight);
|
1278 | | - if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
1279 | | - {
|
1280 | | - bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey) / 8);
|
1281 | | - bigpitch = ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex);
|
1282 | | - }
|
| 1277 | + if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
| 1278 | + bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey)/8);
|
1283 | 1279 | else bigbuffer = NULL;
|
1284 | 1280 | glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
|
1285 | | - bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 1281 | + (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
1286 | 1282 | dirty &= ~2;
|
1287 | 1283 | surfacetype = 0;
|
1288 | 1284 | goto retry;
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -161,7 +161,6 @@ |
162 | 162 | glDirectDrawSurface7 *zbuffer;
|
163 | 163 | glDirectDrawSurface7 *miptexture;
|
164 | 164 | glDirectDrawSurface7 *backbuffer;
|
165 | | - int bigpitch;
|
166 | 165 | private:
|
167 | 166 | int swapinterval;
|
168 | 167 | ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -1348,7 +1348,6 @@ |
1349 | 1349 | This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
|
1350 | 1350 | This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
|
1351 | 1351 | This->backbuffer->pixelformat.dwRGBBitCount = 32;
|
1352 | | - This->backbuffer->pitch = (4 * x);
|
1353 | 1352 | TextureManager__CreateTexture(This->texman,This->backbuffer,x,y);
|
1354 | 1353 | This->backx = x;
|
1355 | 1354 | This->backy = y;
|
— | — | @@ -1355,7 +1354,6 @@ |
1356 | 1355 | }
|
1357 | 1356 | if((This->backx != x) || (This->backy != y))
|
1358 | 1357 | {
|
1359 | | - This->backbuffer->pitch = (4 * x);
|
1360 | 1358 | TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE, TRUE);
|
1361 | 1359 | This->backx = x;
|
1362 | 1360 | This->backy = y;
|
— | — | @@ -1402,7 +1400,6 @@ |
1403 | 1401 | This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
|
1404 | 1402 | This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
|
1405 | 1403 | This->backbuffer->pixelformat.dwRGBBitCount = 32;
|
1406 | | - This->backbuffer->pitch = (4 * x);
|
1407 | 1404 | TextureManager__CreateTexture(This->texman, This->backbuffer, x, y);
|
1408 | 1405 | This->backx = x;
|
1409 | 1406 | This->backy = y;
|
— | — | @@ -1411,7 +1408,6 @@ |
1412 | 1409 | {
|
1413 | 1410 | if (This->backx > x) x = This->backx;
|
1414 | 1411 | if (This->backx > y) y = This->backx;
|
1415 | | - This->backbuffer->pitch = (4 * x);
|
1416 | 1412 | TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE, TRUE);
|
1417 | 1413 | This->backx = x;
|
1418 | 1414 | This->backy = y;
|
— | — | @@ -2074,7 +2070,6 @@ |
2075 | 2071 | surface->stencil->pixelformat.dwRBitMask = 0xF00;
|
2076 | 2072 | surface->stencil->pixelformat.dwZBitMask = 0xF000;
|
2077 | 2073 | surface->stencil->pixelformat.dwRGBBitCount = 16;
|
2078 | | - surface->stencil->pitch = NextMultipleOf4(2 * surface->ddsd.dwWidth);
|
2079 | 2074 | TextureManager__CreateTexture(This->texman, surface->stencil, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
|
2080 | 2075 | }
|
2081 | 2076 | if ((surface->ddsd.dwWidth != surface->stencil->width) ||
|