DXGL r900 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r899‎ | r900 | r901 >
Date:23:01, 9 March 2019
Author:admin
Status:new
Tags:
Comment:
Change texture target to a variable.
Modified paths:
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.c (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)
  • /ddraw/glTexture.h (modified) (history)
  • /ddraw/glUtil.cpp (modified) (history)
  • /ddraw/struct.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawClipper.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2016 William Feely
 3+// Copyright (C) 2011-2019 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -519,5 +519,5 @@
520520 ddsd.dwWidth = texture->levels[0].ddsd.dwWidth;
521521 ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
522522 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);
524524 }
\ No newline at end of file
Index: ddraw/glDirectDrawPalette.c
@@ -371,7 +371,7 @@
372372 memcpy(&ddsd, &ddsd256pal, sizeof(DDSURFACEDESC2));
373373 ddsd.dwWidth = This->palsize;
374374 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);
376376 glTexture_Lock(This->texture, 0, NULL, &ddsd, 0, FALSE);
377377 memcpy(ddsd.lpSurface, This->palette, (This->palsize * 4));
378378 glTexture_Unlock(This->texture, 0, NULL, FALSE);
Index: ddraw/glDirectDrawSurface.cpp
@@ -288,7 +288,7 @@
289289 texture = parenttex;
290290 glTexture_AddRef(texture);
291291 }
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);
293293 if (!(ddsd.dwFlags & DDSD_PITCH))
294294 {
295295 ddsd.dwFlags |= DDSD_PITCH;
Index: ddraw/glRenderer.cpp
@@ -3596,7 +3596,7 @@
35973597 ddsd.dwWidth = x2;
35983598 ddsd.lPitch = x2 * 4;
35993599 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);
36013601 }
36023602 if((This->backbuffer->levels[0].ddsd.dwWidth != x2) || (This->backbuffer->levels[0].ddsd.dwHeight != y2))
36033603 {
@@ -3651,7 +3651,7 @@
36523652 ddsd.dwWidth = x2;
36533653 ddsd.lPitch = x2 * 4;
36543654 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);
36563656 }
36573657 if ((This->backbuffer->levels[0].ddsd.dwWidth < x2) || (This->backbuffer->levels[0].ddsd.dwHeight < y2))
36583658 {
Index: ddraw/glTexture.cpp
@@ -127,7 +127,7 @@
128128 *y = max(1, (DWORD)floorf((float)*y / 2.0f));
129129 }
130130
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)
132132 {
133133 glTexture *newtexture;
134134 if (!texture) return DDERR_INVALIDPARAMS;
@@ -143,6 +143,7 @@
144144 newtexture->useconv = FALSE;
145145 newtexture->pboPack = NULL;
146146 newtexture->pboUnpack = NULL;
 147+ newtexture->target = targetoverride;
147148 if (bigwidth)
148149 {
149150 newtexture->bigwidth = bigwidth;
@@ -405,7 +406,7 @@
406407 ddsd.dwWidth = This->levels[0].ddsd.dwWidth;
407408 ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
408409 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);
410411 }
411412 void glTexture_DeleteDummyColor(glTexture *This, BOOL backend)
412413 {
@@ -489,12 +490,12 @@
490491 inpitch * This->levels[level].ddsd.dwHeight, NULL, GL_DYNAMIC_READ);
491492 BufferObject_Bind(This->pboPack, GL_PIXEL_PACK_BUFFER);
492493 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);
494495 else
495496 {
496497 glUtil_SetActiveTexture(This->renderer->util, 0);
497498 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);
499500 }
500501 BufferObject_Unbind(This->pboPack, GL_PIXEL_PACK_BUFFER);
501502 readbuffer = (char*)BufferObject_Map(This->pboPack, GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
@@ -512,23 +513,23 @@
513514 if ((bigx == x && bigy == y) || !This->levels[level].bigbuffer)
514515 {
515516 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);
517518 else
518519 {
519520 glUtil_SetActiveTexture(This->renderer->util, 0);
520521 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);
522523 }
523524 }
524525 else
525526 {
526527 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);
528529 else
529530 {
530531 glUtil_SetActiveTexture(This->renderer->util, 0);
531532 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);
533534 }
534535 switch (bpp)
535536 {
@@ -598,9 +599,9 @@
599600 BufferObject_Bind(This->pboUnpack, GL_PIXEL_UNPACK_BUFFER);
600601 if (This->renderer->ext->GLEXT_EXT_direct_state_access)
601602 {
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],
603604 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,
605606 0, 0, width, height, This->format, This->type, 0);
606607 }
607608 else
@@ -607,8 +608,8 @@
608609 {
609610 glUtil_SetActiveTexture(util, 0);
610611 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);
613614 }
614615 BufferObject_Unbind(This->pboUnpack, GL_PIXEL_UNPACK_BUFFER);
615616 }
@@ -621,9 +622,9 @@
622623 ClearError();
623624 if (This->renderer->ext->GLEXT_EXT_direct_state_access)
624625 {
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,
626627 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,
628629 0, 0, width, height, This->format, This->type, data);
629630 }
630631 else
@@ -630,8 +631,8 @@
631632 {
632633 glUtil_SetActiveTexture(util, 0);
633634 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);
636637 }
637638 error = glGetError();
638639 if (error != GL_NO_ERROR)
@@ -651,9 +652,9 @@
652653 {
653654 if (This->renderer->ext->GLEXT_EXT_direct_state_access)
654655 {
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],
656657 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,
658659 0, 0, width, height, This->format, This->type, data);
659660 }
660661 else
@@ -660,8 +661,8 @@
661662 {
662663 glUtil_SetActiveTexture(util, 0);
663664 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);
666667 }
667668 }
668669 }
@@ -742,9 +743,9 @@
743744 This->internalformats[7] = 0;
744745 ClearError();
745746 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,
747748 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,
749750 This->levels[i].ddsd.dwHeight, 0, This->format, This->type, This->levels[i].buffer);
750751 error = glGetError();
751752 if (error != GL_NO_ERROR)
@@ -826,6 +827,7 @@
827828 This->format = GL_LUMINANCE;
828829 }
829830 This->type = GL_UNSIGNED_BYTE;
 831+ if (!This->target) This->target = GL_TEXTURE_2D;
