Index: ddraw/TextureManager.c |
— | — | @@ -55,6 +55,19 @@ |
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 | +}
|
59 | 72 | DWORD CalculateMipLevels(DWORD width, DWORD height)
|
60 | 73 | {
|
61 | 74 | DWORD x, y;
|
— | — | @@ -98,9 +111,9 @@ |
99 | 112 | {
|
100 | 113 | TextureManager_DeleteTexture(This, texture);
|
101 | 114 | }
|
102 | | -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
|
| 115 | +void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc)
|
103 | 116 | {
|
104 | | - TextureManager_UploadTextureClassic(This, texture, level, data, width, height, checkerror);
|
| 117 | + TextureManager_UploadTextureClassic(This, texture, level, data, width, height, checkerror, realloc);
|
105 | 118 | }
|
106 | 119 | void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data)
|
107 | 120 | {
|
— | — | @@ -495,11 +508,13 @@ |
496 | 509 | ZeroMemory(texture->internalformats, 8 * sizeof(GLint));
|
497 | 510 | }
|
498 | 511 |
|
499 | | -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
|
| 512 | +void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc)
|
500 | 513 | {
|
501 | 514 | GLenum error;
|
502 | 515 | texture->width = width;
|
503 | 516 | texture->height = height;
|
| 517 | + glPixelStorei(GL_UNPACK_ALIGNMENT, bufferalign(texture->pitch));
|
| 518 | + glPixelStorei(GL_UNPACK_ROW_LENGTH, pixelsfrompitch(texture->pitch, texture->pixelformat.dwRGBBitCount));
|
504 | 519 | if (checkerror)
|
505 | 520 | {
|
506 | 521 | do
|
— | — | @@ -507,16 +522,16 @@ |
508 | 523 | ClearError();
|
509 | 524 | if (This->ext->GLEXT_EXT_direct_state_access)
|
510 | 525 | {
|
511 | | - This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
512 | | - //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
513 | | - // width, height, 0, texture->format, texture->type, data);
|
| 526 | + if (realloc)This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
| 527 | + width, height, 0, texture->format, texture->type, data);
|
| 528 | + else This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
514 | 529 | }
|
515 | 530 | else
|
516 | 531 | {
|
517 | 532 | TextureManager_SetActiveTexture(This, 0);
|
518 | 533 | TextureManager_SetTexture(This, 0, texture);
|
519 | | - glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
520 | | - //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| 534 | + if (realloc)glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| 535 | + else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
521 | 536 | }
|
522 | 537 | error = glGetError();
|
523 | 538 | if (error != GL_NO_ERROR)
|
— | — | @@ -536,16 +551,16 @@ |
537 | 552 | {
|
538 | 553 | if (This->ext->GLEXT_EXT_direct_state_access)
|
539 | 554 | {
|
540 | | - This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
541 | | - //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
542 | | - //width, height, 0, texture->format, texture->type, data);
|
| 555 | + if (realloc)This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
| 556 | + width, height, 0, texture->format, texture->type, data);
|
| 557 | + else This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
543 | 558 | }
|
544 | 559 | else
|
545 | 560 | {
|
546 | 561 | TextureManager_SetActiveTexture(This, 0);
|
547 | 562 | TextureManager_SetTexture(This, 0, texture);
|
548 | | - glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
549 | | - //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| 563 | + if (realloc)glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| 564 | + else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
|
550 | 565 | }
|
551 | 566 | }
|
552 | 567 | }
|
— | — | @@ -552,6 +567,8 @@ |
553 | 568 |
|
554 | 569 | void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data)
|
555 | 570 | {
|
| 571 | + glPixelStorei(GL_PACK_ALIGNMENT, bufferalign(texture->pitch));
|
| 572 | + glPixelStorei(GL_PACK_ROW_LENGTH, bufferalign(texture->pixelformat.dwRGBBitCount));
|
556 | 573 | if(This->ext->GLEXT_EXT_direct_state_access) This->ext->glGetTextureImageEXT(texture->id,GL_TEXTURE_2D,level,texture->format,texture->type,data);
|
557 | 574 | else
|
558 | 575 | {
|
Index: ddraw/TextureManager.h |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | GLint wraps;
|
35 | 35 | GLint wrapt;
|
36 | 36 | GLint miplevel;
|
| 37 | + GLint pitch;
|
37 | 38 | DWORD bordercolor;
|
38 | 39 | GLint internalformats[8];
|
39 | 40 | DWORD colorsizes[4];
|
— | — | @@ -83,11 +84,11 @@ |
84 | 85 | void TextureManager_SetTexture(TextureManager *This, unsigned int level, TEXTURE *texture);
|
85 | 86 | void TextureManager__CreateTexture(TextureManager *This, TEXTURE *texture, int width, int height);
|
86 | 87 | void TextureManager__DeleteTexture(TextureManager *This, TEXTURE *texture);
|
87 | | -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
|
| 88 | +void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc);
|
88 | 89 | void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data);
|
89 | 90 | void TextureManager_CreateTextureClassic(TextureManager *This, TEXTURE *texture, int width, int height);
|
90 | 91 | void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture);
|
91 | | -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
|
| 92 | +void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc);
|
92 | 93 | void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data);
|
93 | 94 | BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty, GLint level);
|
94 | 95 |
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1244,9 +1244,9 @@ |
1245 | 1245 | ddsdMode.dwWidth = primaryx;
|
1246 | 1246 | ddsdMode.dwHeight = primaryy;
|
1247 | 1247 | ddsdMode.dwRefreshRate = primaryrefresh;
|
1248 | | - if(primarybpp == 15) ddsdMode.lPitch = NextMultipleOfWord(primaryx * 2);
|
1249 | | - else if(primarybpp == 4) ddsdMode.lPitch = NextMultipleOfWord(primaryx / 2);
|
1250 | | - else ddsdMode.lPitch = NextMultipleOfWord(primaryx * (primarybpp / 8));
|
| 1248 | + if(primarybpp == 15) ddsdMode.lPitch = NextMultipleOf4(primaryx * 2);
|
| 1249 | + else if(primarybpp == 4) ddsdMode.lPitch = NextMultipleOf4(primaryx / 2);
|
| 1250 | + else ddsdMode.lPitch = NextMultipleOf4(primaryx * (primarybpp / 8));
|
1251 | 1251 | if(lpDDSurfaceDesc2->dwSize < sizeof(DDSURFACEDESC)) ERR(DDERR_INVALIDPARAMS);
|
1252 | 1252 | if(lpDDSurfaceDesc2->dwSize > sizeof(DDSURFACEDESC2))
|
1253 | 1253 | lpDDSurfaceDesc2->dwSize = sizeof(DDSURFACEDESC2);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -72,6 +72,7 @@ |
73 | 73 | glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
|
74 | 74 | buffer = gdibuffer = NULL;
|
75 | 75 | bigbuffer = NULL;
|
| 76 | + bigpitch = 0;
|
76 | 77 | zbuffer = NULL;
|
77 | 78 | this->miplevel = miplevel;
|
78 | 79 | DWORD colormasks[3];
|
— | — | @@ -136,6 +137,7 @@ |
137 | 138 | paltex->pixelformat.dwGBitMask = 0xFF00;
|
138 | 139 | paltex->pixelformat.dwRBitMask = 0xFF;
|
139 | 140 | paltex->pixelformat.dwRGBBitCount = 32;
|
| 141 | + paltex->pitch = 1024;
|
140 | 142 | glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
|
141 | 143 | }
|
142 | 144 | else paltex = NULL;
|
— | — | @@ -219,9 +221,12 @@ |
220 | 222 | switch(surfacetype)
|
221 | 223 | {
|
222 | 224 | case 0:
|
223 | | - buffer = (char *)malloc(NextMultipleOfWord((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
|
224 | | - if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
225 | | - bigbuffer = (char *)malloc(NextMultipleOfWord((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
|
| 225 | + buffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
|
| 226 | + if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
| 227 | + {
|
| 228 | + bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8) * fakey);
|
| 229 | + bigpitch = NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8);
|
| 230 | + }
|
226 | 231 | if(!buffer) *error = DDERR_OUTOFMEMORY;
|
227 | 232 | goto maketex;
|
228 | 233 | break;
|
— | — | @@ -268,7 +273,7 @@ |
269 | 274 | ddsd.ddpfPixelFormat.dwRBitMask = 0;
|
270 | 275 | ddsd.ddpfPixelFormat.dwGBitMask = 0;
|
271 | 276 | ddsd.ddpfPixelFormat.dwBBitMask = 0;
|
272 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
|
| 277 | + ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth);
|
273 | 278 | break;
|
274 | 279 | case 15:
|
275 | 280 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
— | — | @@ -275,7 +280,7 @@ |
276 | 281 | ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
277 | 282 | ddsd.ddpfPixelFormat.dwGBitMask = 0x3E0;
|
278 | 283 | ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
|
279 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| 284 | + ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*2);
|
280 | 285 | ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
|
281 | 286 | break;
|
282 | 287 | case 16:
|
— | — | @@ -283,7 +288,7 @@ |
284 | 289 | ddsd.ddpfPixelFormat.dwRBitMask = 0xF800;
|
285 | 290 | ddsd.ddpfPixelFormat.dwGBitMask = 0x7E0;
|
286 | 291 | ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
|
287 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| 292 | + ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*2);
|
288 | 293 | break;
|
289 | 294 | case 24:
|
290 | 295 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
— | — | @@ -290,7 +295,7 @@ |
291 | 296 | ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
292 | 297 | ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
293 | 298 | ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
|
294 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
|
| 299 | + ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*3);
|
295 | 300 | break;
|
296 | 301 | case 32:
|
297 | 302 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
— | — | @@ -297,7 +302,7 @@ |
298 | 303 | ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
299 | 304 | ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
300 | 305 | ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
|
301 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
|
| 306 | + ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*4);
|
302 | 307 | break;
|
303 | 308 | default:
|
304 | 309 | *error = DDERR_INVALIDPIXELFORMAT;
|
— | — | @@ -306,7 +311,7 @@ |
307 | 312 | return;
|
308 | 313 | }
|
309 | 314 | }
|
310 | | - else ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*(ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
|
| 315 | + else ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*(ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
|
311 | 316 | if (!(ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
|
312 | 317 | {
|
313 | 318 | texture->pixelformat = ddsd.ddpfPixelFormat;
|
— | — | @@ -320,6 +325,7 @@ |
321 | 326 | texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
|
322 | 327 | if (ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) texture->miplevel = ddsd.dwMipMapCount;
|
323 | 328 | else texture->miplevel = 1;
|
| 329 | + texture->pitch = ddsd.lPitch;
|
324 | 330 | glRenderer_MakeTexture(ddInterface->renderer, texture, fakex, fakey);
|
325 | 331 | }
|
326 | 332 | }
|
— | — | @@ -763,8 +769,7 @@ |
764 | 770 | if (pattern->dirty & 1)
|
765 | 771 | glRenderer_UploadTexture(ddInterface->renderer, pattern->buffer, pattern->bigbuffer, pattern->texture,
|
766 | 772 | pattern->ddsd.dwWidth, pattern->ddsd.dwHeight, pattern->fakex, pattern->fakey, pattern->ddsd.lPitch,
|
767 | | - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8() / 8)*pattern->fakex)),
|
768 | | - pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
|
| 773 | + pattern->bigpitch, pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
|
769 | 774 | }
|
770 | 775 | }
|
771 | 776 | if (dwFlags & DDBLT_KEYSRC)
|
— | — | @@ -777,16 +782,13 @@ |
778 | 783 | if(dirty & 1)
|
779 | 784 | {
|
780 | 785 | glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
781 | | - fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
782 | | - ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 786 | + fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
783 | 787 | dirty &= ~1;
|
784 | 788 | }
|
785 | 789 | if(src && (src->dirty & 1))
|
786 | 790 | {
|
787 | 791 | glRenderer_UploadTexture(ddInterface->renderer,src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
|
788 | | - src->fakex,src->fakey,src->ddsd.lPitch,
|
789 | | - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
790 | | - src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
|
| 792 | + src->fakex,src->fakey,src->ddsd.lPitch,src->bigpitch,src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
|
791 | 793 | src->dirty &= ~1;
|
792 | 794 | }
|
793 | 795 | if (clipper)
|
— | — | @@ -806,6 +808,7 @@ |
807 | 809 | stencil->pixelformat.dwRBitMask = 0xF00;
|
808 | 810 | stencil->pixelformat.dwRGBAlphaBitMask = 0xF000;
|
809 | 811 | stencil->pixelformat.dwRGBBitCount = 16;
|
| 812 | + stencil->pitch = ddsd.lPitch;
|
810 | 813 | glRenderer_MakeTexture(ddInterface->renderer, stencil, ddsd.dwWidth, ddsd.dwHeight);
|
811 | 814 | }
|
812 | 815 | if (clipper->dirty)
|
— | — | @@ -977,8 +980,7 @@ |
978 | 981 | if(dirty & 1)
|
979 | 982 | {
|
980 | 983 | glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
981 | | - fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
982 | | - ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 984 | + fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
983 | 985 | dirty &= ~1;
|
984 | 986 | }
|
985 | 987 | this->dirty |= 2;
|
— | — | @@ -988,8 +990,7 @@ |
989 | 991 | if(tmp->dirty & 1)
|
990 | 992 | {
|
991 | 993 | glRenderer_UploadTexture(ddInterface->renderer,tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
|
992 | | - tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
|
993 | | - tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 994 | + tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,tmp->bigpitch,tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
994 | 995 | tmp->dirty &= ~1;
|
995 | 996 | }
|
996 | 997 | tmp->dirty |= 2;
|
— | — | @@ -1261,7 +1262,7 @@ |
1262 | 1263 | case 0:
|
1263 | 1264 | if(dirty & 2)
|
1264 | 1265 | glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
|
1265 | | - (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 1266 | + bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
1266 | 1267 | ddsd.lpSurface = buffer;
|
1267 | 1268 | dirty &= ~2;
|
1268 | 1269 | break;
|
— | — | @@ -1272,11 +1273,14 @@ |
1273 | 1274 | break;
|
1274 | 1275 | case 2:
|
1275 | 1276 | buffer = (char *)malloc(ddsd.lPitch * ddsd.dwHeight);
|
1276 | | - if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
1277 | | - bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOfWord(fakex) * fakey)/8);
|
| 1277 | + if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
| 1278 | + {
|
| 1279 | + bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey) / 8);
|
| 1280 | + bigpitch = ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex);
|
| 1281 | + }
|
1278 | 1282 | else bigbuffer = NULL;
|
1279 | 1283 | glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
|
1280 | | - (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
| 1284 | + bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
1281 | 1285 | dirty &= ~2;
|
1282 | 1286 | surfacetype = 0;
|
1283 | 1287 | goto retry;
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -161,6 +161,7 @@ |
162 | 162 | glDirectDrawSurface7 *zbuffer;
|
163 | 163 | glDirectDrawSurface7 *miptexture;
|
164 | 164 | glDirectDrawSurface7 *backbuffer;
|
| 165 | + int bigpitch;
|
165 | 166 | private:
|
166 | 167 | int swapinterval;
|
167 | 168 | ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
|
— | — | @@ -178,6 +179,7 @@ |
179 | 180 | bool overlay;
|
180 | 181 | IUnknown *zbuffer_iface;
|
181 | 182 | int version;
|
| 183 | + bool clientmem;
|
182 | 184 | };
|
183 | 185 |
|
184 | 186 | // Legacy DDRAW Interfaces
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | if(bpp == 15) bpp = 16;
|
109 | 109 | if((x == bigx && y == bigy) || !bigbuffer)
|
110 | 110 | {
|
111 | | - TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE);
|
| 111 | + TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE, FALSE);
|
112 | 112 | }
|
113 | 113 | else
|
114 | 114 | {
|
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | break;
|
129 | 129 | break;
|
130 | 130 | }
|
131 | | - TextureManager__UploadTexture(This->texman, texture, miplevel, bigbuffer, bigx, bigy, FALSE);
|
| 131 | + TextureManager__UploadTexture(This->texman, texture, miplevel, bigbuffer, bigx, bigy, FALSE, FALSE);
|
132 | 132 | }
|
133 | 133 | }
|
134 | 134 |
|
— | — | @@ -1348,6 +1348,7 @@ |
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);
|
1352 | 1353 | TextureManager__CreateTexture(This->texman,This->backbuffer,x,y);
|
1353 | 1354 | This->backx = x;
|
1354 | 1355 | This->backy = y;
|
— | — | @@ -1354,7 +1355,8 @@ |
1355 | 1356 | }
|
1356 | 1357 | if((This->backx != x) || (This->backy != y))
|
1357 | 1358 | {
|
1358 | | - TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE);
|
| 1359 | + This->backbuffer->pitch = (4 * x);
|
| 1360 | + TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE, TRUE);
|
1359 | 1361 | This->backx = x;
|
1360 | 1362 | This->backy = y;
|
1361 | 1363 | }
|
— | — | @@ -1400,6 +1402,7 @@ |
1401 | 1403 | This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
|
1402 | 1404 | This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
|
1403 | 1405 | This->backbuffer->pixelformat.dwRGBBitCount = 32;
|
| 1406 | + This->backbuffer->pitch = (4 * x);
|
1404 | 1407 | TextureManager__CreateTexture(This->texman, This->backbuffer, x, y);
|
1405 | 1408 | This->backx = x;
|
1406 | 1409 | This->backy = y;
|
— | — | @@ -1408,7 +1411,8 @@ |
1409 | 1412 | {
|
1410 | 1413 | if (This->backx > x) x = This->backx;
|
1411 | 1414 | if (This->backx > y) y = This->backx;
|
1412 | | - TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE);
|
| 1415 | + This->backbuffer->pitch = (4 * x);
|
| 1416 | + TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE, TRUE);
|
1413 | 1417 | This->backx = x;
|
1414 | 1418 | This->backy = y;
|
1415 | 1419 | }
|
— | — | @@ -1505,7 +1509,7 @@ |
1506 | 1510 | {
|
1507 | 1511 | ShaderManager_SetShader(This->shaders,PROG_PAL256,NULL,NULL,0);
|
1508 | 1512 | progtype = PROG_PAL256;
|
1509 | | - TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1,FALSE);
|
| 1513 | + TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1,FALSE,FALSE);
|
1510 | 1514 | This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
|
1511 | 1515 | This->ext->glUniform1i(This->shaders->shaders[progtype].pal,1);
|
1512 | 1516 | TextureManager_SetTexture(This->texman,0,texture);
|
— | — | @@ -2070,12 +2074,13 @@ |
2071 | 2075 | surface->stencil->pixelformat.dwRBitMask = 0xF00;
|
2072 | 2076 | surface->stencil->pixelformat.dwZBitMask = 0xF000;
|
2073 | 2077 | surface->stencil->pixelformat.dwRGBBitCount = 16;
|
| 2078 | + surface->stencil->pitch = NextMultipleOf4(2 * surface->ddsd.dwWidth);
|
2074 | 2079 | TextureManager__CreateTexture(This->texman, surface->stencil, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
|
2075 | 2080 | }
|
2076 | 2081 | if ((surface->ddsd.dwWidth != surface->stencil->width) ||
|
2077 | 2082 | (surface->ddsd.dwHeight != surface->stencil->height))
|
2078 | 2083 | TextureManager__UploadTexture(This->texman, surface->stencil, 0, NULL,
|
2079 | | - surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE);
|
| 2084 | + surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE, TRUE);
|
2080 | 2085 | This->util->SetFBO(&surface->stencilfbo, surface->stencil, 0, false);
|
2081 | 2086 | view[0] = view[2] = 0;
|
2082 | 2087 | view[1] = (GLfloat)surface->ddsd.dwWidth;
|