Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -54,13 +54,13 @@ |
55 | 55 | }
|
56 | 56 |
|
57 | 57 |
|
58 | | -int UploadTexture(char *buffer, char *bigbuffer, GLuint texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int texformat, int texformat2)
|
| 58 | +int UploadTexture(char *buffer, char *bigbuffer, GLuint texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int texformat, int texformat2, int texformat3)
|
59 | 59 | {
|
60 | 60 | if(bpp == 15) bpp = 16;
|
61 | 61 | glBindTexture(GL_TEXTURE_2D,texture); // Select surface's texture
|
62 | 62 | if((x == bigx && y == bigy) || !bigbuffer)
|
63 | 63 | {
|
64 | | - glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,x,y,0,texformat,texformat2,buffer);
|
| 64 | + glTexImage2D(GL_TEXTURE_2D,0,texformat3,x,y,0,texformat,texformat2,buffer);
|
65 | 65 | }
|
66 | 66 | else
|
67 | 67 | {
|
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | break;
|
82 | 82 | break;
|
83 | 83 | }
|
84 | | - glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,bigx,bigy,0,texformat,texformat2,bigbuffer);
|
| 84 | + glTexImage2D(GL_TEXTURE_2D,0,texformat3,bigx,bigy,0,texformat,texformat2,bigbuffer);
|
85 | 85 | }
|
86 | 86 | return 0;
|
87 | 87 | }
|
— | — | @@ -299,13 +299,16 @@ |
300 | 300 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
|
301 | 301 | if(ddsd.dwFlags & DDSD_PIXELFORMAT)
|
302 | 302 | {
|
303 | | - switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
| 303 | + if(ddsd.dwFlags & DDPF_ZBUFFER)
|
304 | 304 | {
|
305 | | - case 8:
|
306 | | - case 16:
|
307 | | - case 32:
|
308 | | - break;
|
309 | | -
|
| 305 | + switch(ddsd.ddpfPixelFormat.dwZBufferBitDepth)
|
| 306 | + {
|
| 307 | + case 16:
|
| 308 | + default:
|
| 309 | + case 24:
|
| 310 | + case 32:
|
| 311 | + __asm nop
|
| 312 | + }
|
310 | 313 | }
|
311 | 314 | }
|
312 | 315 | else
|
— | — | @@ -316,6 +319,7 @@ |
317 | 320 | case 8:
|
318 | 321 | texformat = GL_LUMINANCE;
|
319 | 322 | texformat2 = GL_UNSIGNED_BYTE;
|
| 323 | + texformat3 = GL_LUMINANCE8;
|
320 | 324 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
321 | 325 | ddsd.ddpfPixelFormat.dwRBitMask = 0;
|
322 | 326 | ddsd.ddpfPixelFormat.dwGBitMask = 0;
|
— | — | @@ -325,6 +329,7 @@ |
326 | 330 | case 15:
|
327 | 331 | texformat = GL_BGRA;
|
328 | 332 | texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 333 | + texformat3 = GL_RGB5_A1;
|
329 | 334 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
330 | 335 | ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
331 | 336 | ddsd.ddpfPixelFormat.dwGBitMask = 0x3E0;
|
— | — | @@ -335,6 +340,7 @@ |
336 | 341 | case 16:
|
337 | 342 | texformat = GL_RGB;
|
338 | 343 | texformat2 = GL_UNSIGNED_SHORT_5_6_5;
|
| 344 | + texformat3 = GL_RGB565;
|
339 | 345 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
340 | 346 | ddsd.ddpfPixelFormat.dwRBitMask = 0xF800;
|
341 | 347 | ddsd.ddpfPixelFormat.dwGBitMask = 0x7E0;
|
— | — | @@ -344,6 +350,7 @@ |
345 | 351 | case 24:
|
346 | 352 | texformat = GL_BGR;
|
347 | 353 | texformat2 = GL_UNSIGNED_BYTE;
|
| 354 | + texformat3 = GL_RGB8;
|
348 | 355 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
349 | 356 | ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
350 | 357 | ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
— | — | @@ -353,6 +360,7 @@ |
354 | 361 | case 32:
|
355 | 362 | texformat = GL_BGRA;
|
356 | 363 | texformat2 = GL_UNSIGNED_BYTE;
|
| 364 | + texformat3 = GL_RGBA8;
|
357 | 365 | ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
358 | 366 | ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
359 | 367 | ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
|
— | — | @@ -371,7 +379,7 @@ |
372 | 380 | memcpy(bitmapinfo->bmiColors,colormasks,3*sizeof(DWORD));
|
373 | 381 | }
|
374 | 382 | }
|
375 | | - glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,fakex,fakey,0,texformat,texformat2,NULL);
|
| 383 | + glTexImage2D(GL_TEXTURE_2D,0,texformat3,fakex,fakey,0,texformat,texformat2,NULL);
|
376 | 384 | }
|
377 | 385 |
|
378 | 386 | refcount = 1;
|
— | — | @@ -517,7 +525,7 @@ |
518 | 526 | {
|
519 | 527 | UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
520 | 528 | fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
521 | | - ddsd.ddpfPixelFormat.dwRGBBitCount,texformat,texformat2);
|
| 529 | + ddsd.ddpfPixelFormat.dwRGBBitCount,texformat,texformat2,texformat3);
|
522 | 530 | dirty &= ~1;
|
523 | 531 | }
|
524 | 532 | if(src && (src->dirty & 1))
|
— | — | @@ -525,7 +533,7 @@ |
526 | 534 | UploadTexture(src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
|
527 | 535 | src->fakex,src->fakey,src->ddsd.lPitch,
|
528 | 536 | (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
529 | | - src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->texformat,src->texformat2);
|
| 537 | + src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->texformat,src->texformat2,src->texformat3);
|
530 | 538 | src->dirty &= ~1;
|
531 | 539 | }
|
532 | 540 | LONG sizes[6];
|
— | — | @@ -621,25 +629,25 @@ |
622 | 630 | switch(ddInterface->GetBPP())
|
623 | 631 | {
|
624 | 632 | case 8:
|
625 | | - glUniform4i(keyloc,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
|
626 | | - src->colorkey[0].key.dwColorSpaceHighValue,255);
|
| 633 | + glUniform3i(keyloc,src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
|
| 634 | + src->colorkey[0].key.dwColorSpaceHighValue);
|
627 | 635 | break;
|
628 | 636 | case 15:
|
629 | | - glUniform4i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
|
| 637 | + glUniform3i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
|
630 | 638 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 31),
|
631 | | - _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31),255);
|
| 639 | + _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
632 | 640 | break;
|
633 | 641 | case 16:
|
634 | | - glUniform4i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
|
| 642 | + glUniform3i(keyloc,_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
|
635 | 643 | _6to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 63),
|
636 | | - _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31),255);
|
| 644 | + _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
637 | 645 | break;
|
638 | 646 | case 24:
|
639 | 647 | case 32:
|
640 | 648 | default:
|
641 | | - glUniform4i(keyloc,(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
|
| 649 | + glUniform3i(keyloc,(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
|
642 | 650 | (src->colorkey[0].key.dwColorSpaceHighValue>>8 & 255),
|
643 | | - (src->colorkey[0].key.dwColorSpaceHighValue & 255),255);
|
| 651 | + (src->colorkey[0].key.dwColorSpaceHighValue & 255));
|
644 | 652 | break;
|
645 | 653 | }
|
646 | 654 | GLint texloc = glGetUniformLocation(shaders[PROG_CKEY].prog,"myTexture");
|
— | — | @@ -742,7 +750,7 @@ |
743 | 751 | {
|
744 | 752 | UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
745 | 753 | fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
746 | | - ddsd.ddpfPixelFormat.dwRGBBitCount,texformat,texformat2);
|
| 754 | + ddsd.ddpfPixelFormat.dwRGBBitCount,texformat,texformat2,texformat3);
|
747 | 755 | dirty &= ~1;
|
748 | 756 | }
|
749 | 757 | this->dirty |= 2;
|
— | — | @@ -753,7 +761,7 @@ |
754 | 762 | {
|
755 | 763 | UploadTexture(tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
|
756 | 764 | tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
|
757 | | - tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,tmp->texformat,tmp->texformat2);
|
| 765 | + tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,tmp->texformat,tmp->texformat2,tmp->texformat3);
|
758 | 766 | tmp->dirty &= ~1;
|
759 | 767 | }
|
760 | 768 | tmp->dirty |= 2;
|
— | — | @@ -1058,7 +1066,7 @@ |
1059 | 1067 | UploadTexture(buffer,surface->bigbuffer,texture,surface->ddsd.dwWidth,surface->ddsd.dwHeight,
|
1060 | 1068 | surface->fakex,surface->fakey,surface->ddsd.lPitch,
|
1061 | 1069 | (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*surface->fakex)),
|
1062 | | - surface->ddsd.ddpfPixelFormat.dwRGBBitCount,surface->texformat,surface->texformat2);
|
| 1070 | + surface->ddsd.ddpfPixelFormat.dwRGBBitCount,surface->texformat,surface->texformat2,surface->texformat3);
|
1063 | 1071 | surface->dirty &= ~1;
|
1064 | 1072 | }
|
1065 | 1073 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -109,6 +109,7 @@ |
110 | 110 | int flipcount;
|
111 | 111 | GLenum texformat;
|
112 | 112 | GLenum texformat2;
|
| 113 | + GLint texformat3;
|
113 | 114 | DWORD fakex,fakey;
|
114 | 115 | DWORD dirty;
|
115 | 116 | HGLRC hrc;
|
Index: ddraw/glExtensions.cpp |
— | — | @@ -45,6 +45,8 @@ |
46 | 46 |
|
47 | 47 | GLint (APIENTRY *glGetUniformLocation) (GLuint program, const GLchar* name) = NULL;
|
48 | 48 | void (APIENTRY *glUniform1i) (GLint location, GLint v0) = NULL;
|
| 49 | +void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1) = NULL;
|
| 50 | +void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2) = NULL;
|
49 | 51 | void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL;
|
50 | 52 |
|
51 | 53 | void (APIENTRY *glActiveTexture)(GLenum texture) = NULL;
|
— | — | @@ -80,6 +82,8 @@ |
81 | 83 | glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
|
82 | 84 | glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
|
83 | 85 | glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
|
| 86 | + glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
|
| 87 | + glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
|
84 | 88 | glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
|
85 | 89 | }
|
86 | 90 | const GLubyte *glextensions = glGetString(GL_EXTENSIONS);
|
Index: ddraw/glExtensions.h |
— | — | @@ -25,8 +25,10 @@ |
26 | 26 | #ifndef GL_STENCIL_BUFFER
|
27 | 27 | #define GL_STENCIL_BUFFER 0x8224
|
28 | 28 | #endif
|
| 29 | +#ifndef GL_RGB565
|
| 30 | +#define GL_RGB565 0x8D62
|
| 31 | +#endif
|
29 | 32 |
|
30 | | -
|
31 | 33 | extern int GLEXT_ARB_framebuffer_object;
|
32 | 34 | extern int GLEXT_EXT_framebuffer_object;
|
33 | 35 | extern int GLEXT_NV_packed_depth_stencil;
|
— | — | @@ -65,6 +67,8 @@ |
66 | 68 |
|
67 | 69 | GLAPI GLint (APIENTRY *glGetUniformLocation) (GLuint program, const GLchar* name);
|
68 | 70 | GLAPI void (APIENTRY *glUniform1i) (GLint location, GLint v0);
|
| 71 | +GLAPI void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1);
|
| 72 | +GLAPI void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2);
|
69 | 73 | GLAPI void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
|
70 | 74 |
|
71 | 75 | GLAPI void (APIENTRY *glActiveTexture)(GLenum texture);
|
Index: ddraw/shaders.cpp |
— | — | @@ -32,11 +32,11 @@ |
33 | 33 | char frag_ColorKey[] = "\
|
34 | 34 | #version 110\n\
|
35 | 35 | uniform sampler2D myTexture;\n\
|
36 | | -uniform ivec4 keyIn;\n\
|
| 36 | +uniform ivec3 keyIn;\n\
|
37 | 37 | void main (void)\n\
|
38 | 38 | {\n\
|
39 | 39 | vec4 value = texture2D(myTexture, vec2(gl_TexCoord[0]));\n\
|
40 | | - ivec4 comp = ivec4(texture2D(myTexture, vec2(gl_TexCoord[0]))*255.0);\n\
|
| 40 | + ivec3 comp = ivec3(texture2D(myTexture, vec2(gl_TexCoord[0]))*255.0);\n\
|
41 | 41 | if (comp == keyIn)\n\
|
42 | 42 | discard;\n\
|
43 | 43 | gl_FragColor = value;\n\
|