diff --git a/source/blood/src/credits.cpp b/source/blood/src/credits.cpp index 9885d7079..742094d76 100644 --- a/source/blood/src/credits.cpp +++ b/source/blood/src/credits.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "screen.h" #include "sound.h" #include "view.h" +#include "../glbackend/glbackend.h" #include "sound/s_soundinternal.h" BEGIN_BLD_NS @@ -236,6 +237,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) Smacker_GetPalette(hSMK, palette); paletteSetColorTable(kSMKPal, palette, true); + GLInterface.EnableNonTransparent255(true); videoSetPalette(0, kSMKPal, 8+2); int nScale; @@ -290,6 +292,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) Smacker_Close(hSMK); inputState.ClearAllInput(); soundEngine->StopAllChannels(); + GLInterface.EnableNonTransparent255(false); videoSetPalette(0, 0, 8+2); tileDelete(kSMKTile); Bfree(pzSMK_); diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index fb320d759..2f8cb1ab8 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "animlib.h" #include "cmdlib.h" #include "compat.h" +#include "../glbackend/glbackend.h" #include "anim.h" @@ -300,6 +301,7 @@ int32_t Anim_Play(const char *fn) // OSD_Printf("msecs per frame: %d\n", msecsperframe); + GLInterface.EnableNonTransparent255(true); do { nextframetime += msecsperframe; @@ -391,6 +393,7 @@ int32_t Anim_Play(const char *fn) } } while (timerGetTicks() < nextframetime); } while (running); + GLInterface.EnableNonTransparent255(false); animvpx_print_stats(&codec); @@ -440,6 +443,7 @@ int32_t Anim_Play(const char *fn) paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true); // setpalette(0L,256L,tempbuf); + GLInterface.EnableNonTransparent255(true); P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2); #ifdef USE_OPENGL @@ -529,6 +533,7 @@ int32_t Anim_Play(const char *fn) } ++i; } while (i < numframes); + GLInterface.EnableNonTransparent255(false); end_anim_restore_gl: #ifdef USE_OPENGL diff --git a/source/glbackend/gl_palmanager.cpp b/source/glbackend/gl_palmanager.cpp index 4ce12c231..fa8026b84 100644 --- a/source/glbackend/gl_palmanager.cpp +++ b/source/glbackend/gl_palmanager.cpp @@ -285,20 +285,21 @@ void PaletteManager::BindPalswap(int index) } -int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap) +int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap, bool nontransparent255) { int realpal = palettemap[palette]; int realswap = palswapmap[palswap]; - int combined = (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap; + int combined = (nontransparent255? 0x2000000 : 0) + (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap; int* combinedindex = swappedpalmap.CheckKey(combined); if (combinedindex) return *combinedindex; PaletteData* paldata = &palettes[realpal]; PalswapData* swapdata = &palswaps[realswap]; PalEntry swappedpalette[256]; + int end = nontransparent255 ? 256 : 255; if (!brightmap) { - for (int i = 0; i < 255; i++) + for (int i = 0; i < end; i++) { int swapi = swapdata->lookup[i]; swappedpalette[i] = paldata->colors[swapi]; @@ -330,7 +331,7 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap) return -1; } } - swappedpalette[255] = 0; + if (!nontransparent255) swappedpalette[255] = 0; int palid = FindPalette((uint8_t*)swappedpalette); swappedpalmap.Insert(combined, palid); return palid; diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index a124002d9..ef599cd22 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -46,7 +46,6 @@ CVAR(Int, fixpalette, 0, 0) CVAR(Int, fixpalswap, 0, 0) - template void FlipNonSquareBlock(T* dst, const T* src, int x, int y, int srcpitch) { @@ -177,7 +176,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int if (TextureType == TT_TRUECOLOR) { /*lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true); - if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false); + if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255); } } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 11c791c51..5c17afbe9 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -83,7 +83,7 @@ public: void BindPalette(int index); void BindPalswap(int index); int ActivePalswap() const { return lastsindex; } - int LookupPalette(int palette, int palswap, bool brightmap); + int LookupPalette(int palette, int palswap, bool brightmap, bool nontransparent255 = false); const PalEntry *GetPaletteData(int palid) const { return palettes[palid].colors; } unsigned FindPalette(const uint8_t* paldata); @@ -194,6 +194,7 @@ class GLInstance int TextureType; int MatrixChange = 0; bool istrans = false; + bool g_nontransparent255 = false; // Ugh... This is for movie playback and needs to be maintained as global state. IVertexBuffer* LastVertexBuffer = nullptr; int LastVB_Offset[2] = {}; @@ -240,6 +241,11 @@ public: void EnableBlend(bool on); void EnableDepthTest(bool on); void EnableMultisampling(bool on); + void EnableNonTransparent255(bool on) + { + g_nontransparent255 = on; + } + void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2) { renderState.VertexBuffer = vb; diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 7e4c9abd5..c77ede25f 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "animlib.h" #include "compat.h" #include "cmdlib.h" +#include "../glbackend/glbackend.h" #include "anim.h" @@ -39,7 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_RR_NS // animsound_t.sound -EDUKE32_STATIC_ASSERT(INT16_MAX >= MAXSOUNDS); TArray g_Animations; dukeanim_t * g_animPtr; @@ -338,6 +338,7 @@ int32_t Anim_Play(const char *fn) // OSD_Printf("msecs per frame: %d\n", msecsperframe); + GLInterface.EnableNonTransparent255(true); do { nextframetime += msecsperframe; @@ -425,6 +426,7 @@ int32_t Anim_Play(const char *fn) } } while (timerGetTicks() < nextframetime); } while (running); + GLInterface.EnableNonTransparent255(false); animvpx_print_stats(&codec); @@ -482,6 +484,7 @@ int32_t Anim_Play(const char *fn) paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true); // setpalette(0L,256L,tempbuf); + GLInterface.EnableNonTransparent255(true); P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2); ototalclock = totalclock; @@ -564,6 +567,7 @@ int32_t Anim_Play(const char *fn) ++i; } while (i < numframes); + GLInterface.EnableNonTransparent255(false); end_anim_restore_gl: #ifdef USE_OPENGL diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index 477b64b4a..efec7b446 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -42,6 +42,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "animlib.h" #include "anim.h" +#include "../glbackend/glbackend.h" #include "common_game.h" @@ -273,6 +274,7 @@ playanm(short anim_num) //ototalclock = totalclock + 120*2; ototalclock = (int32_t) totalclock; + GLInterface.EnableNonTransparent255(true); for (i = 1; i < numframes; i++) { while (totalclock < ototalclock) @@ -324,6 +326,7 @@ playanm(short anim_num) ENDOFANIMLOOP: + GLInterface.EnableNonTransparent255(false); videoClearViewableArea(0L); videoNextPage();