| Index: ddraw/TextureManager.c |
| — | — | @@ -46,6 +46,14 @@ |
| 47 | 47 | static const int END_TEXFORMATS = __LINE__ - 4;
|
| 48 | 48 | int numtexformats;
|
| 49 | 49 |
|
| | 50 | +void ClearError()
|
| | 51 | +{
|
| | 52 | + do
|
| | 53 | + {
|
| | 54 | + if (glGetError() == GL_NO_ERROR) break;
|
| | 55 | + } while (1);
|
| | 56 | +}
|
| | 57 | +
|
| 50 | 58 | TextureManager *TextureManager_Create(glExtensions *glext)
|
| 51 | 59 | {
|
| 52 | 60 | TextureManager *newtex;
|
| — | — | @@ -67,9 +75,9 @@ |
| 68 | 76 | {
|
| 69 | 77 | TextureManager_DeleteTexture(This, texture);
|
| 70 | 78 | }
|
| 71 | | -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height)
|
| | 79 | +void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
|
| 72 | 80 | {
|
| 73 | | - TextureManager_UploadTextureClassic(This, texture, level, data, width, height);
|
| | 81 | + TextureManager_UploadTextureClassic(This, texture, level, data, width, height, checkerror);
|
| 74 | 82 | }
|
| 75 | 83 | void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data)
|
| 76 | 84 | {
|
| — | — | @@ -111,6 +119,7 @@ |
| 112 | 120 | {
|
| 113 | 121 | int texformat = -1;
|
| 114 | 122 | int i;
|
| | 123 | + GLenum error;
|
| 115 | 124 | texture->pixelformat.dwSize = sizeof(DDPIXELFORMAT);
|
| 116 | 125 | for(i = 0; i < numtexformats; i++)
|
| 117 | 126 | {
|
| — | — | @@ -120,6 +129,7 @@ |
| 121 | 130 | break;
|
| 122 | 131 | }
|
| 123 | 132 | }
|
| | 133 | + ZeroMemory(texture->internalformats, 8 * sizeof(GLint));
|
| 124 | 134 | switch(texformat)
|
| 125 | 135 | {
|
| 126 | 136 | case -1:
|
| — | — | @@ -126,44 +136,50 @@ |
| 127 | 137 | case 0: // 8-bit palette
|
| 128 | 138 | if(This->ext->glver_major >= 3)
|
| 129 | 139 | {
|
| 130 | | - texture->internalformat = GL_R8;
|
| | 140 | + texture->internalformats[0] = GL_R8;
|
| 131 | 141 | texture->format = GL_RED;
|
| 132 | 142 | }
|
| 133 | 143 | else
|
| 134 | 144 | {
|
| 135 | | - texture->internalformat = GL_RGBA8;
|
| | 145 | + texture->internalformats[0] = GL_RGBA8;
|
| 136 | 146 | texture->format = GL_LUMINANCE;
|
| 137 | 147 | }
|
| 138 | 148 | texture->type = GL_UNSIGNED_BYTE;
|
| 139 | 149 | break;
|
| 140 | 150 | case 1: // 8-bit RGB332
|
| 141 | | - texture->internalformat = GL_R3_G3_B2;
|
| | 151 | + texture->internalformats[0] = GL_R3_G3_B2;
|
| | 152 | + texture->internalformats[1] = GL_RGB8;
|
| | 153 | + texture->internalformats[2] = GL_RGBA8;
|
| 142 | 154 | texture->format = GL_RGB;
|
| 143 | 155 | texture->type = GL_UNSIGNED_BYTE_3_3_2;
|
| 144 | 156 | break;
|
| 145 | 157 | case 2: // 16-bit RGB555
|
| 146 | | - texture->internalformat = GL_RGB5_A1;
|
| | 158 | + texture->internalformats[0] = GL_RGB5_A1;
|
| | 159 | + texture->internalformats[1] = GL_RGB8;
|
| | 160 | + texture->internalformats[2] = GL_RGBA8;
|
| 147 | 161 | texture->format = GL_BGRA;
|
| 148 | 162 | texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 149 | 163 | break;
|
| 150 | 164 | case 3: // 16-bit RGB565
|
| 151 | | - /*if(GLEXT_ARB_ES2_compatibility) texture->internalformat = GL_RGB565;
|
| 152 | | - else */texture->internalformat = GL_RGBA8;
|
| | 165 | + texture->internalformats[0] = GL_RGB565;
|
| | 166 | + texture->internalformats[1] = GL_RGB8;
|
| | 167 | + texture->internalformats[2] = GL_RGBA8;
|
| 153 | 168 | texture->format = GL_RGB;
|
| 154 | 169 | texture->type = GL_UNSIGNED_SHORT_5_6_5;
|
| 155 | 170 | break;
|
| 156 | 171 | case 4: // 24-bit RGB888
|
| 157 | | - texture->internalformat = GL_RGB8;
|
| | 172 | + texture->internalformats[0] = GL_RGB8;
|
| | 173 | + texture->internalformats[1] = GL_RGBA8;
|
| 158 | 174 | texture->format = GL_BGR;
|
| 159 | 175 | texture->type = GL_UNSIGNED_BYTE;
|
| 160 | 176 | break;
|
| 161 | 177 | case 5: // 32-bit RGB888
|
| 162 | | - texture->internalformat = GL_RGBA8;
|
| | 178 | + texture->internalformats[0] = GL_RGBA8;
|
| 163 | 179 | texture->format = GL_BGRA;
|
| 164 | 180 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 165 | 181 | break;
|
| 166 | 182 | case 6: // 32-bit BGR888
|
| 167 | | - texture->internalformat = GL_RGBA8;
|
| | 183 | + texture->internalformats[0] = GL_RGBA8;
|
| 168 | 184 | texture->format = GL_RGBA;
|
| 169 | 185 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 170 | 186 | break;
|
| — | — | @@ -171,62 +187,66 @@ |
| 172 | 188 | FIXME("Unusual texture format RGBA8332 not supported");
|
| 173 | 189 | break;
|
| 174 | 190 | case 8: // 16-bit RGBA4444
|
| 175 | | - texture->internalformat = GL_RGBA4;
|
| | 191 | + texture->internalformats[0] = GL_RGBA4;
|
| | 192 | + texture->internalformats[1] = GL_RGBA8;
|
| 176 | 193 | texture->format = GL_BGRA;
|
| 177 | 194 | texture->type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
| 178 | 195 | break;
|
| 179 | 196 | case 9: // 16-bit RGBA1555
|
| 180 | | - texture->internalformat = GL_RGB5_A1;
|
| | 197 | + texture->internalformats[0] = GL_RGB5_A1;
|
| 181 | 198 | texture->format = GL_BGRA;
|
| 182 | 199 | texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 183 | 200 | break;
|
| 184 | 201 | case 10: // 32-bit RGBA8888
|
| 185 | | - texture->internalformat = GL_RGBA8;
|
| | 202 | + texture->internalformats[0] = GL_RGBA8;
|
| 186 | 203 | texture->format = GL_BGRA;
|
| 187 | 204 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 188 | 205 | break;
|
| 189 | 206 | case 11: // 8-bit Luminance
|
| 190 | | - texture->internalformat = GL_LUMINANCE8;
|
| | 207 | + texture->internalformats[0] = GL_LUMINANCE8;
|
| | 208 | + texture->internalformats[1] = GL_RGB8;
|
| | 209 | + texture->internalformats[2] = GL_RGBA8;
|
| 191 | 210 | texture->format = GL_LUMINANCE;
|
| 192 | 211 | texture->type = GL_UNSIGNED_BYTE;
|
| 193 | 212 | break;
|
| 194 | 213 | case 12: // 8-bit Alpha
|
| 195 | | - texture->internalformat = GL_ALPHA8;
|
| | 214 | + texture->internalformats[0] = GL_ALPHA8;
|
| 196 | 215 | texture->format = GL_ALPHA;
|
| 197 | 216 | texture->type = GL_UNSIGNED_BYTE;
|
| 198 | 217 | break;
|
| 199 | 218 | case 13: // 16-bit Luminance Alpha
|
| 200 | | - texture->internalformat = GL_LUMINANCE8_ALPHA8;
|
| | 219 | + texture->internalformats[0] = GL_LUMINANCE8_ALPHA8;
|
| | 220 | + texture->internalformats[1] = GL_RGBA8;
|
| 201 | 221 | texture->format = GL_LUMINANCE_ALPHA;
|
| 202 | 222 | texture->type = GL_UNSIGNED_BYTE;
|
| 203 | 223 | break;
|
| 204 | 224 | case 14: // 16-bit Z buffer
|
| 205 | | - texture->internalformat = GL_DEPTH_COMPONENT16;
|
| | 225 | + texture->internalformats[0] = GL_DEPTH_COMPONENT16;
|
| 206 | 226 | texture->format = GL_DEPTH_COMPONENT;
|
| 207 | 227 | texture->type = GL_UNSIGNED_SHORT;
|
| 208 | 228 | break;
|
| 209 | 229 | case 15: // 24-bit Z buffer
|
| 210 | | - texture->internalformat = GL_DEPTH_COMPONENT24;
|
| | 230 | + texture->internalformats[0] = GL_DEPTH_COMPONENT24;
|
| 211 | 231 | texture->format = GL_DEPTH_COMPONENT;
|
| 212 | 232 | texture->type = GL_UNSIGNED_INT;
|
| 213 | 233 | break;
|
| 214 | 234 | case 16: // 32/24 bit Z buffer
|
| 215 | | - texture->internalformat = GL_DEPTH_COMPONENT24;
|
| | 235 | + texture->internalformats[0] = GL_DEPTH_COMPONENT24;
|
| 216 | 236 | texture->format = GL_DEPTH_COMPONENT;
|
| 217 | 237 | texture->type = GL_UNSIGNED_INT;
|
| 218 | 238 | break;
|
| 219 | 239 | case 17: // 32-bit Z buffer
|
| 220 | | - texture->internalformat = GL_DEPTH_COMPONENT32;
|
| | 240 | + texture->internalformats[0] = GL_DEPTH_COMPONENT32;
|
| 221 | 241 | texture->format = GL_DEPTH_COMPONENT;
|
| 222 | 242 | texture->type = GL_UNSIGNED_INT;
|
| 223 | 243 | break;
|
| 224 | 244 | case 18: // 32-bit Z/Stencil buffer, depth LSB
|
| 225 | | - texture->internalformat = GL_DEPTH24_STENCIL8;
|
| | 245 | + texture->internalformats[0] = GL_DEPTH24_STENCIL8;
|
| 226 | 246 | texture->format = GL_DEPTH_STENCIL;
|
| 227 | 247 | texture->type = GL_UNSIGNED_INT_24_8;
|
| 228 | 248 | break;
|
| 229 | 249 | case 19: // 32-bit Z/Stencil buffer, depth MSB
|
| 230 | | - texture->internalformat = GL_DEPTH24_STENCIL8;
|
| | 250 | + texture->internalformats[0] = GL_DEPTH24_STENCIL8;
|
| 231 | 251 | texture->format = GL_DEPTH_STENCIL;
|
| 232 | 252 | texture->type = GL_UNSIGNED_INT_24_8;
|
| 233 | 253 | break;
|
| — | — | @@ -235,7 +255,23 @@ |
| 236 | 256 | texture->height = height;
|
| 237 | 257 | glGenTextures(1,&texture->id);
|
| 238 | 258 | TextureManager_SetTexture(This,0,texture);
|
| 239 | | - glTexImage2D(GL_TEXTURE_2D,0,texture->internalformat,texture->width,texture->height,0,texture->format,texture->type,NULL);
|
| | 259 | + do
|
| | 260 | + {
|
| | 261 | + ClearError();
|
| | 262 | + glTexImage2D(GL_TEXTURE_2D, 0, texture->internalformats[0], texture->width, texture->height, 0, texture->format, texture->type, NULL);
|
| | 263 | + error = glGetError();
|
| | 264 | + if (error != GL_NO_ERROR)
|
| | 265 | + {
|
| | 266 | + if (texture->internalformats[1] == 0)
|
| | 267 | + {
|
| | 268 | + FIXME("Failed to create texture, cannot find internal format");
|
| | 269 | + break;
|
| | 270 | + }
|
| | 271 | + memmove(&texture->internalformats[0], &texture->internalformats[1], 7 * sizeof(GLint));
|
| | 272 | + texture->internalformats[7] = 0;
|
| | 273 | + }
|
| | 274 | + else break;
|
| | 275 | + } while (1);
|
| 240 | 276 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,texture->minfilter);
|
| 241 | 277 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,texture->magfilter);
|
| 242 | 278 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,texture->wraps);
|
| — | — | @@ -245,23 +281,55 @@ |
| 246 | 282 | void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture)
|
| 247 | 283 | {
|
| 248 | 284 | glDeleteTextures(1,&texture->id);
|
| 249 | | - texture->bordercolor = texture->format = texture->internalformat =
|
| 250 | | - texture->type = texture->width = texture->height = texture->magfilter =
|
| 251 | | - texture->minfilter = texture->miplevel = texture->wraps = texture->wrapt =
|
| | 285 | + texture->bordercolor = texture->format = texture->type = texture->width =
|
| | 286 | + texture->height = texture->magfilter = texture->minfilter =
|
| | 287 | + texture->miplevel = texture->wraps = texture->wrapt =
|
| 252 | 288 | texture->pbo = texture->id = 0;
|
| | 289 | + ZeroMemory(texture->internalformats, 8 * sizeof(GLint));
|
| 253 | 290 | }
|
| 254 | 291 |
|
| 255 | | -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height)
|
| | 292 | +void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
|
| 256 | 293 | {
|
| | 294 | + GLenum error;
|
| 257 | 295 | texture->width = width;
|
| 258 | 296 | texture->height = height;
|
| 259 | | - if(This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id,GL_TEXTURE_2D,level,texture->internalformat,
|
| 260 | | - width,height,0,texture->format,texture->type,data);
|
| | 297 | + if (checkerror)
|
| | 298 | + {
|
| | 299 | + do
|
| | 300 | + {
|
| | 301 | + ClearError();
|
| | 302 | + if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
| | 303 | + width, height, 0, texture->format, texture->type, data);
|
| | 304 | + else
|
| | 305 | + {
|
| | 306 | + TextureManager_SetActiveTexture(This, 0);
|
| | 307 | + TextureManager_SetTexture(This, 0, texture);
|
| | 308 | + glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| | 309 | + }
|
| | 310 | + error = glGetError();
|
| | 311 | + if (error != GL_NO_ERROR)
|
| | 312 | + {
|
| | 313 | + if (texture->internalformats[1] == 0)
|
| | 314 | + {
|
| | 315 | + FIXME("Failed to update texture, cannot find internal format");
|
| | 316 | + break;
|
| | 317 | + }
|
| | 318 | + memmove(&texture->internalformats[0], &texture->internalformats[1], 7 * sizeof(GLint));
|
| | 319 | + texture->internalformats[7] = 0;
|
| | 320 | + }
|
| | 321 | + else break;
|
| | 322 | + } while (1);
|
| | 323 | + }
|
| 261 | 324 | else
|
| 262 | 325 | {
|
| 263 | | - TextureManager_SetActiveTexture(This, 0);
|
| 264 | | - TextureManager_SetTexture(This, 0,texture);
|
| 265 | | - glTexImage2D(GL_TEXTURE_2D,level,texture->internalformat,width,height,0,texture->format,texture->type,data);
|
| | 326 | + if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
|
| | 327 | + width, height, 0, texture->format, texture->type, data);
|
| | 328 | + else
|
| | 329 | + {
|
| | 330 | + TextureManager_SetActiveTexture(This, 0);
|
| | 331 | + TextureManager_SetTexture(This, 0, texture);
|
| | 332 | + glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
|
| | 333 | + }
|
| 266 | 334 | }
|
| 267 | 335 | }
|
| 268 | 336 |
|
| — | — | @@ -298,200 +366,3 @@ |
| 299 | 367 | glBindTexture(GL_TEXTURE_2D,texname);
|
| 300 | 368 | }
|
| 301 | 369 | }
|
| 302 | | -
|
| 303 | | -
|
| 304 | | -
|
| 305 | | -/* old code
|
| 306 | | - if(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)
|
| 307 | | - {
|
| 308 | | - switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
| 309 | | - {
|
| 310 | | - case 8:
|
| 311 | | - if(ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
|
| 312 | | - {
|
| 313 | | - texformat = GL_LUMINANCE;
|
| 314 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 315 | | - if(dxglcfg.texformat) texformat3 = GL_LUMINANCE8;
|
| 316 | | - else texformat3 = GL_RGBA8;
|
| 317 | | - if(!palettein) palette = new glDirectDrawPalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,NULL);
|
| 318 | | - bitmapinfo->bmiHeader.biBitCount = 8;
|
| 319 | | - }
|
| 320 | | - else
|
| 321 | | - {
|
| 322 | | - texformat = GL_RGB;
|
| 323 | | - texformat2 = GL_UNSIGNED_BYTE_3_3_2;
|
| 324 | | - if(dxglcfg.texformat) texformat3 = GL_R3_G3_B2;
|
| 325 | | - else texformat3 = GL_RGBA8;
|
| 326 | | - }
|
| 327 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0;
|
| 328 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0;
|
| 329 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0;
|
| 330 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
|
| 331 | | - break;
|
| 332 | | - case 16:
|
| 333 | | - if((ddsd.ddpfPixelFormat.dwRBitMask == 0x7C00) && (ddsd.ddpfPixelFormat.dwGBitMask == 0x3E0)
|
| 334 | | - && (ddsd.ddpfPixelFormat.dwBBitMask == 0x1F))
|
| 335 | | - {
|
| 336 | | - texformat = GL_BGRA;
|
| 337 | | - texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 338 | | - if(dxglcfg.texformat) texformat3 = GL_RGB5_A1;
|
| 339 | | - else texformat3 = GL_RGBA8;
|
| 340 | | - }
|
| 341 | | - else // fixme: support more formats
|
| 342 | | - {
|
| 343 | | - texformat = GL_RGB;
|
| 344 | | - texformat2 = GL_UNSIGNED_SHORT_5_6_5;
|
| 345 | | - if(dxglcfg.texformat) texformat3 = GL_RGB;
|
| 346 | | - else texformat3 = GL_RGBA8;
|
| 347 | | - }
|
| 348 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| 349 | | - break;
|
| 350 | | - case 24:
|
| 351 | | - if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
|
| 352 | | - && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
|
| 353 | | - {
|
| 354 | | - texformat = GL_BGR;
|
| 355 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 356 | | - if(dxglcfg.texformat) texformat3 = GL_RGB8;
|
| 357 | | - else texformat3 = GL_RGBA8;
|
| 358 | | - }
|
| 359 | | - else // fixme: support more formats
|
| 360 | | - {
|
| 361 | | - texformat = GL_RGB;
|
| 362 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 363 | | - if(dxglcfg.texformat) texformat3 = GL_RGB8;
|
| 364 | | - else texformat3 = GL_RGBA8;
|
| 365 | | - }
|
| 366 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
|
| 367 | | - break;
|
| 368 | | - case 32:
|
| 369 | | - default:
|
| 370 | | - if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
|
| 371 | | - && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
|
| 372 | | - {
|
| 373 | | - texformat = GL_BGRA;
|
| 374 | | - texformat2 = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 375 | | - texformat3 = GL_RGBA8;
|
| 376 | | - }
|
| 377 | | - else // fixme: support more formats
|
| 378 | | - {
|
| 379 | | - texformat = GL_RGBA;
|
| 380 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 381 | | - texformat3 = GL_RGBA8;
|
| 382 | | - }
|
| 383 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
|
| 384 | | - }
|
| 385 | | - }
|
| 386 | | - else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
|
| 387 | | - {
|
| 388 | | - switch(ddsd.ddpfPixelFormat.dwZBufferBitDepth)
|
| 389 | | - {
|
| 390 | | - case 16:
|
| 391 | | - default:
|
| 392 | | - texformat = GL_DEPTH_COMPONENT;
|
| 393 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 394 | | - texformat3 = GL_DEPTH_COMPONENT16;
|
| 395 | | - break;
|
| 396 | | - case 24:
|
| 397 | | - texformat = GL_DEPTH_COMPONENT;
|
| 398 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 399 | | - texformat3 = GL_DEPTH_COMPONENT24;
|
| 400 | | - break;
|
| 401 | | - case 32:
|
| 402 | | - if((ddsd.ddpfPixelFormat.dwRGBZBitMask == 0x00ffffff) &&
|
| 403 | | - !(ddsd.ddpfPixelFormat.dwFlags & DDPF_STENCILBUFFER))
|
| 404 | | - {
|
| 405 | | - texformat = GL_DEPTH_COMPONENT;
|
| 406 | | - texformat2 = GL_UNSIGNED_INT;
|
| 407 | | - texformat3 = GL_DEPTH_COMPONENT24;
|
| 408 | | - break;
|
| 409 | | - }
|
| 410 | | - else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_STENCILBUFFER)
|
| 411 | | - {
|
| 412 | | - texformat = GL_DEPTH_STENCIL;
|
| 413 | | - texformat2 = GL_UNSIGNED_INT_24_8;
|
| 414 | | - texformat3 = GL_DEPTH24_STENCIL8;
|
| 415 | | - hasstencil = true;
|
| 416 | | - break;
|
| 417 | | - }
|
| 418 | | - else
|
| 419 | | - {
|
| 420 | | - texformat = GL_DEPTH_COMPONENT;
|
| 421 | | - texformat2 = GL_UNSIGNED_INT;
|
| 422 | | - texformat3 = GL_DEPTH_COMPONENT32;
|
| 423 | | - break;
|
| 424 | | - }
|
| 425 | | - }
|
| 426 | | - }
|
| 427 | | - }
|
| 428 | | -
|
| 429 | | -*/
|
| 430 | | -
|
| 431 | | -/*
|
| 432 | | - if(!(ddsd.dwFlags & DDSD_PIXELFORMAT))
|
| 433 | | - {
|
| 434 | | - ddsd.ddpfPixelFormat.dwRGBBitCount = ddInterface->GetBPP();
|
| 435 | | - switch(ddInterface->GetBPP())
|
| 436 | | - {
|
| 437 | | - case 8:
|
| 438 | | - texformat = GL_LUMINANCE;
|
| 439 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 440 | | - if(dxglcfg.texformat) texformat3 = GL_LUMINANCE8;
|
| 441 | | - else texformat3 = GL_RGBA8;
|
| 442 | | - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
| 443 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0;
|
| 444 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0;
|
| 445 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0;
|
| 446 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
|
| 447 | | - break;
|
| 448 | | - case 15:
|
| 449 | | - texformat = GL_BGRA;
|
| 450 | | - texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 451 | | - if(dxglcfg.texformat) texformat3 = GL_RGB5_A1;
|
| 452 | | - else texformat3 = GL_RGBA8;
|
| 453 | | - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
| 454 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
| 455 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0x3E0;
|
| 456 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
|
| 457 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| 458 | | - ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
|
| 459 | | - break;
|
| 460 | | - case 16:
|
| 461 | | - texformat = GL_RGB;
|
| 462 | | - texformat2 = GL_UNSIGNED_SHORT_5_6_5;
|
| 463 | | - if(dxglcfg.texformat) texformat3 = GL_RGB;
|
| 464 | | - else texformat3 = GL_RGBA8;
|
| 465 | | - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
| 466 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0xF800;
|
| 467 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0x7E0;
|
| 468 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
|
| 469 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| 470 | | - break;
|
| 471 | | - case 24:
|
| 472 | | - texformat = GL_BGR;
|
| 473 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 474 | | - if(dxglcfg.texformat) texformat3 = GL_RGB8;
|
| 475 | | - else texformat3 = GL_RGBA8;
|
| 476 | | - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
| 477 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
| 478 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
| 479 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
|
| 480 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
|
| 481 | | - break;
|
| 482 | | - case 32:
|
| 483 | | - texformat = GL_BGRA;
|
| 484 | | - texformat2 = GL_UNSIGNED_BYTE;
|
| 485 | | - texformat3 = GL_RGBA8;
|
| 486 | | - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
| 487 | | - ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
| 488 | | - ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
| 489 | | - ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
|
| 490 | | - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
|
| 491 | | - break;
|
| 492 | | - default:
|
| 493 | | - *error = DDERR_INVALIDPIXELFORMAT;
|
| 494 | | - return;
|
| 495 | | - }
|
| 496 | | - }
|
| 497 | | -
|
| 498 | | -*/ |
| \ No newline at end of file |
| Index: ddraw/TextureManager.h |
| — | — | @@ -34,7 +34,7 @@ |
| 35 | 35 | GLint wrapt;
|
| 36 | 36 | GLint miplevel;
|
| 37 | 37 | DWORD bordercolor;
|
| 38 | | - GLint internalformat;
|
| | 38 | + GLint internalformats[8];
|
| 39 | 39 | GLenum format;
|
| 40 | 40 | GLenum type;
|
| 41 | 41 | GLuint pbo;
|
| — | — | @@ -68,11 +68,11 @@ |
| 69 | 69 | void TextureManager_SetTexture(TextureManager *This, unsigned int level, TEXTURE *texture);
|
| 70 | 70 | void TextureManager__CreateTexture(TextureManager *This, TEXTURE *texture, int width, int height);
|
| 71 | 71 | void TextureManager__DeleteTexture(TextureManager *This, TEXTURE *texture);
|
| 72 | | -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height);
|
| | 72 | +void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
|
| 73 | 73 | void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data);
|
| 74 | 74 | void TextureManager_CreateTextureClassic(TextureManager *This, TEXTURE *texture, int width, int height);
|
| 75 | 75 | void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture);
|
| 76 | | -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height);
|
| | 76 | +void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
|
| 77 | 77 | void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data);
|
| 78 | 78 |
|
| 79 | 79 | #ifdef __cplusplus
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -105,7 +105,7 @@ |
| 106 | 106 | if(bpp == 15) bpp = 16;
|
| 107 | 107 | if((x == bigx && y == bigy) || !bigbuffer)
|
| 108 | 108 | {
|
| 109 | | - TextureManager__UploadTexture(This->texman, texture, 0, buffer, x, y);
|
| | 109 | + TextureManager__UploadTexture(This->texman, texture, 0, buffer, x, y, FALSE);
|
| 110 | 110 | }
|
| 111 | 111 | else
|
| 112 | 112 | {
|
| — | — | @@ -125,7 +125,7 @@ |
| 126 | 126 | break;
|
| 127 | 127 | break;
|
| 128 | 128 | }
|
| 129 | | - TextureManager__UploadTexture(This->texman,texture,0,bigbuffer,bigx,bigy);
|
| | 129 | + TextureManager__UploadTexture(This->texman, texture, 0, bigbuffer, bigx, bigy, FALSE);
|
| 130 | 130 | }
|
| 131 | 131 | }
|
| 132 | 132 |
|
| — | — | @@ -1171,7 +1171,7 @@ |
| 1172 | 1172 | }
|
| 1173 | 1173 | if((This->backx != x) || (This->backy != y))
|
| 1174 | 1174 | {
|
| 1175 | | - TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y);
|
| | 1175 | + TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE);
|
| 1176 | 1176 | This->backx = x;
|
| 1177 | 1177 | This->backy = y;
|
| 1178 | 1178 | }
|
| — | — | @@ -1225,7 +1225,7 @@ |
| 1226 | 1226 | {
|
| 1227 | 1227 | if (This->backx > x) x = This->backx;
|
| 1228 | 1228 | if (This->backx > y) y = This->backx;
|
| 1229 | | - TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y);
|
| | 1229 | + TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE);
|
| 1230 | 1230 | This->backx = x;
|
| 1231 | 1231 | This->backy = y;
|
| 1232 | 1232 | }
|
| — | — | @@ -1322,7 +1322,7 @@ |
| 1323 | 1323 | {
|
| 1324 | 1324 | This->shaders->SetShader(PROG_PAL256,NULL,NULL,0);
|
| 1325 | 1325 | progtype = PROG_PAL256;
|
| 1326 | | - TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1);
|
| | 1326 | + TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1,FALSE);
|
| 1327 | 1327 | This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
|
| 1328 | 1328 | This->ext->glUniform1i(This->shaders->shaders[progtype].pal,1);
|
| 1329 | 1329 | TextureManager_SetTexture(This->texman,0,texture);
|
| — | — | @@ -1864,7 +1864,7 @@ |
| 1865 | 1865 | if ((surface->ddsd.dwWidth != surface->stencil->width) ||
|
| 1866 | 1866 | (surface->ddsd.dwHeight != surface->stencil->height))
|
| 1867 | 1867 | TextureManager__UploadTexture(This->texman, surface->stencil, 0, NULL,
|
| 1868 | | - surface->ddsd.dwWidth, surface->ddsd.dwHeight);
|
| | 1868 | + surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE);
|
| 1869 | 1869 | This->util->SetFBO(&surface->stencilfbo, surface->stencil, 0, false);
|
| 1870 | 1870 | view[0] = view[2] = 0;
|
| 1871 | 1871 | view[1] = (GLfloat)surface->ddsd.dwWidth;
|