From 9e7f91b5acb72ac89782c5bd010afae332724c4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Jan 2020 12:56:32 +0100 Subject: [PATCH] - fixed size of texture arrays. We need 6 slots, not 5. --- source/common/menu/menu.cpp | 2 +- source/glbackend/gl_renderstate.h | 2 +- source/glbackend/glbackend.cpp | 2 +- source/glbackend/glbackend.h | 11 ++++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index b2cc58b6e..2dc51c39e 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -479,7 +479,7 @@ bool M_SetMenu(FName menu, int param, FName caller) return false; case NAME_CustomSubMenu1: - menu = ENamedName(menu + param); + menu = ENamedName(menu.GetIndex() + param); break; #if 0 diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index f113158a3..1807e55b7 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -75,7 +75,7 @@ struct PolymostRenderState PalEntry ClearColor = 0; short vp_x, vp_y, vp_w, vp_h; short sc_x = SHRT_MIN, sc_y, sc_w, sc_h; - int texIds[5], samplerIds[5]; + int texIds[6], samplerIds[6]; PalEntry FogColor; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 98903c44e..767542c81 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -349,7 +349,7 @@ void GLInstance::DrawImGui(ImDrawData* data) void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState) { bool reset = false; - for (int i = 0; i < 5; i++) + for (int i = 0; i < MAX_TEXTURES; i++) { if (texIds[i] != oldState.TexId[i] || samplerIds[i] != oldState.SamplerId[i]) { diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index ddbb7e1c1..07467658d 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -165,20 +165,21 @@ struct ImDrawData; struct palette_t; extern float shadediv[256]; +enum +{ + MAX_TEXTURES = 6, /*15*/ // slot 15 is used internally and not available. - The renderer uses only 5, though. +}; + struct GLState { int Flags = STF_COLORMASK | STF_DEPTHMASK; FRenderStyle Style{}; int DepthFunc = -1; - int TexId[5] = {}, SamplerId[5] = {}; + int TexId[MAX_TEXTURES] = {}, SamplerId[MAX_TEXTURES] = {}; }; class GLInstance { - enum - { - MAX_TEXTURES = 5, /*15*/ // slot 15 is used internally and not available. - The renderer uses only 5, though. - }; std::vector Buffer; // cheap-ass implementation. The primary purpose is to get the GL accesses out of polymost.cpp, not writing something performant right away. int maxTextureSize; PaletteManager palmanager;