830832 This->colororder = 4;
831833 This->colorsizes[0] = 1;
832834 This->colorsizes[1] = 1;
@@ -853,6 +855,7 @@
854856 This->format = GL_LUMINANCE;
855857 }
856858 This->type = GL_UNSIGNED_BYTE;
 859+ if (!This->target) This->target = GL_TEXTURE_2D;
857860 This->colororder = 4;
858861 This->colorsizes[0] = 3;
859862 This->colorsizes[1] = 3;
@@ -880,6 +883,7 @@
881884 This->format = GL_LUMINANCE;
882885 }
883886 This->type = GL_UNSIGNED_BYTE;
 887+ if (!This->target) This->target = GL_TEXTURE_2D;
884888 This->colororder = 4;
885889 This->colorsizes[0] = 15;
886890 This->colorsizes[1] = 15;
@@ -903,6 +907,7 @@
904908 This->format = GL_LUMINANCE;
905909 }
906910 This->type = GL_UNSIGNED_BYTE;
 911+ if (!This->target) This->target = GL_TEXTURE_2D;
907912 This->colororder = 4;
908913 This->colorsizes[0] = 255;
909914 This->colorsizes[1] = 255;
@@ -919,6 +924,7 @@
920925 This->internalformats[2] = GL_RGBA8;
921926 This->format = GL_RGB;
922927 This->type = GL_UNSIGNED_BYTE_3_3_2;
 928+ if (!This->target) This->target = GL_TEXTURE_2D;
923929 This->colororder = 1;
924930 This->colorsizes[0] = 7;
925931 This->colorsizes[1] = 7;
@@ -934,6 +940,7 @@
935941 This->internalformats[1] = GL_RGBA8;
936942 This->format = GL_BGRA;
937943 This->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 944+ if (!This->target) This->target = GL_TEXTURE_2D;
938945 This->colororder = 1;
939946 This->colorsizes[0] = 31;
940947 This->colorsizes[1] = 31;
@@ -950,6 +957,7 @@
951958 This->internalformats[2] = GL_RGBA8;
952959 This->format = GL_RGB;
953960 This->type = GL_UNSIGNED_SHORT_5_6_5;
 961+ if (!This->target) This->target = GL_TEXTURE_2D;
954962 This->colororder = 1;
955963 This->colorsizes[0] = 31;
956964 This->colorsizes[1] = 63;
@@ -965,6 +973,7 @@
966974 This->internalformats[1] = GL_RGBA8;
967975 This->format = GL_BGR;
968976 This->type = GL_UNSIGNED_BYTE;
 977+ if (!This->target) This->target = GL_TEXTURE_2D;
969978 This->colororder = 1;
970979 This->colorsizes[0] = 255;
971980 This->colorsizes[1] = 255;
@@ -980,6 +989,7 @@
981990 This->internalformats[1] = GL_RGBA8;
982991 This->format = GL_RGB;
983992 This->type = GL_UNSIGNED_BYTE;
 993+ if (!This->target) This->target = GL_TEXTURE_2D;
