Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2016 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -519,5 +519,5 @@ |
520 | 520 | ddsd.dwWidth = texture->levels[0].ddsd.dwWidth;
|
521 | 521 | ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
|
522 | 522 | ddsd.dwHeight = texture->levels[0].ddsd.dwHeight;
|
523 | | - glTexture_Create(&ddsd, &This->texture, renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, FALSE);
|
| 523 | + glTexture_Create(&ddsd, &This->texture, renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, FALSE, 0);
|
524 | 524 | } |
\ No newline at end of file |
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | memcpy(&ddsd, &ddsd256pal, sizeof(DDSURFACEDESC2));
|
373 | 373 | ddsd.dwWidth = This->palsize;
|
374 | 374 | ddsd.lPitch = This->palsize * 4;
|
375 | | - glTexture_Create(&ddsd, &This->texture, renderer, This->palsize, 1, FALSE, FALSE);
|
| 375 | + glTexture_Create(&ddsd, &This->texture, renderer, This->palsize, 1, FALSE, FALSE, 0);
|
376 | 376 | glTexture_Lock(This->texture, 0, NULL, &ddsd, 0, FALSE);
|
377 | 377 | memcpy(ddsd.lpSurface, This->palette, (This->palsize * 4));
|
378 | 378 | glTexture_Unlock(This->texture, 0, NULL, FALSE);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | texture = parenttex;
|
290 | 290 | glTexture_AddRef(texture);
|
291 | 291 | }
|
292 | | - else glTexture_Create(&ddsd, &texture, ddInterface->renderer, fakex, fakey, hasstencil, FALSE);
|
| 292 | + else glTexture_Create(&ddsd, &texture, ddInterface->renderer, fakex, fakey, hasstencil, FALSE, 0);
|
293 | 293 | if (!(ddsd.dwFlags & DDSD_PITCH))
|
294 | 294 | {
|
295 | 295 | ddsd.dwFlags |= DDSD_PITCH;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -3596,7 +3596,7 @@ |
3597 | 3597 | ddsd.dwWidth = x2;
|
3598 | 3598 | ddsd.lPitch = x2 * 4;
|
3599 | 3599 | ddsd.dwHeight = y2;
|
3600 | | - glTexture_Create(&ddsd, &This->backbuffer, This, x2, y2, FALSE, TRUE);
|
| 3600 | + glTexture_Create(&ddsd, &This->backbuffer, This, x2, y2, FALSE, TRUE, 0);
|
3601 | 3601 | }
|
3602 | 3602 | if((This->backbuffer->levels[0].ddsd.dwWidth != x2) || (This->backbuffer->levels[0].ddsd.dwHeight != y2))
|
3603 | 3603 | {
|
— | — | @@ -3651,7 +3651,7 @@ |
3652 | 3652 | ddsd.dwWidth = x2;
|
3653 | 3653 | ddsd.lPitch = x2 * 4;
|
3654 | 3654 | ddsd.dwHeight = y2;
|
3655 | | - glTexture_Create(&ddsd, &This->backbuffer, This, x2, y2, FALSE, TRUE);
|
| 3655 | + glTexture_Create(&ddsd, &This->backbuffer, This, x2, y2, FALSE, TRUE, 0);
|
3656 | 3656 | }
|
3657 | 3657 | if ((This->backbuffer->levels[0].ddsd.dwWidth < x2) || (This->backbuffer->levels[0].ddsd.dwHeight < y2))
|
3658 | 3658 | {
|
Index: ddraw/glTexture.cpp |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | *y = max(1, (DWORD)floorf((float)*y / 2.0f));
|
129 | 129 | }
|
130 | 130 |
|
131 | | -HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend)
|
| 131 | +HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend, GLenum targetoverride)
|
132 | 132 | {
|
133 | 133 | glTexture *newtexture;
|
134 | 134 | if (!texture) return DDERR_INVALIDPARAMS;
|
— | — | @@ -143,6 +143,7 @@ |
144 | 144 | newtexture->useconv = FALSE;
|
145 | 145 | newtexture->pboPack = NULL;
|
146 | 146 | newtexture->pboUnpack = NULL;
|
| 147 | + newtexture->target = targetoverride;
|
147 | 148 | if (bigwidth)
|
148 | 149 | {
|
149 | 150 | newtexture->bigwidth = bigwidth;
|
— | — | @@ -405,7 +406,7 @@ |
406 | 407 | ddsd.dwWidth = This->levels[0].ddsd.dwWidth;
|
407 | 408 | ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
|
408 | 409 | ddsd.dwHeight = This->levels[0].ddsd.dwHeight;
|
409 | | - glTexture_Create(&ddsd, &This->dummycolor, This->renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, backend);
|
| 410 | + glTexture_Create(&ddsd, &This->dummycolor, This->renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, backend, 0);
|
410 | 411 | }
|
411 | 412 | void glTexture_DeleteDummyColor(glTexture *This, BOOL backend)
|
412 | 413 | {
|
— | — | @@ -489,12 +490,12 @@ |
490 | 491 | inpitch * This->levels[level].ddsd.dwHeight, NULL, GL_DYNAMIC_READ);
|
491 | 492 | BufferObject_Bind(This->pboPack, GL_PIXEL_PACK_BUFFER);
|
492 | 493 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
493 | | - This->renderer->ext->glGetTextureImageEXT(This->id, GL_TEXTURE_2D, level, This->format, This->type, 0);
|
| 494 | + This->renderer->ext->glGetTextureImageEXT(This->id, This->target, level, This->format, This->type, 0);
|
494 | 495 | else
|
495 | 496 | {
|
496 | 497 | glUtil_SetActiveTexture(This->renderer->util, 0);
|
497 | 498 | glUtil_SetTexture(This->renderer->util, 0, This);
|
498 | | - glGetTexImage(GL_TEXTURE_2D, level, This->format, This->type, 0);
|
| 499 | + glGetTexImage(This->target, level, This->format, This->type, 0);
|
499 | 500 | }
|
500 | 501 | BufferObject_Unbind(This->pboPack, GL_PIXEL_PACK_BUFFER);
|
501 | 502 | readbuffer = (char*)BufferObject_Map(This->pboPack, GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
— | — | @@ -512,23 +513,23 @@ |
513 | 514 | if ((bigx == x && bigy == y) || !This->levels[level].bigbuffer)
|
514 | 515 | {
|
515 | 516 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
516 | | - This->renderer->ext->glGetTextureImageEXT(This->id, GL_TEXTURE_2D, level, This->format, This->type, This->levels[level].buffer);
|
| 517 | + This->renderer->ext->glGetTextureImageEXT(This->id, This->target, level, This->format, This->type, This->levels[level].buffer);
|
517 | 518 | else
|
518 | 519 | {
|
519 | 520 | glUtil_SetActiveTexture(This->renderer->util, 0);
|
520 | 521 | glUtil_SetTexture(This->renderer->util, 0, This);
|
521 | | - glGetTexImage(GL_TEXTURE_2D, level, This->format, This->type, This->levels[level].buffer);
|
| 522 | + glGetTexImage(This->target, level, This->format, This->type, This->levels[level].buffer);
|
522 | 523 | }
|
523 | 524 | }
|
524 | 525 | else
|
525 | 526 | {
|
526 | 527 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
527 | | - This->renderer->ext->glGetTextureImageEXT(This->id, GL_TEXTURE_2D, level, This->format, This->type, This->levels[level].bigbuffer);
|
| 528 | + This->renderer->ext->glGetTextureImageEXT(This->id, This->target, level, This->format, This->type, This->levels[level].bigbuffer);
|
528 | 529 | else
|
529 | 530 | {
|
530 | 531 | glUtil_SetActiveTexture(This->renderer->util, 0);
|
531 | 532 | glUtil_SetTexture(This->renderer->util, 0, This);
|
532 | | - glGetTexImage(GL_TEXTURE_2D, level, This->format, This->type, This->levels[level].bigbuffer);
|
| 533 | + glGetTexImage(This->target, level, This->format, This->type, This->levels[level].bigbuffer);
|
533 | 534 | }
|
534 | 535 | switch (bpp)
|
535 | 536 | {
|
— | — | @@ -598,9 +599,9 @@ |
599 | 600 | BufferObject_Bind(This->pboUnpack, GL_PIXEL_UNPACK_BUFFER);
|
600 | 601 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
601 | 602 | {
|
602 | | - /*if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, GL_TEXTURE_2D, level, This->internalformats[0],
|
| 603 | + /*if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, This->target, level, This->internalformats[0],
|
603 | 604 | width, height, 0, This->format, This->type, data);
|
604 | | - else */This->renderer->ext->glTextureSubImage2DEXT(This->id, GL_TEXTURE_2D, level,
|
| 605 | + else */This->renderer->ext->glTextureSubImage2DEXT(This->id, This->target, level,
|
605 | 606 | 0, 0, width, height, This->format, This->type, 0);
|
606 | 607 | }
|
607 | 608 | else
|
— | — | @@ -607,8 +608,8 @@ |
608 | 609 | {
|
609 | 610 | glUtil_SetActiveTexture(util, 0);
|
610 | 611 | glUtil_SetTexture(util, 0, This);
|
611 | | - /*if (dorealloc)glTexImage2D(GL_TEXTURE_2D, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
612 | | - else */glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, This->format, This->type, 0);
|
| 612 | + /*if (dorealloc)glTexImage2D(This->target, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
| 613 | + else */glTexSubImage2D(This->target, level, 0, 0, width, height, This->format, This->type, 0);
|
613 | 614 | }
|
614 | 615 | BufferObject_Unbind(This->pboUnpack, GL_PIXEL_UNPACK_BUFFER);
|
615 | 616 | }
|
— | — | @@ -621,9 +622,9 @@ |
622 | 623 | ClearError();
|
623 | 624 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
624 | 625 | {
|
625 | | - if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, GL_TEXTURE_2D, level,
|
| 626 | + if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, This->target, level,
|
626 | 627 | This->internalformats[0], width, height, 0, This->format, This->type, data);
|
627 | | - else This->renderer->ext->glTextureSubImage2DEXT(This->id, GL_TEXTURE_2D, level,
|
| 628 | + else This->renderer->ext->glTextureSubImage2DEXT(This->id, This->target, level,
|
628 | 629 | 0, 0, width, height, This->format, This->type, data);
|
629 | 630 | }
|
630 | 631 | else
|
— | — | @@ -630,8 +631,8 @@ |
631 | 632 | {
|
632 | 633 | glUtil_SetActiveTexture(util, 0);
|
633 | 634 | glUtil_SetTexture(util, 0, This);
|
634 | | - if (dorealloc) glTexImage2D(GL_TEXTURE_2D, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
635 | | - else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, This->format, This->type, data);
|
| 635 | + if (dorealloc) glTexImage2D(This->target, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
| 636 | + else glTexSubImage2D(This->target, level, 0, 0, width, height, This->format, This->type, data);
|
636 | 637 | }
|
637 | 638 | error = glGetError();
|
638 | 639 | if (error != GL_NO_ERROR)
|
— | — | @@ -651,9 +652,9 @@ |
652 | 653 | {
|
653 | 654 | if (This->renderer->ext->GLEXT_EXT_direct_state_access)
|
654 | 655 | {
|
655 | | - if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, GL_TEXTURE_2D, level, This->internalformats[0],
|
| 656 | + if (dorealloc)This->renderer->ext->glTextureImage2DEXT(This->id, This->target, level, This->internalformats[0],
|
656 | 657 | width, height, 0, This->format, This->type, data);
|
657 | | - else This->renderer->ext->glTextureSubImage2DEXT(This->id, GL_TEXTURE_2D, level,
|
| 658 | + else This->renderer->ext->glTextureSubImage2DEXT(This->id, This->target, level,
|
658 | 659 | 0, 0, width, height, This->format, This->type, data);
|
659 | 660 | }
|
660 | 661 | else
|
— | — | @@ -660,8 +661,8 @@ |
661 | 662 | {
|
662 | 663 | glUtil_SetActiveTexture(util, 0);
|
663 | 664 | glUtil_SetTexture(util, 0, This);
|
664 | | - if (dorealloc)glTexImage2D(GL_TEXTURE_2D, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
665 | | - else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, This->format, This->type, data);
|
| 665 | + if (dorealloc)glTexImage2D(This->target, level, This->internalformats[0], width, height, 0, This->format, This->type, data);
|
| 666 | + else glTexSubImage2D(This->target, level, 0, 0, width, height, This->format, This->type, data);
|
666 | 667 | }
|
667 | 668 | }
|
668 | 669 | }
|
— | — | @@ -742,9 +743,9 @@ |
743 | 744 | This->internalformats[7] = 0;
|
744 | 745 | ClearError();
|
745 | 746 | if ((This->levels[0].ddsd.dwWidth != This->bigwidth) || (This->levels[0].ddsd.dwHeight != This->bigheight))
|
746 | | - glTexImage2D(GL_TEXTURE_2D, i, This->internalformats[0], This->bigwidth,
|
| 747 | + glTexImage2D(This->target, i, This->internalformats[0], This->bigwidth,
|
747 | 748 | This->bigheight, 0, This->format, This->type, This->levels[i].bigbuffer);
|
748 | | - else glTexImage2D(GL_TEXTURE_2D, i, This->internalformats[0], This->levels[i].ddsd.dwWidth,
|
| 749 | + else glTexImage2D(This->target, i, This->internalformats[0], This->levels[i].ddsd.dwWidth,
|
749 | 750 | This->levels[i].ddsd.dwHeight, 0, This->format, This->type, This->levels[i].buffer);
|
750 | 751 | error = glGetError();
|
751 | 752 | if (error != GL_NO_ERROR)
|
— | — | @@ -826,6 +827,7 @@ |
827 | 828 | This->format = GL_LUMINANCE;
|
828 | 829 | }
|
829 | 830 | This->type = GL_UNSIGNED_BYTE;
|
| 831 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
830 | 832 | This->colororder = 4;
|
831 | 833 | This->colorsizes[0] = 1;
|
832 | 834 | This->colorsizes[1] = 1;
|
— | — | @@ -853,6 +855,7 @@ |
854 | 856 | This->format = GL_LUMINANCE;
|
855 | 857 | }
|
856 | 858 | This->type = GL_UNSIGNED_BYTE;
|
| 859 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
857 | 860 | This->colororder = 4;
|
858 | 861 | This->colorsizes[0] = 3;
|
859 | 862 | This->colorsizes[1] = 3;
|
— | — | @@ -880,6 +883,7 @@ |
881 | 884 | This->format = GL_LUMINANCE;
|
882 | 885 | }
|
883 | 886 | This->type = GL_UNSIGNED_BYTE;
|
| 887 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
884 | 888 | This->colororder = 4;
|
885 | 889 | This->colorsizes[0] = 15;
|
886 | 890 | This->colorsizes[1] = 15;
|
— | — | @@ -903,6 +907,7 @@ |
904 | 908 | This->format = GL_LUMINANCE;
|
905 | 909 | }
|
906 | 910 | This->type = GL_UNSIGNED_BYTE;
|
| 911 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
907 | 912 | This->colororder = 4;
|
908 | 913 | This->colorsizes[0] = 255;
|
909 | 914 | This->colorsizes[1] = 255;
|
— | — | @@ -919,6 +924,7 @@ |
920 | 925 | This->internalformats[2] = GL_RGBA8;
|
921 | 926 | This->format = GL_RGB;
|
922 | 927 | This->type = GL_UNSIGNED_BYTE_3_3_2;
|
| 928 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
923 | 929 | This->colororder = 1;
|
924 | 930 | This->colorsizes[0] = 7;
|
925 | 931 | This->colorsizes[1] = 7;
|
— | — | @@ -934,6 +940,7 @@ |
935 | 941 | This->internalformats[1] = GL_RGBA8;
|
936 | 942 | This->format = GL_BGRA;
|
937 | 943 | This->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 944 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
938 | 945 | This->colororder = 1;
|
939 | 946 | This->colorsizes[0] = 31;
|
940 | 947 | This->colorsizes[1] = 31;
|
— | — | @@ -950,6 +957,7 @@ |
951 | 958 | This->internalformats[2] = GL_RGBA8;
|
952 | 959 | This->format = GL_RGB;
|
953 | 960 | This->type = GL_UNSIGNED_SHORT_5_6_5;
|
| 961 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
954 | 962 | This->colororder = 1;
|
955 | 963 | This->colorsizes[0] = 31;
|
956 | 964 | This->colorsizes[1] = 63;
|
— | — | @@ -965,6 +973,7 @@ |
966 | 974 | This->internalformats[1] = GL_RGBA8;
|
967 | 975 | This->format = GL_BGR;
|
968 | 976 | This->type = GL_UNSIGNED_BYTE;
|
| 977 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
969 | 978 | This->colororder = 1;
|
970 | 979 | This->colorsizes[0] = 255;
|
971 | 980 | This->colorsizes[1] = 255;
|
— | — | @@ -980,6 +989,7 @@ |
981 | 990 | This->internalformats[1] = GL_RGBA8;
|
982 | 991 | This->format = GL_RGB;
|
983 | 992 | This->type = GL_UNSIGNED_BYTE;
|
| 993 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
984 | 994 | This->colororder = 1;
|
985 | 995 | This->colorsizes[0] = 255;
|
986 | 996 | This->colorsizes[1] = 255;
|
— | — | @@ -994,6 +1004,7 @@ |
995 | 1005 | This->internalformats[0] = GL_RGBA8;
|
996 | 1006 | This->format = GL_BGRA;
|
997 | 1007 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 1008 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
998 | 1009 | This->colororder = 1;
|
999 | 1010 | This->colorsizes[0] = 255;
|
1000 | 1011 | This->colorsizes[1] = 255;
|
— | — | @@ -1008,6 +1019,7 @@ |
1009 | 1020 | This->internalformats[0] = GL_RGBA8;
|
1010 | 1021 | This->format = GL_RGBA;
|
1011 | 1022 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 1023 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1012 | 1024 | This->colororder = 0;
|
1013 | 1025 | This->colorsizes[0] = 255;
|
1014 | 1026 | This->colorsizes[1] = 255;
|
— | — | @@ -1026,6 +1038,7 @@ |
1027 | 1039 | This->internalformats[0] = GL_RGBA8;
|
1028 | 1040 | This->format = GL_BGRA;
|
1029 | 1041 | This->type = GL_UNSIGNED_BYTE;
|
| 1042 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1030 | 1043 | This->colororder = 1;
|
1031 | 1044 | This->colorsizes[0] = 7;
|
1032 | 1045 | This->colorsizes[1] = 7;
|
— | — | @@ -1041,6 +1054,7 @@ |
1042 | 1055 | This->internalformats[1] = GL_RGBA8;
|
1043 | 1056 | This->format = GL_BGRA;
|
1044 | 1057 | This->type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
| 1058 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1045 | 1059 | This->colororder = 1;
|
1046 | 1060 | This->colorsizes[0] = 15;
|
1047 | 1061 | This->colorsizes[1] = 15;
|
— | — | @@ -1056,6 +1070,7 @@ |
1057 | 1071 | This->internalformats[1] = GL_RGBA8;
|
1058 | 1072 | This->format = GL_BGRA;
|
1059 | 1073 | This->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 1074 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1060 | 1075 | This->colorbits[0] = 5;
|
1061 | 1076 | This->colorbits[1] = 5;
|
1062 | 1077 | This->colorbits[2] = 5;
|
— | — | @@ -1066,6 +1081,7 @@ |
1067 | 1082 | This->internalformats[0] = GL_RGBA8;
|
1068 | 1083 | This->format = GL_BGRA;
|
1069 | 1084 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 1085 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1070 | 1086 | This->colororder = 1;
|
1071 | 1087 | This->colorsizes[0] = 255;
|
1072 | 1088 | This->colorsizes[1] = 255;
|
— | — | @@ -1082,6 +1098,7 @@ |
1083 | 1099 | This->internalformats[2] = GL_RGBA8;
|
1084 | 1100 | This->format = GL_LUMINANCE;
|
1085 | 1101 | This->type = GL_UNSIGNED_BYTE;
|
| 1102 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1086 | 1103 | This->colororder = 5;
|
1087 | 1104 | This->colorsizes[0] = 255;
|
1088 | 1105 | This->colorsizes[1] = 255;
|
— | — | @@ -1096,6 +1113,7 @@ |
1097 | 1114 | This->internalformats[0] = GL_ALPHA8;
|
1098 | 1115 | This->format = GL_ALPHA;
|
1099 | 1116 | This->type = GL_UNSIGNED_BYTE;
|
| 1117 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1100 | 1118 | This->colororder = 6;
|
1101 | 1119 | This->colorsizes[0] = 255;
|
1102 | 1120 | This->colorsizes[1] = 255;
|
— | — | @@ -1111,6 +1129,7 @@ |
1112 | 1130 | This->internalformats[1] = GL_RGBA8;
|
1113 | 1131 | This->format = GL_LUMINANCE_ALPHA;
|
1114 | 1132 | This->type = GL_UNSIGNED_BYTE;
|
| 1133 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1115 | 1134 | This->colororder = 7;
|
1116 | 1135 | This->colorsizes[0] = 255;
|
1117 | 1136 | This->colorsizes[1] = 255;
|
— | — | @@ -1125,6 +1144,7 @@ |
1126 | 1145 | This->internalformats[0] = GL_DEPTH_COMPONENT16;
|
1127 | 1146 | This->format = GL_DEPTH_COMPONENT;
|
1128 | 1147 | This->type = GL_UNSIGNED_SHORT;
|
| 1148 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1129 | 1149 | This->colororder = 4;
|
1130 | 1150 | This->colorsizes[0] = 65535;
|
1131 | 1151 | This->colorsizes[1] = 65535;
|
— | — | @@ -1144,6 +1164,7 @@ |
1145 | 1165 | This->internalformats[0] = GL_DEPTH_COMPONENT24;
|
1146 | 1166 | This->format = GL_DEPTH_COMPONENT;
|
1147 | 1167 | This->type = GL_UNSIGNED_INT;
|
| 1168 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1148 | 1169 | This->colororder = 4;
|
1149 | 1170 | This->colorsizes[0] = 16777215;
|
1150 | 1171 | This->colorsizes[1] = 16777215;
|
— | — | @@ -1159,6 +1180,7 @@ |
1160 | 1181 | This->internalformats[0] = GL_DEPTH_COMPONENT24;
|
1161 | 1182 | This->format = GL_DEPTH_COMPONENT;
|
1162 | 1183 | This->type = GL_UNSIGNED_INT;
|
| 1184 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1163 | 1185 | This->colororder = 4;
|
1164 | 1186 | This->colorsizes[0] = 16777215;
|
1165 | 1187 | This->colorsizes[1] = 16777215;
|
— | — | @@ -1173,6 +1195,7 @@ |
1174 | 1196 | This->internalformats[0] = GL_DEPTH_COMPONENT32;
|
1175 | 1197 | This->format = GL_DEPTH_COMPONENT;
|
1176 | 1198 | This->type = GL_UNSIGNED_INT;
|
| 1199 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1177 | 1200 | This->colororder = 4;
|
1178 | 1201 | This->colorsizes[0] = 4294967295;
|
1179 | 1202 | This->colorsizes[1] = 4294967295;
|
— | — | @@ -1188,6 +1211,7 @@ |
1189 | 1212 | This->internalformats[0] = GL_DEPTH24_STENCIL8;
|
1190 | 1213 | This->format = GL_DEPTH_STENCIL;
|
1191 | 1214 | This->type = GL_UNSIGNED_INT_24_8;
|
| 1215 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1192 | 1216 | This->colororder = 7;
|
1193 | 1217 | This->colorsizes[0] = 16777215;
|
1194 | 1218 | This->colorsizes[1] = 16777215;
|
— | — | @@ -1203,6 +1227,7 @@ |
1204 | 1228 | This->internalformats[0] = GL_DEPTH24_STENCIL8;
|
1205 | 1229 | This->format = GL_DEPTH_STENCIL;
|
1206 | 1230 | This->type = GL_UNSIGNED_INT_24_8;
|
| 1231 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
1207 | 1232 | This->colororder = 7;
|
1208 | 1233 | This->colorsizes[0] = 16777215;
|
1209 | 1234 | This->colorsizes[1] = 16777215;
|
— | — | @@ -1234,11 +1259,11 @@ |
1235 | 1260 | }
|
1236 | 1261 | }
|
1237 | 1262 | This->wraps = This->wrapt = GL_CLAMP_TO_EDGE;
|
1238 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, This->minfilter);
|
1239 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, This->magfilter);
|
1240 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, This->wraps);
|
1241 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, This->wrapt);
|
1242 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->miplevel - 1);
|
| 1263 | + glTexParameteri(This->target, GL_TEXTURE_MIN_FILTER, This->minfilter);
|
| 1264 | + glTexParameteri(This->target, GL_TEXTURE_MAG_FILTER, This->magfilter);
|
| 1265 | + glTexParameteri(This->target, GL_TEXTURE_WRAP_S, This->wraps);
|
| 1266 | + glTexParameteri(This->target, GL_TEXTURE_WRAP_T, This->wrapt);
|
| 1267 | + glTexParameteri(This->target, GL_TEXTURE_MAX_LEVEL, This->miplevel - 1);
|
1243 | 1268 | if ((This->levels[0].ddsd.dwWidth != This->bigwidth) || (This->levels[0].ddsd.dwHeight != This->bigheight))
|
1244 | 1269 | {
|
1245 | 1270 | x = This->bigwidth;
|
— | — | @@ -1254,7 +1279,7 @@ |
1255 | 1280 | do
|
1256 | 1281 | {
|
1257 | 1282 | ClearError();
|
1258 | | - glTexImage2D(GL_TEXTURE_2D, i, This->internalformats[0], x, y, 0, This->format, This->type, NULL);
|
| 1283 | + glTexImage2D(This->target, i, This->internalformats[0], x, y, 0, This->format, This->type, NULL);
|
1259 | 1284 | This->levels[i].dirty |= 2;
|
1260 | 1285 | ShrinkMip(&x, &y);
|
1261 | 1286 | error = glGetError();
|
— | — | @@ -1332,14 +1357,14 @@ |
1333 | 1358 | }
|
1334 | 1359 | else if (renderer->ext->GLEXT_EXT_direct_state_access)
|
1335 | 1360 | {
|
1336 | | - renderer->ext->glTextureParameteriEXT(This->id, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag);
|
1337 | | - renderer->ext->glTextureParameteriEXT(This->id, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min);
|
| 1361 | + renderer->ext->glTextureParameteriEXT(This->id, This->target, GL_TEXTURE_MAG_FILTER, mag);
|
| 1362 | + renderer->ext->glTextureParameteriEXT(This->id, This->target, GL_TEXTURE_MIN_FILTER, min);
|
1338 | 1363 | }
|
1339 | 1364 | else
|
1340 | 1365 | {
|
1341 | 1366 | glUtil_SetTexture(renderer->util, level, This);
|
1342 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag);
|
1343 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min);
|
| 1367 | + glTexParameteri(This->target, GL_TEXTURE_MAG_FILTER, mag);
|
| 1368 | + glTexParameteri(This->target, GL_TEXTURE_MIN_FILTER, min);
|
1344 | 1369 | }
|
1345 | 1370 | This->magfilter = mag;
|
1346 | 1371 | This->minfilter = min;
|
— | — | @@ -1347,8 +1372,8 @@ |
1348 | 1373 | else
|
1349 | 1374 | {
|
1350 | 1375 | glUtil_SetTexture(renderer->util, level, NULL);
|
1351 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag);
|
1352 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min);
|
| 1376 | + glTexParameteri(This->target, GL_TEXTURE_MAG_FILTER, mag);
|
| 1377 | + glTexParameteri(This->target, GL_TEXTURE_MIN_FILTER, min);
|
1353 | 1378 | }
|
1354 | 1379 | }
|
1355 | 1380 | }
|
Index: ddraw/glTexture.h |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 |
|
34 | 34 | DWORD CalculateMipLevels(DWORD width, DWORD height);
|
35 | 35 |
|
36 | | -HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend);
|
| 36 | +HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend, GLenum targetoverride);
|
37 | 37 | ULONG glTexture_AddRef(glTexture *This);
|
38 | 38 | ULONG glTexture_Release(glTexture *This, BOOL backend);
|
39 | 39 | HRESULT glTexture_Lock(glTexture *This, GLint level, LPRECT r, LPDDSURFACEDESC2 ddsd, DWORD flags, BOOL backend);
|
Index: ddraw/glUtil.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2017 William Feely
|
| 3 | +// Copyright (C) 2012-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -150,18 +150,18 @@ |
151 | 151 | {
|
152 | 152 | if(This->currentfbo != fbo) This->ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
|
153 | 153 | This->currentfbo = fbo;
|
154 | | - This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,color->id,level);
|
| 154 | + This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,color->target,color->id,level);
|
155 | 155 | fbo->fbcolor = color;
|
156 | 156 | if(stencil)
|
157 | 157 | {
|
158 | 158 | if(!fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
159 | | - if(z)This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,z->id,zlevel);
|
| 159 | + if(z)This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,z->target,z->id,zlevel);
|
160 | 160 | else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
161 | 161 | }
|
162 | 162 | else
|
163 | 163 | {
|
164 | 164 | if(fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
165 | | - if(z) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,z->id,zlevel);
|
| 165 | + if(z) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,z->target,z->id,zlevel);
|
166 | 166 | else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
167 | 167 | }
|
168 | 168 | fbo->stencil = stencil;
|
— | — | @@ -172,14 +172,14 @@ |
173 | 173 | {
|
174 | 174 | if (This->currentfbo != fbo) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
175 | 175 | This->currentfbo = fbo;
|
176 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color->id, level);
|
| 176 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, color->target, color->id, level);
|
177 | 177 | fbo->fbcolor = color;
|
178 | 178 | if(stencil)
|
179 | 179 | {
|
180 | 180 | if(z)
|
181 | 181 | {
|
182 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
183 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
| 182 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, z->target, z->id, zlevel);
|
| 183 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, z->target, z->id, zlevel);
|
184 | 184 | }
|
185 | 185 | else
|
186 | 186 | {
|
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | else
|
192 | 192 | {
|
193 | 193 | This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
194 | | - if (z)This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
| 194 | + if (z)This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, z->target, z->id, zlevel);
|
195 | 195 | else This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
196 | 196 | }
|
197 | 197 | fbo->stencil = stencil;
|
— | — | @@ -648,13 +648,22 @@ |
649 | 649 | void glUtil_SetTexture(glUtil *This, unsigned int level, glTexture *texture)
|
650 | 650 | {
|
651 | 651 | GLuint texname;
|
| 652 | + GLenum target;
|
652 | 653 | if (level >= 16) return;
|
653 | | - if (!texture) texname = 0;
|
654 | | - else texname = texture->id;
|
| 654 | + if (!texture)
|
| 655 | + {
|
| 656 | + texname = 0;
|
| 657 | + target = GL_TEXTURE_2D;
|
| 658 | + }
|
| 659 | + else
|
| 660 | + {
|
| 661 | + texname = texture->id;
|
| 662 | + target = texture->target;
|
| 663 | + }
|
655 | 664 | if (texname != This->textures[level])
|
656 | 665 | {
|
657 | 666 | glUtil_SetActiveTexture(This, level);
|
658 | | - glBindTexture(GL_TEXTURE_2D, texname);
|
| 667 | + glBindTexture(target, texname);
|
659 | 668 | //This->textures[level] = texname;
|
660 | 669 | }
|
661 | 670 | }
|
Index: ddraw/struct.h |
— | — | @@ -310,6 +310,7 @@ |
311 | 311 | int colororder;
|
312 | 312 | GLenum format;
|
313 | 313 | GLenum type;
|
| 314 | + GLenum target;
|
314 | 315 | BOOL zhasstencil;
|
315 | 316 | BOOL useconv;
|
316 | 317 | int convfunctionupload;
|