diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a4a47f1e28..024cbda231c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1399,6 +1399,7 @@ set(EXPECTED_DATA editor/entities_clear/vanilla.png editor/front.png editor/speed_arrow.png + editor/speed_arrow_array.png editor/speedup.png editor/switch.png editor/tele.png diff --git a/data/editor/speed_arrow_array.png b/data/editor/speed_arrow_array.png new file mode 100644 index 00000000000..f85db1a0f4c Binary files /dev/null and b/data/editor/speed_arrow_array.png differ diff --git a/data/shader/tile.vert b/data/shader/tile.vert index 97099bce3d2..6288371e995 100644 --- a/data/shader/tile.vert +++ b/data/shader/tile.vert @@ -1,6 +1,6 @@ layout (location = 0) in vec2 inVertex; #ifdef TW_TILE_TEXTURED -layout (location = 1) in vec3 inVertexTexCoord; +layout (location = 1) in uvec4 inVertexTexCoord; #endif uniform mat4x2 gPos; @@ -14,6 +14,6 @@ void main() gl_Position = vec4(gPos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0); #ifdef TW_TILE_TEXTURED - TexCoord = inVertexTexCoord; + TexCoord = vec3(inVertexTexCoord.xyz); #endif } diff --git a/data/shader/tile_border.vert b/data/shader/tile_border.vert index 8202a08e484..f8f71ebda51 100644 --- a/data/shader/tile_border.vert +++ b/data/shader/tile_border.vert @@ -1,6 +1,6 @@ layout (location = 0) in vec2 inVertex; #ifdef TW_TILE_TEXTURED -layout (location = 1) in vec3 inVertexTexCoord; +layout (location = 1) in uvec4 inVertexTexCoord; #endif uniform mat4x2 gPos; @@ -20,6 +20,9 @@ void main() #ifdef TW_TILE_TEXTURED // scale the texture coordinates too - TexCoord = vec3(inVertexTexCoord.xy * gScale, inVertexTexCoord.z); + vec2 TexScale = gScale; + if (float(inVertexTexCoord.w) > 0.0) + TexScale = gScale.yx; + TexCoord = vec3(vec2(inVertexTexCoord.xy) * TexScale, float(inVertexTexCoord.z)); #endif } diff --git a/data/shader/vulkan/tile.vert b/data/shader/vulkan/tile.vert index 5e78358cc16..7dd9d35fdc3 100644 --- a/data/shader/vulkan/tile.vert +++ b/data/shader/vulkan/tile.vert @@ -3,7 +3,7 @@ layout (location = 0) in vec2 inVertex; #ifdef TW_TILE_TEXTURED -layout (location = 1) in vec3 inVertexTexCoord; +layout (location = 1) in uvec4 inVertexTexCoord; #endif layout(push_constant) uniform SPosBO { @@ -19,6 +19,6 @@ void main() gl_Position = vec4(gPosBO.gPos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0); #ifdef TW_TILE_TEXTURED - TexCoord = inVertexTexCoord; + TexCoord = vec3(inVertexTexCoord.xyz); #endif } diff --git a/data/shader/vulkan/tile_border.vert b/data/shader/vulkan/tile_border.vert index b7ae599815d..5463fdf39ed 100644 --- a/data/shader/vulkan/tile_border.vert +++ b/data/shader/vulkan/tile_border.vert @@ -3,7 +3,7 @@ layout (location = 0) in vec2 inVertex; #ifdef TW_TILE_TEXTURED -layout (location = 1) in vec3 inVertexTexCoord; +layout (location = 1) in uvec4 inVertexTexCoord; #endif layout(push_constant) uniform SPosBO { @@ -25,6 +25,9 @@ void main() #ifdef TW_TILE_TEXTURED // scale the texture coordinates too - TexCoord = vec3(inVertexTexCoord.xy * gPosBO.gScale, inVertexTexCoord.z); + vec2 TexScale = gPosBO.gScale; + if (inVertexTexCoord.w > 0) + TexScale = gPosBO.gScale.yx; + TexCoord = vec3(vec2(inVertexTexCoord.xy) * TexScale, float(inVertexTexCoord.z)); #endif } diff --git a/src/base/vmath.h b/src/base/vmath.h index 37205b108b9..6797e5db1d9 100644 --- a/src/base/vmath.h +++ b/src/base/vmath.h @@ -4,6 +4,7 @@ #define BASE_VMATH_H #include +#include #include "math.h" @@ -399,5 +400,6 @@ class vector4_base typedef vector4_base vec4; typedef vector4_base bvec4; typedef vector4_base ivec4; +typedef vector4_base ubvec4; #endif diff --git a/src/engine/client/backend/opengl/backend_opengl.cpp b/src/engine/client/backend/opengl/backend_opengl.cpp index 35e7335a5f9..2405bddc4a0 100644 --- a/src/engine/client/backend/opengl/backend_opengl.cpp +++ b/src/engine/client/backend/opengl/backend_opengl.cpp @@ -451,7 +451,7 @@ bool CCommandProcessorFragment_OpenGL::InitOpenGL(const SCommand_Init *pCommand) pCommand->m_pCapabilities->m_ContextPatch = 0; } - pCommand->m_pCapabilities->m_TileBuffering = pCommand->m_pCapabilities->m_2DArrayTextures || pCommand->m_pCapabilities->m_3DTextures; + pCommand->m_pCapabilities->m_TileBuffering = pCommand->m_pCapabilities->m_2DArrayTextures; pCommand->m_pCapabilities->m_QuadBuffering = false; pCommand->m_pCapabilities->m_TextBuffering = false; pCommand->m_pCapabilities->m_QuadContainerBuffering = false; @@ -464,8 +464,6 @@ bool CCommandProcessorFragment_OpenGL::InitOpenGL(const SCommand_Init *pCommand) pCommand->m_pCapabilities->m_2DArrayTextures = false; pCommand->m_pCapabilities->m_ShaderSupport = false; - if(MinorV >= 1) - pCommand->m_pCapabilities->m_ShaderSupport = true; int Texture3DSize = 0; glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &Texture3DSize); @@ -474,18 +472,6 @@ bool CCommandProcessorFragment_OpenGL::InitOpenGL(const SCommand_Init *pCommand) pCommand->m_pCapabilities->m_3DTextures = true; } - // check for array texture extension - if(pCommand->m_pCapabilities->m_ShaderSupport && GLEW_EXT_texture_array) - { - int TextureLayers = 0; - glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &TextureLayers); - if(TextureLayers >= 256) - { - pCommand->m_pCapabilities->m_2DArrayTextures = true; - pCommand->m_pCapabilities->m_2DArrayTexturesAsExtension = true; - } - } - pCommand->m_pCapabilities->m_TileBuffering = false; pCommand->m_pCapabilities->m_QuadBuffering = false; pCommand->m_pCapabilities->m_TextBuffering = false; @@ -815,8 +801,8 @@ void CCommandProcessorFragment_OpenGL::TextureCreate(int Slot, int Width, int He glTexImage2D(GL_TEXTURE_2D, 0, GLStoreFormat, Width, Height, 0, GLFormat, GL_UNSIGNED_BYTE, pTexData); } - int Flag2DArrayTexture = (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE | CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER); - int Flag3DTexture = (CCommandBuffer::TEXFLAG_TO_3D_TEXTURE | CCommandBuffer::TEXFLAG_TO_3D_TEXTURE_SINGLE_LAYER); + int Flag2DArrayTexture = CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE; + int Flag3DTexture = CCommandBuffer::TEXFLAG_TO_3D_TEXTURE; if((Flags & (Flag2DArrayTexture | Flag3DTexture)) != 0) { bool Is3DTexture = (Flags & Flag3DTexture) != 0; @@ -882,46 +868,32 @@ void CCommandProcessorFragment_OpenGL::TextureCreate(int Slot, int Width, int He uint8_t *p3DImageData = NULL; - bool IsSingleLayer = (Flags & (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER | CCommandBuffer::TEXFLAG_TO_3D_TEXTURE_SINGLE_LAYER)) != 0; - - if(!IsSingleLayer) - p3DImageData = (uint8_t *)malloc((size_t)Width * Height * PixelSize); + p3DImageData = (uint8_t *)malloc((size_t)Width * Height * PixelSize); int Image3DWidth, Image3DHeight; int ConvertWidth = Width; int ConvertHeight = Height; - if(!IsSingleLayer) + if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) { - if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) - { - dbg_msg("gfx", "3D/2D array texture was resized"); - int NewWidth = maximum(HighestBit(ConvertWidth), 16); - int NewHeight = maximum(HighestBit(ConvertHeight), 16); - uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pTexData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, GLFormatToPixelSize(GLFormat)); + dbg_msg("gfx", "3D/2D array texture was resized"); + int NewWidth = maximum(HighestBit(ConvertWidth), 16); + int NewHeight = maximum(HighestBit(ConvertHeight), 16); + uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pTexData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, GLFormatToPixelSize(GLFormat)); - ConvertWidth = NewWidth; - ConvertHeight = NewHeight; + ConvertWidth = NewWidth; + ConvertHeight = NewHeight; - free(pTexData); - pTexData = pNewTexData; - } + free(pTexData); + pTexData = pNewTexData; } - if(IsSingleLayer || (Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight))) + if((Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight))) { - if(IsSingleLayer) - { - glTexImage3D(Target, 0, GLStoreFormat, ConvertWidth, ConvertHeight, 1, 0, GLFormat, GL_UNSIGNED_BYTE, pTexData); - } - else - { - glTexImage3D(Target, 0, GLStoreFormat, Image3DWidth, Image3DHeight, 256, 0, GLFormat, GL_UNSIGNED_BYTE, p3DImageData); - } + glTexImage3D(Target, 0, GLStoreFormat, Image3DWidth, Image3DHeight, 256, 0, GLFormat, GL_UNSIGNED_BYTE, p3DImageData); } - if(!IsSingleLayer) - free(p3DImageData); + free(p3DImageData); } } @@ -2084,7 +2056,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderBorderTile(const CCommandBuffe if(IsTextured) { glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 3, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset); + glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset); } size_t RealDrawCount = pCommand->m_DrawNum * 4; @@ -2136,7 +2108,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer if(IsTextured) { glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 3, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset); + glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset); } for(int i = 0; i < pCommand->m_IndicesDrawNum; ++i) diff --git a/src/engine/client/backend/opengl/backend_opengl3.cpp b/src/engine/client/backend/opengl/backend_opengl3.cpp index a460c5723f0..315dd887d7d 100644 --- a/src/engine/client/backend/opengl/backend_opengl3.cpp +++ b/src/engine/client/backend/opengl/backend_opengl3.cpp @@ -600,7 +600,7 @@ void CCommandProcessorFragment_OpenGL3_3::TextureCreate(int Slot, int Width, int glGenerateMipmap(GL_TEXTURE_2D); } - if((Flags & (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE | CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER)) != 0) + if((Flags & (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE)) != 0) { glGenTextures(1, &m_vTextures[Slot].m_Tex2DArray); glBindTexture(GL_TEXTURE_2D_ARRAY, m_vTextures[Slot].m_Tex2DArray); @@ -620,47 +620,33 @@ void CCommandProcessorFragment_OpenGL3_3::TextureCreate(int Slot, int Width, int uint8_t *p3DImageData = NULL; - bool IsSingleLayer = (Flags & CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER) != 0; - - if(!IsSingleLayer) - p3DImageData = (uint8_t *)malloc((size_t)Width * Height * PixelSize); + p3DImageData = (uint8_t *)malloc((size_t)Width * Height * PixelSize); int Image3DWidth, Image3DHeight; int ConvertWidth = Width; int ConvertHeight = Height; - if(!IsSingleLayer) + if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) { - if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) - { - dbg_msg("gfx", "3D/2D array texture was resized"); - int NewWidth = maximum(HighestBit(ConvertWidth), 16); - int NewHeight = maximum(HighestBit(ConvertHeight), 16); - uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pTexData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, GLFormatToPixelSize(GLFormat)); - - ConvertWidth = NewWidth; - ConvertHeight = NewHeight; - - free(pTexData); - pTexData = pNewTexData; - } + dbg_msg("gfx", "3D/2D array texture was resized"); + int NewWidth = maximum(HighestBit(ConvertWidth), 16); + int NewHeight = maximum(HighestBit(ConvertHeight), 16); + uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pTexData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, GLFormatToPixelSize(GLFormat)); + + ConvertWidth = NewWidth; + ConvertHeight = NewHeight; + + free(pTexData); + pTexData = pNewTexData; } - if(IsSingleLayer || (Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight))) + if((Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight))) { - if(IsSingleLayer) - { - glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GLStoreFormat, ConvertWidth, ConvertHeight, 1, 0, GLFormat, GL_UNSIGNED_BYTE, pTexData); - } - else - { - glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GLStoreFormat, Image3DWidth, Image3DHeight, 256, 0, GLFormat, GL_UNSIGNED_BYTE, p3DImageData); - } + glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GLStoreFormat, Image3DWidth, Image3DHeight, 256, 0, GLFormat, GL_UNSIGNED_BYTE, p3DImageData); glGenerateMipmap(GL_TEXTURE_2D_ARRAY); } - if(!IsSingleLayer) - free(p3DImageData); + free(p3DImageData); } } diff --git a/src/engine/client/backend/vulkan/backend_vulkan.cpp b/src/engine/client/backend/vulkan/backend_vulkan.cpp index f43ae43ff4e..d6b31aa5668 100644 --- a/src/engine/client/backend/vulkan/backend_vulkan.cpp +++ b/src/engine/client/backend/vulkan/backend_vulkan.cpp @@ -2593,8 +2593,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase } bool Requires2DTexture = (Flags & CCommandBuffer::TEXFLAG_NO_2D_TEXTURE) == 0; - bool Requires2DTextureArray = (Flags & (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE | CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER)) != 0; - bool Is2DTextureSingleLayer = (Flags & CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER) != 0; + bool Requires2DTextureArray = (Flags & (CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE)) != 0; bool RequiresMipMaps = (Flags & CCommandBuffer::TEXFLAG_NOMIPMAPS) == 0; size_t MipMapLevelCount = 1; if(RequiresMipMaps) @@ -2638,44 +2637,33 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase int ConvertWidth = Width; int ConvertHeight = Height; - if(!Is2DTextureSingleLayer) + if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) { - if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0) - { - dbg_msg("vulkan", "3D/2D array texture was resized"); - int NewWidth = maximum(HighestBit(ConvertWidth), 16); - int NewHeight = maximum(HighestBit(ConvertHeight), 16); - uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, PixelSize); + dbg_msg("vulkan", "3D/2D array texture was resized"); + int NewWidth = maximum(HighestBit(ConvertWidth), 16); + int NewHeight = maximum(HighestBit(ConvertHeight), 16); + uint8_t *pNewTexData = (uint8_t *)Resize((const uint8_t *)pData, ConvertWidth, ConvertHeight, NewWidth, NewHeight, PixelSize); - ConvertWidth = NewWidth; - ConvertHeight = NewHeight; + ConvertWidth = NewWidth; + ConvertHeight = NewHeight; - free(pData); - pData = pNewTexData; - } + free(pData); + pData = pNewTexData; } void *p3DTexData = pData; bool Needs3DTexDel = false; - if(!Is2DTextureSingleLayer) - { - p3DTexData = malloc((size_t)PixelSize * ConvertWidth * ConvertHeight); - if(!Texture2DTo3D(pData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DTexData, Image3DWidth, Image3DHeight)) - { - free(p3DTexData); - p3DTexData = nullptr; - } - Needs3DTexDel = true; - } - else + p3DTexData = malloc((size_t)PixelSize * ConvertWidth * ConvertHeight); + if(!Texture2DTo3D(pData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DTexData, Image3DWidth, Image3DHeight)) { - Image3DWidth = ConvertWidth; - Image3DHeight = ConvertHeight; + free(p3DTexData); + p3DTexData = nullptr; } + Needs3DTexDel = true; if(p3DTexData != nullptr) { - const size_t ImageDepth2DArray = Is2DTextureSingleLayer ? 1 : ((size_t)16 * 16); + const size_t ImageDepth2DArray = (size_t)16 * 16; VkExtent3D ImgSize{(uint32_t)Image3DWidth, (uint32_t)Image3DHeight, 1}; if(RequiresMipMaps) { @@ -4898,7 +4886,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase std::array aAttributeDescriptions = {}; aAttributeDescriptions[0] = {0, 0, VK_FORMAT_R32G32_SFLOAT, 0}; if(HasSampler) - aAttributeDescriptions[1] = {1, 0, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 2}; + aAttributeDescriptions[1] = {1, 0, VK_FORMAT_R8G8B8A8_UINT, sizeof(float) * 2}; std::array aSetLayouts; aSetLayouts[0] = m_Standard3DTexturedDescriptorSetLayout; @@ -4913,7 +4901,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase aPushConstants[0] = {VK_SHADER_STAGE_VERTEX_BIT, 0, VertPushConstantSize}; aPushConstants[1] = {VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(SUniformTileGPosBorder) + sizeof(SUniformTileGVertColorAlign), FragPushConstantSize}; - return CreateGraphicsPipeline(pVertName, pFragName, PipeContainer, HasSampler ? (sizeof(float) * (2 + 3)) : (sizeof(float) * 2), aAttributeDescriptions, aSetLayouts, aPushConstants, TexMode, BlendMode, DynamicMode); + return CreateGraphicsPipeline(pVertName, pFragName, PipeContainer, HasSampler ? (sizeof(float) * 2 + sizeof(uint8_t) * 4) : (sizeof(float) * 2), aAttributeDescriptions, aSetLayouts, aPushConstants, TexMode, BlendMode, DynamicMode); } template @@ -7049,9 +7037,9 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase [[nodiscard]] bool Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand, SRenderCommandExecuteBuffer &ExecBuffer) { - vec2 Dir{}; + vec2 Scale{}; vec2 Off{}; - return RenderTileLayer(ExecBuffer, pCommand->m_State, false, pCommand->m_Color, Dir, Off, (size_t)pCommand->m_IndicesDrawNum, pCommand->m_pIndicesOffsets, pCommand->m_pDrawCount); + return RenderTileLayer(ExecBuffer, pCommand->m_State, false, pCommand->m_Color, Scale, Off, (size_t)pCommand->m_IndicesDrawNum, pCommand->m_pIndicesOffsets, pCommand->m_pDrawCount); } void Cmd_RenderBorderTile_FillExecuteBuffer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_RenderBorderTile *pCommand) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 9b7252b3e6c..d2c8eef6c55 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -454,10 +454,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTextureRaw(size_t Width, size_ Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE; if((Flags & IGraphics::TEXLOAD_TO_3D_TEXTURE) != 0) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TO_3D_TEXTURE; - if((Flags & IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER) != 0) - Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER; - if((Flags & IGraphics::TEXLOAD_TO_3D_TEXTURE_SINGLE_LAYER) != 0) - Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TO_3D_TEXTURE_SINGLE_LAYER; if((Flags & IGraphics::TEXLOAD_NO_2D_TEXTURE) != 0) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NO_2D_TEXTURE; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index ea838c22f2f..5f69b6ca8e2 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -147,9 +147,7 @@ class CCommandBuffer TEXFLAG_NOMIPMAPS = 1, TEXFLAG_TO_3D_TEXTURE = (1 << 3), TEXFLAG_TO_2D_ARRAY_TEXTURE = (1 << 4), - TEXFLAG_TO_3D_TEXTURE_SINGLE_LAYER = (1 << 5), - TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER = (1 << 6), - TEXFLAG_NO_2D_TEXTURE = (1 << 7), + TEXFLAG_NO_2D_TEXTURE = (1 << 5), }; enum diff --git a/src/engine/graphics.h b/src/engine/graphics.h index e0251d4dad4..5e1639ba941 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -57,10 +57,10 @@ struct SGraphicTile struct SGraphicTileTexureCoords { - vec3 m_TexCoordTopLeft; - vec3 m_TexCoordTopRight; - vec3 m_TexCoordBottomRight; - vec3 m_TexCoordBottomLeft; + ubvec4 m_TexCoordTopLeft; + ubvec4 m_TexCoordTopRight; + ubvec4 m_TexCoordBottomRight; + ubvec4 m_TexCoordBottomLeft; }; class CImageInfo @@ -246,9 +246,7 @@ class IGraphics : public IInterface TEXLOAD_NO_COMPRESSION = 1 << 2, TEXLOAD_TO_3D_TEXTURE = (1 << 3), TEXLOAD_TO_2D_ARRAY_TEXTURE = (1 << 4), - TEXLOAD_TO_3D_TEXTURE_SINGLE_LAYER = (1 << 5), - TEXLOAD_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER = (1 << 6), - TEXLOAD_NO_2D_TEXTURE = (1 << 7), + TEXLOAD_NO_2D_TEXTURE = (1 << 5), }; class CTextureHandle diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index f5e0e475bea..54727939b7d 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -356,8 +356,8 @@ IGraphics::CTextureHandle CMapImages::GetSpeedupArrow() { if(!m_SpeedupArrowIsLoaded) { - int TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER : IGraphics::TEXLOAD_TO_3D_TEXTURE_SINGLE_LAYER) | IGraphics::TEXLOAD_NO_2D_TEXTURE; - m_SpeedupArrowTexture = Graphics()->LoadTexture(g_pData->m_aImages[IMAGE_SPEEDUP_ARROW].m_pFilename, IStorage::TYPE_ALL, TextureLoadFlag); + int TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE; + m_SpeedupArrowTexture = Graphics()->LoadTexture("editor/speed_arrow_array.png", IStorage::TYPE_ALL, TextureLoadFlag); m_SpeedupArrowIsLoaded = true; } diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 7c72c7134b5..ad49f9eb292 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -1,6 +1,5 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#include #include #include #include @@ -144,7 +143,7 @@ void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels } } -void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, const ivec2 &Offset, int Scale, CMapItemGroup *pGroup) +void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, unsigned char Flags, unsigned char Index, int x, int y, const ivec2 &Offset, int Scale, CMapItemGroup *pGroup) { if(pTmpTex) { @@ -196,20 +195,16 @@ void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool pTmpTex->m_TexCoordBottomRight.x = x2; pTmpTex->m_TexCoordBottomRight.y = y2; - if(As3DTextureCoord) - { - pTmpTex->m_TexCoordTopLeft.z = ((float)Index + 0.5f) / 256.f; - pTmpTex->m_TexCoordBottomLeft.z = ((float)Index + 0.5f) / 256.f; - pTmpTex->m_TexCoordTopRight.z = ((float)Index + 0.5f) / 256.f; - pTmpTex->m_TexCoordBottomRight.z = ((float)Index + 0.5f) / 256.f; - } - else - { - pTmpTex->m_TexCoordTopLeft.z = Index; - pTmpTex->m_TexCoordBottomLeft.z = Index; - pTmpTex->m_TexCoordTopRight.z = Index; - pTmpTex->m_TexCoordBottomRight.z = Index; - } + pTmpTex->m_TexCoordTopLeft.z = Index; + pTmpTex->m_TexCoordBottomLeft.z = Index; + pTmpTex->m_TexCoordTopRight.z = Index; + pTmpTex->m_TexCoordBottomRight.z = Index; + + bool HasRotation = (Flags & TILEFLAG_ROTATE) != 0; + pTmpTex->m_TexCoordTopLeft.w = HasRotation; + pTmpTex->m_TexCoordBottomLeft.w = HasRotation; + pTmpTex->m_TexCoordTopRight.w = HasRotation; + pTmpTex->m_TexCoordBottomRight.w = HasRotation; } pTmpTile->m_TopLeft.x = x * Scale + Offset.x; @@ -222,10 +217,10 @@ void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool pTmpTile->m_BottomRight.y = y * Scale + Scale + Offset.y; } -void FillTmpTileSpeedup(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, const ivec2 &Offset, int Scale, CMapItemGroup *pGroup, short AngleRotate) +void FillTmpTileSpeedup(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, unsigned char Flags, unsigned char Index, int x, int y, const ivec2 &Offset, int Scale, CMapItemGroup *pGroup, short AngleRotate) { int Angle = AngleRotate % 360; - FillTmpTile(pTmpTile, pTmpTex, As3DTextureCoord, Angle >= 270 ? Angle : (Angle >= 180 ? ROTATION_180 : (Angle >= 90 ? ROTATION_90 : 0)), AngleRotate % 90, x, y, Offset, Scale, pGroup); + FillTmpTile(pTmpTile, pTmpTex, Angle >= 270 ? ROTATION_270 : (Angle >= 180 ? ROTATION_180 : (Angle >= 90 ? ROTATION_90 : 0)), AngleRotate % 90, x, y, Offset, Scale, pGroup); } bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height) @@ -255,7 +250,7 @@ CMapLayers::STileLayerVisuals::~STileLayerVisuals() m_pTilesOfLayer = NULL; } -bool AddTile(std::vector &vTmpTiles, std::vector &vTmpTileTexCoords, bool As3DTextureCoord, unsigned char Index, unsigned char Flags, int x, int y, CMapItemGroup *pGroup, bool DoTextureCoords, bool FillSpeedup = false, int AngleRotate = -1, const ivec2 &Offset = ivec2{0, 0}, int Scale = 32) +bool AddTile(std::vector &vTmpTiles, std::vector &vTmpTileTexCoords, unsigned char Index, unsigned char Flags, int x, int y, CMapItemGroup *pGroup, bool DoTextureCoords, bool FillSpeedup = false, int AngleRotate = -1, const ivec2 &Offset = ivec2{0, 0}, int Scale = 32) { if(Index) { @@ -269,9 +264,9 @@ bool AddTile(std::vector &vTmpTiles, std::vector vtmpQuads; std::vector vtmpQuadsTextured; - bool As3DTextureCoords = !Graphics()->Uses2DTextureArrays(); - for(int g = 0; g < m_pLayers->NumGroups(); g++) { CMapItemGroup *pGroup = m_pLayers->GetGroup(g); @@ -626,7 +619,7 @@ void CMapLayers::OnMapLoad() if(IsSpeedupLayer && CurOverlay == 0) AddAsSpeedup = true; - if(AddTile(vtmpTiles, vtmpTileTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate)) + if(AddTile(vtmpTiles, vtmpTileTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate)) Visuals.m_pTilesOfLayer[y * pTMap->m_Width + x].Draw(true); //do the border tiles @@ -635,17 +628,17 @@ void CMapLayers::OnMapLoad() if(y == 0) { Visuals.m_BorderTopLeft.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size())); - if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, -32})) + if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, -32})) Visuals.m_BorderTopLeft.Draw(true); } else if(y == pTMap->m_Height - 1) { Visuals.m_BorderBottomLeft.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size())); - if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, 0})) + if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, 0})) Visuals.m_BorderBottomLeft.Draw(true); } Visuals.m_vBorderLeft[y].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderLeftTiles.size())); - if(AddTile(vtmpBorderLeftTiles, vtmpBorderLeftTilesTexCoords, As3DTextureCoords, Index, Flags, 0, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, 0})) + if(AddTile(vtmpBorderLeftTiles, vtmpBorderLeftTilesTexCoords, Index, Flags, 0, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, 0})) Visuals.m_vBorderLeft[y].Draw(true); } else if(x == pTMap->m_Width - 1) @@ -653,29 +646,29 @@ void CMapLayers::OnMapLoad() if(y == 0) { Visuals.m_BorderTopRight.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size())); - if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, -32})) + if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, -32})) Visuals.m_BorderTopRight.Draw(true); } else if(y == pTMap->m_Height - 1) { Visuals.m_BorderBottomRight.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size())); - if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) + if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) Visuals.m_BorderBottomRight.Draw(true); } Visuals.m_vBorderRight[y].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderRightTiles.size())); - if(AddTile(vtmpBorderRightTiles, vtmpBorderRightTilesTexCoords, As3DTextureCoords, Index, Flags, 0, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) + if(AddTile(vtmpBorderRightTiles, vtmpBorderRightTilesTexCoords, Index, Flags, 0, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) Visuals.m_vBorderRight[y].Draw(true); } if(y == 0) { Visuals.m_vBorderTop[x].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderTopTiles.size())); - if(AddTile(vtmpBorderTopTiles, vtmpBorderTopTilesTexCoords, As3DTextureCoords, Index, Flags, x, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, -32})) + if(AddTile(vtmpBorderTopTiles, vtmpBorderTopTilesTexCoords, Index, Flags, x, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, -32})) Visuals.m_vBorderTop[x].Draw(true); } else if(y == pTMap->m_Height - 1) { Visuals.m_vBorderBottom[x].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderBottomTiles.size())); - if(AddTile(vtmpBorderBottomTiles, vtmpBorderBottomTilesTexCoords, As3DTextureCoords, Index, Flags, x, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) + if(AddTile(vtmpBorderBottomTiles, vtmpBorderBottomTilesTexCoords, Index, Flags, x, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0})) Visuals.m_vBorderBottom[x].Draw(true); } } @@ -685,7 +678,7 @@ void CMapLayers::OnMapLoad() if(IsGameLayer) { Visuals.m_BorderKillTile.SetIndexBufferByteOffset((offset_ptr32)(vtmpTiles.size())); - if(AddTile(vtmpTiles, vtmpTileTexCoords, As3DTextureCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords)) + if(AddTile(vtmpTiles, vtmpTileTexCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords)) Visuals.m_BorderKillTile.Draw(true); } @@ -754,10 +747,10 @@ void CMapLayers::OnMapLoad() { char *pUploadData = (char *)malloc(sizeof(char) * UploadDataSize); - mem_copy_special(pUploadData, pTmpTiles, sizeof(vec2), vtmpTiles.size() * 4, (DoTextureCoords ? sizeof(vec3) : 0)); + mem_copy_special(pUploadData, pTmpTiles, sizeof(vec2), vtmpTiles.size() * 4, (DoTextureCoords ? sizeof(ubvec4) : 0)); if(DoTextureCoords) { - mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), vtmpTiles.size() * 4, sizeof(vec2)); + mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(ubvec4), vtmpTiles.size() * 4, sizeof(vec2)); } // first create the buffer object @@ -765,7 +758,7 @@ void CMapLayers::OnMapLoad() // then create the buffer container SBufferContainerInfo ContainerInfo; - ContainerInfo.m_Stride = (DoTextureCoords ? (sizeof(float) * 2 + sizeof(vec3)) : 0); + ContainerInfo.m_Stride = (DoTextureCoords ? (sizeof(float) * 2 + sizeof(ubvec4)) : 0); ContainerInfo.m_VertBufferBindingIndex = BufferObjectIndex; ContainerInfo.m_vAttributes.emplace_back(); SBufferContainerInfo::SAttribute *pAttr = &ContainerInfo.m_vAttributes.back(); @@ -778,11 +771,11 @@ void CMapLayers::OnMapLoad() { ContainerInfo.m_vAttributes.emplace_back(); pAttr = &ContainerInfo.m_vAttributes.back(); - pAttr->m_DataTypeCount = 3; - pAttr->m_Type = GRAPHICS_TYPE_FLOAT; + pAttr->m_DataTypeCount = 4; + pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE; pAttr->m_Normalized = false; pAttr->m_pOffset = (void *)(sizeof(vec2)); - pAttr->m_FuncType = 0; + pAttr->m_FuncType = 1; } Visuals.m_BufferContainerIndex = Graphics()->CreateBufferContainer(&ContainerInfo); diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 541f6435f62..5e858292d4c 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -459,7 +459,10 @@ void CRenderTools::RenderTileRectangle(int RectX, int RectY, int RectW, int Rect pfnEval(ColorEnvOffset, ColorEnv, Channels, pUser); } - Graphics()->QuadsBegin(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DBegin(); + else + Graphics()->QuadsBegin(); Graphics()->SetColor(Color.r * Channels.r, Color.g * Channels.g, Color.b * Channels.b, Color.a * Channels.a); int StartY = (int)(ScreenY0 / Scale) - 1; @@ -501,15 +504,39 @@ void CRenderTools::RenderTileRectangle(int RectX, int RectY, int RectW, int Rect float x3 = Nudge + Px0 / TexSize + Frac; float y3 = Nudge + Py1 / TexSize - Frac; - Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); - IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); - Graphics()->QuadsDrawTL(&QuadItem, 1); + if(Graphics()->HasTextureArraysSupport()) + { + x0 = 0; + y0 = 0; + x1 = x0 + 1; + y1 = y0; + x2 = x0 + 1; + y2 = y0 + 1; + x3 = x0; + y3 = y0 + 1; + } + + if(Graphics()->HasTextureArraysSupport()) + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsTex3DDrawTL(&QuadItem, 1); + } + else + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsDrawTL(&QuadItem, 1); + } } } } } - Graphics()->QuadsEnd(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DEnd(); + else + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } @@ -918,7 +945,10 @@ void CRenderTools::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, Co float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); float FinalTilesetScale = FinalTileSize / TilePixelSize; - Graphics()->QuadsBegin(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DBegin(); + else + Graphics()->QuadsBegin(); Graphics()->SetColor(Color); int StartY = (int)(ScreenY0 / Scale) - 1; @@ -987,14 +1017,38 @@ void CRenderTools::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, Co float x3 = Nudge + Px0 / TexSize + Frac; float y3 = Nudge + Py1 / TexSize - Frac; - Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); - IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); - Graphics()->QuadsDrawTL(&QuadItem, 1); + if(Graphics()->HasTextureArraysSupport()) + { + x0 = 0; + y0 = 0; + x1 = x0 + 1; + y1 = y0; + x2 = x0 + 1; + y2 = y0 + 1; + x3 = x0; + y3 = y0 + 1; + } + + if(Graphics()->HasTextureArraysSupport()) + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsTex3DDrawTL(&QuadItem, 1); + } + else + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsDrawTL(&QuadItem, 1); + } } } } - Graphics()->QuadsEnd(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DEnd(); + else + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } @@ -1010,7 +1064,10 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedupTile, int w, int h, fl float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); float FinalTilesetScale = FinalTileSize / TilePixelSize; - Graphics()->QuadsBegin(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DBegin(); + else + Graphics()->QuadsBegin(); Graphics()->SetColor(Color); int StartY = (int)(ScreenY0 / Scale) - 1; @@ -1079,14 +1136,38 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedupTile, int w, int h, fl float x3 = Nudge + Px0 / TexSize + Frac; float y3 = Nudge + Py1 / TexSize - Frac; - Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); - IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); - Graphics()->QuadsDrawTL(&QuadItem, 1); + if(Graphics()->HasTextureArraysSupport()) + { + x0 = 0; + y0 = 0; + x1 = x0 + 1; + y1 = y0; + x2 = x0 + 1; + y2 = y0 + 1; + x3 = x0; + y3 = y0 + 1; + } + + if(Graphics()->HasTextureArraysSupport()) + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsTex3DDrawTL(&QuadItem, 1); + } + else + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsDrawTL(&QuadItem, 1); + } } } } - Graphics()->QuadsEnd(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DEnd(); + else + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } @@ -1102,7 +1183,10 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); float FinalTilesetScale = FinalTileSize / TilePixelSize; - Graphics()->QuadsBegin(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DBegin(); + else + Graphics()->QuadsBegin(); Graphics()->SetColor(Color); int StartY = (int)(ScreenY0 / Scale) - 1; @@ -1184,6 +1268,18 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float float x3 = Nudge + Px0 / TexSize + Frac; float y3 = Nudge + Py1 / TexSize - Frac; + if(Graphics()->HasTextureArraysSupport()) + { + x0 = 0; + y0 = 0; + x1 = x0 + 1; + y1 = y0; + x2 = x0 + 1; + y2 = y0 + 1; + x3 = x0; + y3 = y0 + 1; + } + if(Flags & TILEFLAG_XFLIP) { x0 = x2; @@ -1214,14 +1310,26 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float y1 = Tmp; } - Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); - IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); - Graphics()->QuadsDrawTL(&QuadItem, 1); + if(Graphics()->HasTextureArraysSupport()) + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsTex3DDrawTL(&QuadItem, 1); + } + else + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsDrawTL(&QuadItem, 1); + } } } } - Graphics()->QuadsEnd(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DEnd(); + else + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } @@ -1235,7 +1343,10 @@ void CRenderTools::RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, Co float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth(); float FinalTilesetScale = FinalTileSize / TilePixelSize; - Graphics()->QuadsBegin(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DBegin(); + else + Graphics()->QuadsBegin(); Graphics()->SetColor(Color); int StartY = (int)(ScreenY0 / Scale) - 1; @@ -1304,13 +1415,37 @@ void CRenderTools::RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, Co float x3 = Nudge + Px0 / TexSize + Frac; float y3 = Nudge + Py1 / TexSize - Frac; - Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); - IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); - Graphics()->QuadsDrawTL(&QuadItem, 1); + if(Graphics()->HasTextureArraysSupport()) + { + x0 = 0; + y0 = 0; + x1 = x0 + 1; + y1 = y0; + x2 = x0 + 1; + y2 = y0 + 1; + x3 = x0; + y3 = y0 + 1; + } + + if(Graphics()->HasTextureArraysSupport()) + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsTex3DDrawTL(&QuadItem, 1); + } + else + { + Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3); + IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale); + Graphics()->QuadsDrawTL(&QuadItem, 1); + } } } } - Graphics()->QuadsEnd(); + if(Graphics()->HasTextureArraysSupport()) + Graphics()->QuadsTex3DEnd(); + else + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); }