984994 This->colororder = 1;
985995 This->colorsizes[0] = 255;
986996 This->colorsizes[1] = 255;
@@ -994,6 +1004,7 @@
9951005 This->internalformats[0] = GL_RGBA8;
9961006 This->format = GL_BGRA;
9971007 This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 1008+ if (!This->target) This->target = GL_TEXTURE_2D;
9981009 This->colororder = 1;
9991010 This->colorsizes[0] = 255;
10001011 This->colorsizes[1] = 255;
@@ -1008,6 +1019,7 @@
10091020 This->internalformats[0] = GL_RGBA8;
10101021 This->format = GL_RGBA;
10111022 This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 1023+ if (!This->target) This->target = GL_TEXTURE_2D;
10121024 This->colororder = 0;
10131025 This->colorsizes[0] = 255;
10141026 This->colorsizes[1] = 255;
@@ -1026,6 +1038,7 @@
10271039 This->internalformats[0] = GL_RGBA8;
10281040 This->format = GL_BGRA;
10291041 This->type = GL_UNSIGNED_BYTE;
 1042+ if (!This->target) This->target = GL_TEXTURE_2D;
10301043 This->colororder = 1;
10311044 This->colorsizes[0] = 7;
10321045 This->colorsizes[1] = 7;
@@ -1041,6 +1054,7 @@
10421055 This->internalformats[1] = GL_RGBA8;
10431056 This->format = GL_BGRA;
10441057 This->type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
 1058+ if (!This->target) This->target = GL_TEXTURE_2D;
10451059 This->colororder = 1;
10461060 This->colorsizes[0] = 15;
10471061 This->colorsizes[1] = 15;
@@ -1056,6 +1070,7 @@
10571071 This->internalformats[1] = GL_RGBA8;
10581072 This->format = GL_BGRA;
10591073 This->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 1074+ if (!This->target) This->target = GL_TEXTURE_2D;
10601075 This->colorbits[0] = 5;
10611076 This->colorbits[1] = 5;
10621077 This->colorbits[2] = 5;
@@ -1066,6 +1081,7 @@
10671082 This->internalformats[0] = GL_RGBA8;
10681083 This->format = GL_BGRA;
10691084 This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 1085+ if (!This->target) This->target = GL_TEXTURE_2D;
10701086 This->colororder = 1;
10711087 This->colorsizes[0] = 255;
10721088 This->colorsizes[1] = 255;
@@ -1082,6 +1098,7 @@
10831099 This->internalformats[2] = GL_RGBA8;
10841100 This->format = GL_LUMINANCE;
10851101 This->type = GL_UNSIGNED_BYTE;
 1102+ if (!This->target) This->target = GL_TEXTURE_2D;
10861103 This->colororder = 5;
10871104 This->colorsizes[0] = 255;
10881105 This->colorsizes[1] = 255;
@@ -1096,6 +1113,7 @@
10971114 This->internalformats[0] = GL_ALPHA8;
10981115 This->format = GL_ALPHA;
10991116 This->type = GL_UNSIGNED_BYTE;
 1117+ if (!This->target) This->target = GL_TEXTURE_2D;
11001118 This->colororder = 6;
11011119 This->colorsizes[0] = 255;
11021120 This->colorsizes[1] = 255;
@@ -1111,6 +1129,7 @@
11121130 This->internalformats[1] = GL_RGBA8;
11131131 This->format = GL_LUMINANCE_ALPHA;
11141132 This->type = GL_UNSIGNED_BYTE;
 1133+ if (!This->target) This->target = GL_TEXTURE_2D;
11151134 This->colororder = 7;
11161135 This->colorsizes[0] = 255;
11171136 This->colorsizes[1] = 255;
@@ -1125,6 +1144,7 @@
11261145 This->internalformats[0] = GL_DEPTH_COMPONENT16;
11271146 This->format = GL_DEPTH_COMPONENT;
11281147 This->type = GL_UNSIGNED_SHORT;
 1148+ if (!This->target) This->target = GL_TEXTURE_2D;
11291149 This->colororder = 4;
11301150 This->colorsizes[0] = 65535;
11311151 This->colorsizes[1] = 65535;
@@ -1144,6 +1164,7 @@
11451165 This->internalformats[0] = GL_DEPTH_COMPONENT24;
11461166 This->format = GL_DEPTH_COMPONENT;
11471167 This->type = GL_UNSIGNED_INT;
 1168+ if (!This->target) This->target = GL_TEXTURE_2D;
11481169 This->colororder = 4;
11491170 This->colorsizes[0] = 16777215;
11501171 This->colorsizes[1] = 16777215;
@@ -1159,6 +1180,7 @@
11601181 This->internalformats[0] = GL_DEPTH_COMPONENT24;
11611182 This->format = GL_DEPTH_COMPONENT;
11621183 This->type = GL_UNSIGNED_INT;
 1184+ if (!This->target) This->target = GL_TEXTURE_2D;
11631185 This->colororder = 4;
11641186 This->colorsizes[0] = 16777215;
11651187 This->colorsizes[1] = 16777215;
@@ -1173,6 +1195,7 @@
11741196 This->internalformats[0] = GL_DEPTH_COMPONENT32;
11751197 This->format = GL_DEPTH_COMPONENT;
11761198 This->type = GL_UNSIGNED_INT;
 1199+ if (!This->target) This->target = GL_TEXTURE_2D;
11771200 This->colororder = 4;
11781201 This->colorsizes[0] = 4294967295;
11791202 This->colorsizes[1] = 4294967295;
@@ -1188,6 +1211,7 @@
11891212 This->internalformats[0] = GL_DEPTH24_STENCIL8;
11901213 This->format = GL_DEPTH_STENCIL;
11911214 This->type = GL_UNSIGNED_INT_24_8;
 1215+ if (!This->target) This->target = GL_TEXTURE_2D;
11921216 This->colororder = 7;
11931217 This->colorsizes[0] = 16777215;
11941218 This->colorsizes[1] = 16777215;
@@ -1203,6 +1227,7 @@
12041228 This->internalformats[0] = GL_DEPTH24_STENCIL8;
12051229 This->format = GL_DEPTH_STENCIL;
12061230 This->type = GL_UNSIGNED_INT_24_8;
 1231+ if (!This->target) This->target = GL_TEXTURE_2D;
12071232 This->colororder = 7;
12081233 This->colorsizes[0] = 16777215;
12091234 This->colorsizes[1] = 16777215;
@@ -1234,11 +1259,11 @@
12351260 }
12361261 }
12371262 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);
12431268 if ((This->levels[0].ddsd.dwWidth != This->bigwidth) || (This->levels[0].ddsd.dwHeight != This->bigheight))
12441269 {
12451270 x = This->bigwidth;
@@ -1254,7 +1279,7 @@
12551280 do
12561281 {
12571282 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);
12591284 This->levels[i].dirty |= 2;
12601285 ShrinkMip(&x, &y);
12611286 error = glGetError();
@@ -1332,14 +1357,14 @@
13331358 }
13341359 else if (renderer->ext->GLEXT_EXT_direct_state_access)
13351360 {
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);
13381363 }
13391364 else
13401365 {
13411366 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);
13441369 }
13451370 This->magfilter = mag;
13461371 This->minfilter = min;
@@ -1347,8 +1372,8 @@
13481373 else
13491374 {
13501375 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);
13531378 }
13541379 }
13551380 }
Index: ddraw/glTexture.h
@@ -32,7 +32,7 @@
3333
3434 DWORD CalculateMipLevels(DWORD width, DWORD height);
3535
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);
3737 ULONG glTexture_AddRef(glTexture *This);
3838 ULONG glTexture_Release(glTexture *This, BOOL backend);
3939 HRESULT glTexture_Lock(glTexture *This, GLint level, LPRECT r, LPDDSURFACEDESC2 ddsd, DWORD flags, BOOL backend);
Index: ddraw/glUtil.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012-2017 William Feely
 3+// Copyright (C) 2012-2019 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -150,18 +150,18 @@
151151 {
152152 if(This->currentfbo != fbo) This->ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
153153 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);
155155 fbo->fbcolor = color;
156156 if(stencil)
157157 {
158158 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);
160160 else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
161161 }
162162 else
163163 {
164164 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);
166166 else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
167167 }
168168 fbo->stencil = stencil;
@@ -172,14 +172,14 @@
173173 {
174174 if (This->currentfbo != fbo) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
175175 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);
177177 fbo->fbcolor = color;
178178 if(stencil)
179179 {
180180 if(z)
181181 {
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);
184184 }
185185 else
186186 {
@@ -190,7 +190,7 @@
191191 else
192192 {
193193 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);
195195 else This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
196196 }
197197 fbo->stencil = stencil;
@@ -648,13 +648,22 @@
649649 void glUtil_SetTexture(glUtil *This, unsigned int level, glTexture *texture)
650650 {
651651 GLuint texname;
 652+ GLenum target;
652653 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+ }
655664 if (texname != This->textures[level])
656665 {
657666 glUtil_SetActiveTexture(This, level);
658 - glBindTexture(GL_TEXTURE_2D, texname);
 667+ glBindTexture(target, texname);
659668 //This->textures[level] = texname;
660669 }
661670 }
Index: ddraw/struct.h
@@ -310,6 +310,7 @@
311311 int colororder;
312312 GLenum format;
313313 GLenum type;
 314+ GLenum target;
314315 BOOL zhasstencil;
315316 BOOL useconv;
316317 int convfunctionupload;