mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Switch to a fragment shader solution for border tile rendering
This commit is contained in:
parent
b60b14bf61
commit
639a8c3c8b
|
@ -1403,6 +1403,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
|
||||
|
@ -1554,6 +1555,8 @@ set(EXPECTED_DATA
|
|||
shader/text.vert
|
||||
shader/tile.frag
|
||||
shader/tile.vert
|
||||
shader/tile_border.frag
|
||||
shader/tile_border.vert
|
||||
shader/vulkan/prim.frag
|
||||
shader/vulkan/prim.vert
|
||||
shader/vulkan/prim3d.frag
|
||||
|
@ -1568,6 +1571,8 @@ set(EXPECTED_DATA
|
|||
shader/vulkan/text.vert
|
||||
shader/vulkan/tile.frag
|
||||
shader/vulkan/tile.vert
|
||||
shader/vulkan/tile_border.frag
|
||||
shader/vulkan/tile_border.vert
|
||||
skins/PaladiN.png
|
||||
skins/antiantey.png
|
||||
skins/beast.png
|
||||
|
|
|
@ -136,17 +136,11 @@ if(NOT FOUND_MATCHING_SHA256_FILE)
|
|||
generate_shader_file("-DTW_TILE_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_textured.frag.spv")
|
||||
generate_shader_file("-DTW_TILE_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_textured.vert.spv")
|
||||
|
||||
generate_shader_file("-DTW_TILE_BORDER" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border.frag.spv")
|
||||
generate_shader_file("-DTW_TILE_BORDER" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border.vert.spv")
|
||||
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile_border.frag" "data/shader/vulkan/tile_border.frag.spv")
|
||||
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile_border.vert" "data/shader/vulkan/tile_border.vert.spv")
|
||||
|
||||
generate_shader_file("-DTW_TILE_BORDER" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_textured.frag.spv")
|
||||
generate_shader_file("-DTW_TILE_BORDER" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_textured.vert.spv")
|
||||
|
||||
generate_shader_file("-DTW_TILE_BORDER_LINE" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_line.frag.spv")
|
||||
generate_shader_file("-DTW_TILE_BORDER_LINE" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_line.vert.spv")
|
||||
|
||||
generate_shader_file("-DTW_TILE_BORDER_LINE" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_line_textured.frag.spv")
|
||||
generate_shader_file("-DTW_TILE_BORDER_LINE" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_line_textured.vert.spv")
|
||||
generate_shader_file("" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile_border.frag" "data/shader/vulkan/tile_border_textured.frag.spv")
|
||||
generate_shader_file("" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile_border.vert" "data/shader/vulkan/tile_border_textured.vert.spv")
|
||||
|
||||
# quad layer
|
||||
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.frag" "data/shader/vulkan/quad.frag.spv")
|
||||
|
|
BIN
data/editor/speed_arrow_array.png
Normal file
BIN
data/editor/speed_arrow_array.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
|
@ -1,44 +1,19 @@
|
|||
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;
|
||||
|
||||
#if defined(TW_TILE_BORDER) || defined(TW_TILE_BORDER_LINE)
|
||||
uniform vec2 gDir;
|
||||
uniform vec2 gOffset;
|
||||
#endif
|
||||
|
||||
#if defined(TW_TILE_BORDER)
|
||||
uniform int gJumpIndex;
|
||||
#endif
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
noperspective out vec3 TexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if defined(TW_TILE_BORDER)
|
||||
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
|
||||
int XCount = gl_InstanceID - (int(gl_InstanceID/gJumpIndex) * gJumpIndex);
|
||||
int YCount = (int(gl_InstanceID/gJumpIndex));
|
||||
VertPos.x += gOffset.x + gDir.x * float(XCount);
|
||||
VertPos.y += gOffset.y + gDir.y * float(YCount);
|
||||
|
||||
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
||||
#elif defined(TW_TILE_BORDER_LINE)
|
||||
vec4 VertPos = vec4(inVertex.x + gOffset.x, inVertex.y + gOffset.y, 0.0, 1.0);
|
||||
VertPos.x += gDir.x * float(gl_InstanceID);
|
||||
VertPos.y += gDir.y * float(gl_InstanceID);
|
||||
|
||||
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(gPos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
TexCoord = inVertexTexCoord;
|
||||
TexCoord = vec3(inVertexTexCoord.xyz);
|
||||
#endif
|
||||
}
|
||||
|
|
28
data/shader/tile_border.frag
Normal file
28
data/shader/tile_border.frag
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifdef TW_TILE_TEXTURED
|
||||
#ifdef TW_TILE_3D_TEXTURED
|
||||
uniform sampler3D gTextureSampler;
|
||||
#else
|
||||
uniform sampler2DArray gTextureSampler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uniform vec4 gVertColor;
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
noperspective in vec3 TexCoord;
|
||||
#endif
|
||||
|
||||
out vec4 FragClr;
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
vec3 realTexCoords = vec3(fract(TexCoord.xy), TexCoord.z);
|
||||
vec2 dx = dFdx(TexCoord.xy);
|
||||
vec2 dy = dFdy(TexCoord.xy);
|
||||
vec4 tex = textureGrad(gTextureSampler, realTexCoords, dx, dy);
|
||||
FragClr = tex * gVertColor;
|
||||
#else
|
||||
FragClr = gVertColor;
|
||||
#endif
|
||||
}
|
28
data/shader/tile_border.vert
Normal file
28
data/shader/tile_border.vert
Normal file
|
@ -0,0 +1,28 @@
|
|||
layout (location = 0) in vec2 inVertex;
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
layout (location = 1) in uvec4 inVertexTexCoord;
|
||||
#endif
|
||||
|
||||
uniform mat4x2 gPos;
|
||||
|
||||
uniform vec2 gOffset;
|
||||
uniform vec2 gScale;
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
noperspective out vec3 TexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
// scale then position vertex
|
||||
vec2 VertexPos = (inVertex * gScale) + gOffset;
|
||||
gl_Position = vec4(gPos * vec4(VertexPos, 0.0, 1.0), 0.0, 1.0);
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
// scale the texture coordinates too
|
||||
vec2 TexScale = gScale;
|
||||
if (float(inVertexTexCoord.w) > 0.0)
|
||||
TexScale = gScale.yx;
|
||||
TexCoord = vec3(vec2(inVertexTexCoord.xy) * TexScale, float(inVertexTexCoord.z));
|
||||
#endif
|
||||
}
|
|
@ -3,20 +3,11 @@
|
|||
|
||||
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 {
|
||||
layout(offset = 0) uniform mat4x2 gPos;
|
||||
|
||||
#if defined(TW_TILE_BORDER) || defined(TW_TILE_BORDER_LINE)
|
||||
layout(offset = 32) uniform vec2 gDir;
|
||||
layout(offset = 40) uniform vec2 gOffset;
|
||||
#endif
|
||||
|
||||
#if defined(TW_TILE_BORDER)
|
||||
layout(offset = 48) uniform int gJumpIndex;
|
||||
#endif
|
||||
} gPosBO;
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
|
@ -25,25 +16,9 @@ layout (location = 0) noperspective out vec3 TexCoord;
|
|||
|
||||
void main()
|
||||
{
|
||||
#if defined(TW_TILE_BORDER)
|
||||
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
|
||||
int XCount = gl_InstanceIndex - (int(gl_InstanceIndex/gPosBO.gJumpIndex) * gPosBO.gJumpIndex);
|
||||
int YCount = (int(gl_InstanceIndex/gPosBO.gJumpIndex));
|
||||
VertPos.x += gPosBO.gOffset.x + gPosBO.gDir.x * float(XCount);
|
||||
VertPos.y += gPosBO.gOffset.y + gPosBO.gDir.y * float(YCount);
|
||||
|
||||
gl_Position = vec4(gPosBO.gPos * VertPos, 0.0, 1.0);
|
||||
#elif defined(TW_TILE_BORDER_LINE)
|
||||
vec4 VertPos = vec4(inVertex.x + gPosBO.gOffset.x, inVertex.y + gPosBO.gOffset.y, 0.0, 1.0);
|
||||
VertPos.x += gPosBO.gDir.x * float(gl_InstanceIndex);
|
||||
VertPos.y += gPosBO.gDir.y * float(gl_InstanceIndex);
|
||||
|
||||
gl_Position = vec4(gPosBO.gPos * VertPos, 0.0, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(gPosBO.gPos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
TexCoord = inVertexTexCoord;
|
||||
TexCoord = vec3(inVertexTexCoord.xyz);
|
||||
#endif
|
||||
}
|
||||
|
|
28
data/shader/vulkan/tile_border.frag
Normal file
28
data/shader/vulkan/tile_border.frag
Normal file
|
@ -0,0 +1,28 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
layout(binding = 0) uniform sampler2DArray gTextureSampler;
|
||||
#endif
|
||||
|
||||
layout(push_constant) uniform SVertexColorBO {
|
||||
layout(offset = 64) uniform vec4 gVertColor;
|
||||
} gColorBO;
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
layout (location = 0) noperspective in vec3 TexCoord;
|
||||
#endif
|
||||
|
||||
layout (location = 0) out vec4 FragClr;
|
||||
void main()
|
||||
{
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
vec3 realTexCoords = vec3(fract(TexCoord.xy), TexCoord.z);
|
||||
vec2 dx = dFdx(TexCoord.xy);
|
||||
vec2 dy = dFdy(TexCoord.xy);
|
||||
vec4 tex = textureGrad(gTextureSampler, realTexCoords, dx, dy);
|
||||
FragClr = tex * gColorBO.gVertColor;
|
||||
#else
|
||||
FragClr = gColorBO.gVertColor;
|
||||
#endif
|
||||
}
|
33
data/shader/vulkan/tile_border.vert
Normal file
33
data/shader/vulkan/tile_border.vert
Normal file
|
@ -0,0 +1,33 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout (location = 0) in vec2 inVertex;
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
layout (location = 1) in uvec4 inVertexTexCoord;
|
||||
#endif
|
||||
|
||||
layout(push_constant) uniform SPosBO {
|
||||
layout(offset = 0) uniform mat4x2 gPos;
|
||||
|
||||
layout(offset = 32) uniform vec2 gOffset;
|
||||
layout(offset = 40) uniform vec2 gScale;
|
||||
} gPosBO;
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
layout (location = 0) noperspective out vec3 TexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
// scale then position vertex
|
||||
vec2 VertexPos = (inVertex * gPosBO.gScale) + gPosBO.gOffset;
|
||||
gl_Position = vec4(gPosBO.gPos * vec4(VertexPos, 0.0, 1.0), 0.0, 1.0);
|
||||
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
// scale the texture coordinates too
|
||||
vec2 TexScale = gPosBO.gScale;
|
||||
if (inVertexTexCoord.w > 0)
|
||||
TexScale = gPosBO.gScale.yx;
|
||||
TexCoord = vec3(vec2(inVertexTexCoord.xy) * TexScale, float(inVertexTexCoord.z));
|
||||
#endif
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
#define BASE_VMATH_H
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#include "math.h"
|
||||
|
||||
|
@ -399,5 +400,6 @@ public:
|
|||
typedef vector4_base<float> vec4;
|
||||
typedef vector4_base<bool> bvec4;
|
||||
typedef vector4_base<int> ivec4;
|
||||
typedef vector4_base<uint8_t> ubvec4;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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,19 +472,7 @@ 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 = pCommand->m_pCapabilities->m_2DArrayTextures || pCommand->m_pCapabilities->m_3DTextures;
|
||||
pCommand->m_pCapabilities->m_TileBuffering = false;
|
||||
pCommand->m_pCapabilities->m_QuadBuffering = false;
|
||||
pCommand->m_pCapabilities->m_TextBuffering = false;
|
||||
pCommand->m_pCapabilities->m_QuadContainerBuffering = 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,17 +868,12 @@ 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);
|
||||
int Image3DWidth, Image3DHeight;
|
||||
|
||||
int ConvertWidth = Width;
|
||||
int ConvertHeight = Height;
|
||||
|
||||
if(!IsSingleLayer)
|
||||
{
|
||||
if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0)
|
||||
{
|
||||
dbg_msg("gfx", "3D/2D array texture was resized");
|
||||
|
@ -906,21 +887,12 @@ void CCommandProcessorFragment_OpenGL::TextureCreate(int Slot, int Width, int He
|
|||
free(pTexData);
|
||||
pTexData = pNewTexData;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsSingleLayer || (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
|
||||
if((Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight)))
|
||||
{
|
||||
glTexImage3D(Target, 0, GLStoreFormat, Image3DWidth, Image3DHeight, 256, 0, GLFormat, GL_UNSIGNED_BYTE, p3DImageData);
|
||||
}
|
||||
}
|
||||
|
||||
if(!IsSingleLayer)
|
||||
free(p3DImageData);
|
||||
}
|
||||
}
|
||||
|
@ -1116,7 +1088,6 @@ ERunCommandReturnTypes CCommandProcessorFragment_OpenGL::RunCommand(const CComma
|
|||
|
||||
case CCommandBuffer::CMD_RENDER_TILE_LAYER: Cmd_RenderTileLayer(static_cast<const CCommandBuffer::SCommand_RenderTileLayer *>(pBaseCommand)); break;
|
||||
case CCommandBuffer::CMD_RENDER_BORDER_TILE: Cmd_RenderBorderTile(static_cast<const CCommandBuffer::SCommand_RenderBorderTile *>(pBaseCommand)); break;
|
||||
case CCommandBuffer::CMD_RENDER_BORDER_TILE_LINE: Cmd_RenderBorderTileLine(static_cast<const CCommandBuffer::SCommand_RenderBorderTileLine *>(pBaseCommand)); break;
|
||||
case CCommandBuffer::CMD_RENDER_QUAD_LAYER: Cmd_RenderQuadLayer(static_cast<const CCommandBuffer::SCommand_RenderQuadLayer *>(pBaseCommand)); break;
|
||||
case CCommandBuffer::CMD_RENDER_TEXT: Cmd_RenderText(static_cast<const CCommandBuffer::SCommand_RenderText *>(pBaseCommand)); break;
|
||||
case CCommandBuffer::CMD_RENDER_QUAD_CONTAINER: Cmd_RenderQuadContainer(static_cast<const CCommandBuffer::SCommand_RenderQuadContainer *>(pBaseCommand)); break;
|
||||
|
@ -1283,7 +1254,7 @@ void CCommandProcessorFragment_OpenGL2::SetState(const CCommandBuffer::SState &S
|
|||
}
|
||||
|
||||
#ifndef BACKEND_GL_MODERN_API
|
||||
bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t StepN, size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize)
|
||||
bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -1291,18 +1262,10 @@ bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t StepN, size_t Check
|
|||
if(m_HasShaders)
|
||||
{
|
||||
CGLSLTWProgram *pProgram = m_pPrimitive3DProgramTextured;
|
||||
if(StepN == 1)
|
||||
pProgram = m_pTileProgramTextured;
|
||||
UseProgram(pProgram);
|
||||
|
||||
pProgram->SetUniform(pProgram->m_LocTextureSampler, Slot);
|
||||
|
||||
if(StepN == 1)
|
||||
{
|
||||
float aColor[4] = {1.f, 1.f, 1.f, 1.f};
|
||||
pProgram->SetUniformVec4(((CGLSLTileProgram *)pProgram)->m_LocColor, 1, aColor);
|
||||
}
|
||||
|
||||
float m[2 * 4] = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0};
|
||||
|
@ -1317,20 +1280,6 @@ bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t StepN, size_t Check
|
|||
glOrtho(-1, 1, -1, 1, -10.0f, 10.f);
|
||||
}
|
||||
|
||||
GLuint BufferID = 0;
|
||||
if(StepN == 1 && m_HasShaders)
|
||||
{
|
||||
glGenBuffers(1, &BufferID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, BufferID);
|
||||
glBufferData(GL_ARRAY_BUFFER, VerticesCount * sizeof((m_aStreamVertices[0])), m_aStreamVertices, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, false, sizeof((m_aStreamVertices[0])), 0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof((m_aStreamVertices[0])), (GLvoid *)(sizeof(vec4) + sizeof(vec2)));
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -1338,23 +1287,12 @@ bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t StepN, size_t Check
|
|||
glVertexPointer(2, GL_FLOAT, sizeof(m_aStreamVertices[0]), m_aStreamVertices);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2)));
|
||||
glTexCoordPointer(3, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2) + sizeof(vec4)));
|
||||
}
|
||||
|
||||
glDrawArrays(GL_QUADS, 0, VerticesCount);
|
||||
|
||||
if(StepN == 1 && m_HasShaders)
|
||||
{
|
||||
glDisableVertexAttribArray(0);
|
||||
glDisableVertexAttribArray(1);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glDeleteBuffers(1, &BufferID);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
|
@ -1585,9 +1523,7 @@ bool CCommandProcessorFragment_OpenGL2::IsTileMapAnalysisSucceeded()
|
|||
}
|
||||
|
||||
// everything build up, now do the analyze steps
|
||||
bool NoError = DoAnalyzeStep(0, CheckCount, VertexCount, pFakeTexture, SingleImageSize);
|
||||
if(NoError && m_HasShaders)
|
||||
NoError &= DoAnalyzeStep(1, CheckCount, VertexCount, pFakeTexture, SingleImageSize);
|
||||
bool NoError = DoAnalyzeStep(CheckCount, VertexCount, pFakeTexture, SingleImageSize);
|
||||
|
||||
glDeleteTextures(1, &FakeTexture);
|
||||
free(pFakeTexture);
|
||||
|
@ -1615,7 +1551,7 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
|
|||
{
|
||||
HasAllFunc &= (glUniformMatrix4x2fv != NULL) && (glGenBuffers != NULL);
|
||||
HasAllFunc &= (glBindBuffer != NULL) && (glBufferData != NULL);
|
||||
HasAllFunc &= (glEnableVertexAttribArray != NULL) && (glVertexAttribPointer != NULL);
|
||||
HasAllFunc &= (glEnableVertexAttribArray != NULL) && (glVertexAttribPointer != NULL) && (glVertexAttribIPointer != NULL);
|
||||
HasAllFunc &= (glDisableVertexAttribArray != NULL) && (glDeleteBuffers != NULL);
|
||||
HasAllFunc &= (glUseProgram != NULL) && (glTexImage3D != NULL);
|
||||
HasAllFunc &= (glBindAttribLocation != NULL) && (glTexImage3D != NULL);
|
||||
|
@ -1641,6 +1577,8 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
|
|||
{
|
||||
m_pTileProgram = new CGLSLTileProgram;
|
||||
m_pTileProgramTextured = new CGLSLTileProgram;
|
||||
m_pBorderTileProgram = new CGLSLTileProgram;
|
||||
m_pBorderTileProgramTextured = new CGLSLTileProgram;
|
||||
m_pPrimitive3DProgram = new CGLSLPrimitiveProgram;
|
||||
m_pPrimitive3DProgramTextured = new CGLSLPrimitiveProgram;
|
||||
|
||||
|
@ -1743,6 +1681,63 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
|
|||
m_pTileProgramTextured->m_LocTextureSampler = m_pTileProgramTextured->GetUniformLoc("gTextureSampler");
|
||||
m_pTileProgramTextured->m_LocColor = m_pTileProgramTextured->GetUniformLoc("gVertColor");
|
||||
}
|
||||
if(pCommand->m_pCapabilities->m_2DArrayTextures)
|
||||
ShaderCompiler.SetTextureReplaceType(CGLSLCompiler::GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY);
|
||||
else
|
||||
ShaderCompiler.SetTextureReplaceType(CGLSLCompiler::GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D);
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileProgram->CreateProgram();
|
||||
m_pBorderTileProgram->AddShader(&VertexShader);
|
||||
m_pBorderTileProgram->AddShader(&FragmentShader);
|
||||
|
||||
glBindAttribLocation(m_pBorderTileProgram->GetProgramID(), 0, "inVertex");
|
||||
|
||||
m_pBorderTileProgram->LinkProgram();
|
||||
|
||||
UseProgram(m_pBorderTileProgram);
|
||||
|
||||
m_pBorderTileProgram->m_LocPos = m_pBorderTileProgram->GetUniformLoc("gPos");
|
||||
m_pBorderTileProgram->m_LocColor = m_pBorderTileProgram->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileProgram->m_LocOffset = m_pBorderTileProgram->GetUniformLoc("gOffset");
|
||||
m_pBorderTileProgram->m_LocScale = m_pBorderTileProgram->GetUniformLoc("gScale");
|
||||
}
|
||||
if(pCommand->m_pCapabilities->m_2DArrayTextures)
|
||||
ShaderCompiler.SetTextureReplaceType(CGLSLCompiler::GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY);
|
||||
else
|
||||
ShaderCompiler.SetTextureReplaceType(CGLSLCompiler::GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D);
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
ShaderCompiler.AddDefine("TW_TILE_TEXTURED", "");
|
||||
if(!pCommand->m_pCapabilities->m_2DArrayTextures)
|
||||
ShaderCompiler.AddDefine("TW_TILE_3D_TEXTURED", "");
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileProgramTextured->CreateProgram();
|
||||
m_pBorderTileProgramTextured->AddShader(&VertexShader);
|
||||
m_pBorderTileProgramTextured->AddShader(&FragmentShader);
|
||||
|
||||
glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramID(), 0, "inVertex");
|
||||
glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramID(), 1, "inVertexTexCoord");
|
||||
|
||||
m_pBorderTileProgramTextured->LinkProgram();
|
||||
|
||||
UseProgram(m_pBorderTileProgramTextured);
|
||||
|
||||
m_pBorderTileProgramTextured->m_LocPos = m_pBorderTileProgramTextured->GetUniformLoc("gPos");
|
||||
m_pBorderTileProgramTextured->m_LocTextureSampler = m_pBorderTileProgramTextured->GetUniformLoc("gTextureSampler");
|
||||
m_pBorderTileProgramTextured->m_LocColor = m_pBorderTileProgramTextured->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileProgramTextured->m_LocOffset = m_pBorderTileProgramTextured->GetUniformLoc("gOffset");
|
||||
m_pBorderTileProgramTextured->m_LocScale = m_pBorderTileProgramTextured->GetUniformLoc("gScale");
|
||||
}
|
||||
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
@ -1850,13 +1845,10 @@ void CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(const CCommandBuf
|
|||
|
||||
GLuint VertBufferID = 0;
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glGenBuffers(1, &VertBufferID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VertBufferID);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
|
||||
BufferObject.m_BufferObjectID = VertBufferID;
|
||||
|
@ -1875,12 +1867,9 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RecreateBufferObject(const CCommandB
|
|||
int Index = pCommand->m_BufferIndex;
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
BufferObject.m_DataSize = pCommand->m_DataSize;
|
||||
free(BufferObject.m_pData);
|
||||
|
@ -1898,12 +1887,9 @@ void CCommandProcessorFragment_OpenGL2::Cmd_UpdateBufferObject(const CCommandBuf
|
|||
int Index = pCommand->m_BufferIndex;
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_pOffset), (GLsizeiptr)(pCommand->m_DataSize), pUploadData);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
if(pUploadData)
|
||||
mem_copy(((uint8_t *)BufferObject.m_pData) + (ptrdiff_t)pCommand->m_pOffset, pUploadData, pCommand->m_DataSize);
|
||||
|
@ -1922,12 +1908,9 @@ void CCommandProcessorFragment_OpenGL2::Cmd_CopyBufferObject(const CCommandBuffe
|
|||
|
||||
mem_copy(((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset, ((uint8_t *)ReadBufferObject.m_pData) + (ptrdiff_t)pCommand->m_ReadOffset, pCommand->m_CopySize);
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, WriteBufferObject.m_BufferObjectID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_WriteOffset), (GLsizeiptr)(pCommand->m_CopySize), ((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand)
|
||||
|
@ -1935,10 +1918,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_DeleteBufferObject(const CCommandBuf
|
|||
int Index = pCommand->m_BufferIndex;
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glDeleteBuffers(1, &BufferObject.m_BufferObjectID);
|
||||
}
|
||||
|
||||
free(BufferObject.m_pData);
|
||||
BufferObject.m_pData = NULL;
|
||||
|
@ -1993,11 +1973,8 @@ void CCommandProcessorFragment_OpenGL2::Cmd_DeleteBufferContainer(const CCommand
|
|||
{
|
||||
int VertBufferID = BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex;
|
||||
if(VertBufferID != -1)
|
||||
{
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glDeleteBuffers(1, &m_vBufferObjectIndices[VertBufferID].m_BufferObjectID);
|
||||
}
|
||||
|
||||
free(m_vBufferObjectIndices[VertBufferID].m_pData);
|
||||
m_vBufferObjectIndices[VertBufferID].m_pData = NULL;
|
||||
|
@ -2011,170 +1988,6 @@ void CCommandProcessorFragment_OpenGL2::Cmd_IndicesRequiredNumNotify(const CComm
|
|||
{
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::RenderBorderTileEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const ColorRGBA &Color, const char *pBuffOffset, unsigned int DrawNum, const vec2 &Offset, const vec2 &Dir, int JumpIndex)
|
||||
{
|
||||
if(m_HasShaders)
|
||||
{
|
||||
CGLSLPrimitiveProgram *pProgram = NULL;
|
||||
if(IsTexturedState(State))
|
||||
{
|
||||
pProgram = m_pPrimitive3DProgramTextured;
|
||||
}
|
||||
else
|
||||
pProgram = m_pPrimitive3DProgram;
|
||||
|
||||
UseProgram(pProgram);
|
||||
|
||||
SetState(State, pProgram, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCommandProcessorFragment_OpenGL::SetState(State, true);
|
||||
}
|
||||
|
||||
bool IsTextured = BufferContainer.m_ContainerInfo.m_vAttributes.size() == 2;
|
||||
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(m_aStreamVertices[0]), m_aStreamVertices);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2)));
|
||||
if(IsTextured)
|
||||
glTexCoordPointer(3, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2) + sizeof(vec4)));
|
||||
|
||||
size_t VertexCount = 0;
|
||||
for(size_t i = 0; i < DrawNum; ++i)
|
||||
{
|
||||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pBuffOffset)) / (6 * sizeof(unsigned int))) * 4);
|
||||
size_t SingleVertSize = (sizeof(vec2) + (IsTextured ? sizeof(vec3) : 0));
|
||||
size_t CurBufferOffset = RealOffset * SingleVertSize;
|
||||
int XCount = i - (size_t)(i / JumpIndex) * JumpIndex;
|
||||
int YCount = (size_t)(i / JumpIndex);
|
||||
for(size_t n = 0; n < 4; ++n)
|
||||
{
|
||||
ptrdiff_t VertOffset = (ptrdiff_t)(CurBufferOffset + (n * SingleVertSize));
|
||||
vec2 *pPos = (vec2 *)((uint8_t *)BufferObject.m_pData + VertOffset);
|
||||
|
||||
GL_SVertexTex3D &Vertex = m_aStreamVertices[VertexCount++];
|
||||
Vertex.m_Pos = *pPos;
|
||||
Vertex.m_Color = Color;
|
||||
if(IsTextured)
|
||||
{
|
||||
vec3 *pTex = (vec3 *)((uint8_t *)BufferObject.m_pData + VertOffset + (ptrdiff_t)sizeof(vec2));
|
||||
Vertex.m_Tex = *pTex;
|
||||
}
|
||||
|
||||
Vertex.m_Pos += Offset + Dir * vec2(XCount, YCount);
|
||||
|
||||
if(VertexCount >= std::size(m_aStreamVertices))
|
||||
{
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
VertexCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(VertexCount > 0)
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glUseProgram(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::RenderBorderTileLineEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const ColorRGBA &Color, const char *pBuffOffset, unsigned int IndexDrawNum, unsigned int DrawNum, const vec2 &Offset, const vec2 &Dir)
|
||||
{
|
||||
if(m_HasShaders)
|
||||
{
|
||||
CGLSLPrimitiveProgram *pProgram = NULL;
|
||||
if(IsTexturedState(State))
|
||||
{
|
||||
pProgram = m_pPrimitive3DProgramTextured;
|
||||
}
|
||||
else
|
||||
pProgram = m_pPrimitive3DProgram;
|
||||
|
||||
UseProgram(pProgram);
|
||||
|
||||
SetState(State, pProgram, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCommandProcessorFragment_OpenGL::SetState(State, true);
|
||||
}
|
||||
|
||||
bool IsTextured = BufferContainer.m_ContainerInfo.m_vAttributes.size() == 2;
|
||||
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(m_aStreamVertices[0]), m_aStreamVertices);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2)));
|
||||
if(IsTextured)
|
||||
glTexCoordPointer(3, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2) + sizeof(vec4)));
|
||||
|
||||
size_t VertexCount = 0;
|
||||
for(size_t i = 0; i < DrawNum; ++i)
|
||||
{
|
||||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pBuffOffset)) / (6 * sizeof(unsigned int))) * 4);
|
||||
size_t SingleVertSize = (sizeof(vec2) + (IsTextured ? sizeof(vec3) : 0));
|
||||
size_t CurBufferOffset = (RealOffset)*SingleVertSize;
|
||||
size_t VerticesPerLine = (size_t)IndexDrawNum / 6;
|
||||
|
||||
for(size_t n = 0; n < 4 * (size_t)VerticesPerLine; ++n)
|
||||
{
|
||||
ptrdiff_t VertOffset = (ptrdiff_t)(CurBufferOffset + (n * SingleVertSize));
|
||||
vec2 *pPos = (vec2 *)((uint8_t *)BufferObject.m_pData + VertOffset);
|
||||
|
||||
GL_SVertexTex3D &Vertex = m_aStreamVertices[VertexCount++];
|
||||
Vertex.m_Pos = *pPos;
|
||||
Vertex.m_Color = Color;
|
||||
if(IsTextured)
|
||||
{
|
||||
vec3 *pTex = (vec3 *)((uint8_t *)BufferObject.m_pData + VertOffset + (ptrdiff_t)sizeof(vec2));
|
||||
Vertex.m_Tex = *pTex;
|
||||
}
|
||||
|
||||
Vertex.m_Pos += Offset + Dir * i;
|
||||
|
||||
if(VertexCount >= std::size(m_aStreamVertices))
|
||||
{
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
VertexCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(VertexCount > 0)
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glUseProgram(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand)
|
||||
{
|
||||
int Index = pCommand->m_BufferContainerIndex;
|
||||
|
@ -2184,19 +1997,42 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderBorderTile(const CCommandBuffe
|
|||
|
||||
SBufferContainer &BufferContainer = m_vBufferContainers[Index];
|
||||
|
||||
RenderBorderTileEmulation(BufferContainer, pCommand->m_State, pCommand->m_Color, pCommand->m_pIndicesOffset, pCommand->m_DrawNum, pCommand->m_Offset, pCommand->m_Dir, pCommand->m_JumpIndex);
|
||||
}
|
||||
CGLSLTileProgram *pProgram = NULL;
|
||||
if(IsTexturedState(pCommand->m_State))
|
||||
pProgram = m_pBorderTileProgramTextured;
|
||||
else
|
||||
pProgram = m_pBorderTileProgram;
|
||||
UseProgram(pProgram);
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand)
|
||||
{
|
||||
int Index = pCommand->m_BufferContainerIndex;
|
||||
// if space not there return
|
||||
if((size_t)Index >= m_vBufferContainers.size())
|
||||
return;
|
||||
SetState(pCommand->m_State, pProgram, true);
|
||||
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color);
|
||||
|
||||
SBufferContainer &BufferContainer = m_vBufferContainers[Index];
|
||||
pProgram->SetUniformVec2(pProgram->m_LocOffset, 1, (float *)&pCommand->m_Offset);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocScale, 1, (float *)&pCommand->m_Scale);
|
||||
|
||||
RenderBorderTileLineEmulation(BufferContainer, pCommand->m_State, pCommand->m_Color, pCommand->m_pIndicesOffset, pCommand->m_IndexDrawNum, pCommand->m_DrawNum, pCommand->m_Offset, pCommand->m_Dir);
|
||||
bool IsTextured = BufferContainer.m_ContainerInfo.m_vAttributes.size() == 2;
|
||||
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset);
|
||||
if(IsTextured)
|
||||
{
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribIPointer(1, 4, GL_UNSIGNED_BYTE, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset);
|
||||
}
|
||||
|
||||
size_t RealDrawCount = pCommand->m_DrawNum * 4;
|
||||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pCommand->m_pIndicesOffset)) / (6 * sizeof(unsigned int))) * 4);
|
||||
glDrawArrays(GL_QUADS, RealOffset, RealDrawCount);
|
||||
|
||||
glDisableVertexAttribArray(0);
|
||||
if(IsTextured)
|
||||
glDisableVertexAttribArray(1);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand)
|
||||
|
@ -2213,8 +2049,6 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer
|
|||
return; // nothing to draw
|
||||
}
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
CGLSLTileProgram *pProgram = NULL;
|
||||
if(IsTexturedState(pCommand->m_State))
|
||||
{
|
||||
|
@ -2227,35 +2061,19 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer
|
|||
|
||||
SetState(pCommand->m_State, pProgram, true);
|
||||
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCommandProcessorFragment_OpenGL::SetState(pCommand->m_State, true);
|
||||
}
|
||||
|
||||
bool IsTextured = BufferContainer.m_ContainerInfo.m_vAttributes.size() == 2;
|
||||
|
||||
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
|
||||
if(m_HasShaders)
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID);
|
||||
|
||||
if(!m_HasShaders)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if(m_HasShaders)
|
||||
{
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset);
|
||||
if(IsTextured)
|
||||
{
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset);
|
||||
glVertexAttribIPointer(1, 4, GL_UNSIGNED_BYTE, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[1].m_pOffset);
|
||||
}
|
||||
|
||||
for(int i = 0; i < pCommand->m_IndicesDrawNum; ++i)
|
||||
|
@ -2264,62 +2082,12 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer
|
|||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pCommand->m_pIndicesOffsets[i])) / (6 * sizeof(unsigned int))) * 4);
|
||||
glDrawArrays(GL_QUADS, RealOffset, RealDrawCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(m_aStreamVertices[0]), m_aStreamVertices);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2)));
|
||||
if(IsTextured)
|
||||
glTexCoordPointer(3, GL_FLOAT, sizeof(m_aStreamVertices[0]), (uint8_t *)m_aStreamVertices + (ptrdiff_t)(sizeof(vec2) + sizeof(vec4)));
|
||||
|
||||
size_t VertexCount = 0;
|
||||
for(int i = 0; i < pCommand->m_IndicesDrawNum; ++i)
|
||||
{
|
||||
size_t RealDrawCount = (pCommand->m_pDrawCount[i] / 6) * 4;
|
||||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pCommand->m_pIndicesOffsets[i])) / (6 * sizeof(unsigned int))) * 4);
|
||||
size_t SingleVertSize = (sizeof(vec2) + (IsTextured ? sizeof(vec3) : 0));
|
||||
size_t CurBufferOffset = RealOffset * SingleVertSize;
|
||||
|
||||
for(size_t n = 0; n < RealDrawCount; ++n)
|
||||
{
|
||||
ptrdiff_t VertOffset = (ptrdiff_t)(CurBufferOffset + (n * SingleVertSize));
|
||||
vec2 *pPos = (vec2 *)((uint8_t *)BufferObject.m_pData + VertOffset);
|
||||
GL_SVertexTex3D &Vertex = m_aStreamVertices[VertexCount++];
|
||||
Vertex.m_Pos = *pPos;
|
||||
Vertex.m_Color = pCommand->m_Color;
|
||||
if(IsTextured)
|
||||
{
|
||||
vec3 *pTex = (vec3 *)((uint8_t *)BufferObject.m_pData + VertOffset + (ptrdiff_t)sizeof(vec2));
|
||||
Vertex.m_Tex = *pTex;
|
||||
}
|
||||
|
||||
if(VertexCount >= std::size(m_aStreamVertices))
|
||||
{
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
VertexCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(VertexCount > 0)
|
||||
glDrawArrays(GL_QUADS, 0, VertexCount);
|
||||
}
|
||||
|
||||
if(!m_HasShaders)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(IsTextured)
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisableVertexAttribArray(0);
|
||||
if(IsTextured)
|
||||
glDisableVertexAttribArray(1);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
}
|
||||
|
||||
#undef BACKEND_GL_MODERN_API
|
||||
|
|
|
@ -116,7 +116,6 @@ protected:
|
|||
|
||||
virtual void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderTileLayer"); }
|
||||
virtual void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderBorderTile"); }
|
||||
virtual void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderBorderTileLine"); }
|
||||
virtual void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderQuadLayer"); }
|
||||
virtual void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderText"); }
|
||||
virtual void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) { dbg_assert(false, "Call of unsupported Cmd_RenderQuadContainer"); }
|
||||
|
@ -158,11 +157,8 @@ class CCommandProcessorFragment_OpenGL2 : public CCommandProcessorFragment_OpenG
|
|||
std::vector<SBufferObject> m_vBufferObjectIndices;
|
||||
|
||||
#ifndef BACKEND_GL_MODERN_API
|
||||
bool DoAnalyzeStep(size_t StepN, size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize);
|
||||
bool DoAnalyzeStep(size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize);
|
||||
bool IsTileMapAnalysisSucceeded();
|
||||
|
||||
void RenderBorderTileEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const ColorRGBA &Color, const char *pBuffOffset, unsigned int DrawNum, const vec2 &Offset, const vec2 &Dir, int JumpIndex);
|
||||
void RenderBorderTileLineEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const ColorRGBA &Color, const char *pBuffOffset, unsigned int IndexDrawNum, unsigned int DrawNum, const vec2 &Offset, const vec2 &Dir);
|
||||
#endif
|
||||
|
||||
void UseProgram(CGLSLTWProgram *pProgram);
|
||||
|
@ -189,11 +185,12 @@ protected:
|
|||
|
||||
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override;
|
||||
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override;
|
||||
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) override;
|
||||
#endif
|
||||
|
||||
CGLSLTileProgram *m_pTileProgram;
|
||||
CGLSLTileProgram *m_pTileProgramTextured;
|
||||
CGLSLTileProgram *m_pBorderTileProgram;
|
||||
CGLSLTileProgram *m_pBorderTileProgramTextured;
|
||||
CGLSLPrimitiveProgram *m_pPrimitive3DProgram;
|
||||
CGLSLPrimitiveProgram *m_pPrimitive3DProgramTextured;
|
||||
};
|
||||
|
|
|
@ -106,8 +106,6 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
m_pPrimitive3DProgramTextured = new CGLSLPrimitiveProgram;
|
||||
m_pBorderTileProgram = new CGLSLTileProgram;
|
||||
m_pBorderTileProgramTextured = new CGLSLTileProgram;
|
||||
m_pBorderTileLineProgram = new CGLSLTileProgram;
|
||||
m_pBorderTileLineProgramTextured = new CGLSLTileProgram;
|
||||
m_pQuadProgram = new CGLSLQuadProgram;
|
||||
m_pQuadProgramTextured = new CGLSLQuadProgram;
|
||||
m_pTextProgram = new CGLSLTextProgram;
|
||||
|
@ -237,9 +235,8 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
ShaderCompiler.AddDefine("TW_TILE_BORDER", "");
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileProgram->CreateProgram();
|
||||
|
@ -252,16 +249,14 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
m_pBorderTileProgram->m_LocPos = m_pBorderTileProgram->GetUniformLoc("gPos");
|
||||
m_pBorderTileProgram->m_LocColor = m_pBorderTileProgram->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileProgram->m_LocOffset = m_pBorderTileProgram->GetUniformLoc("gOffset");
|
||||
m_pBorderTileProgram->m_LocDir = m_pBorderTileProgram->GetUniformLoc("gDir");
|
||||
m_pBorderTileProgram->m_LocJumpIndex = m_pBorderTileProgram->GetUniformLoc("gJumpIndex");
|
||||
m_pBorderTileProgram->m_LocScale = m_pBorderTileProgram->GetUniformLoc("gScale");
|
||||
}
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
ShaderCompiler.AddDefine("TW_TILE_BORDER", "");
|
||||
ShaderCompiler.AddDefine("TW_TILE_TEXTURED", "");
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile_border.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileProgramTextured->CreateProgram();
|
||||
|
@ -275,50 +270,7 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
m_pBorderTileProgramTextured->m_LocTextureSampler = m_pBorderTileProgramTextured->GetUniformLoc("gTextureSampler");
|
||||
m_pBorderTileProgramTextured->m_LocColor = m_pBorderTileProgramTextured->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileProgramTextured->m_LocOffset = m_pBorderTileProgramTextured->GetUniformLoc("gOffset");
|
||||
m_pBorderTileProgramTextured->m_LocDir = m_pBorderTileProgramTextured->GetUniformLoc("gDir");
|
||||
m_pBorderTileProgramTextured->m_LocJumpIndex = m_pBorderTileProgramTextured->GetUniformLoc("gJumpIndex");
|
||||
}
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
ShaderCompiler.AddDefine("TW_TILE_BORDER_LINE", "");
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileLineProgram->CreateProgram();
|
||||
m_pBorderTileLineProgram->AddShader(&VertexShader);
|
||||
m_pBorderTileLineProgram->AddShader(&FragmentShader);
|
||||
m_pBorderTileLineProgram->LinkProgram();
|
||||
|
||||
UseProgram(m_pBorderTileLineProgram);
|
||||
|
||||
m_pBorderTileLineProgram->m_LocPos = m_pBorderTileLineProgram->GetUniformLoc("gPos");
|
||||
m_pBorderTileLineProgram->m_LocColor = m_pBorderTileLineProgram->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileLineProgram->m_LocOffset = m_pBorderTileLineProgram->GetUniformLoc("gOffset");
|
||||
m_pBorderTileLineProgram->m_LocDir = m_pBorderTileLineProgram->GetUniformLoc("gDir");
|
||||
}
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
ShaderCompiler.AddDefine("TW_TILE_BORDER_LINE", "");
|
||||
ShaderCompiler.AddDefine("TW_TILE_TEXTURED", "");
|
||||
VertexShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(&ShaderCompiler, pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
ShaderCompiler.ClearDefines();
|
||||
|
||||
m_pBorderTileLineProgramTextured->CreateProgram();
|
||||
m_pBorderTileLineProgramTextured->AddShader(&VertexShader);
|
||||
m_pBorderTileLineProgramTextured->AddShader(&FragmentShader);
|
||||
m_pBorderTileLineProgramTextured->LinkProgram();
|
||||
|
||||
UseProgram(m_pBorderTileLineProgramTextured);
|
||||
|
||||
m_pBorderTileLineProgramTextured->m_LocPos = m_pBorderTileLineProgramTextured->GetUniformLoc("gPos");
|
||||
m_pBorderTileLineProgramTextured->m_LocTextureSampler = m_pBorderTileLineProgramTextured->GetUniformLoc("gTextureSampler");
|
||||
m_pBorderTileLineProgramTextured->m_LocColor = m_pBorderTileLineProgramTextured->GetUniformLoc("gVertColor");
|
||||
m_pBorderTileLineProgramTextured->m_LocOffset = m_pBorderTileLineProgramTextured->GetUniformLoc("gOffset");
|
||||
m_pBorderTileLineProgramTextured->m_LocDir = m_pBorderTileLineProgramTextured->GetUniformLoc("gDir");
|
||||
m_pBorderTileProgramTextured->m_LocScale = m_pBorderTileProgramTextured->GetUniformLoc("gScale");
|
||||
}
|
||||
{
|
||||
CGLSL VertexShader;
|
||||
|
@ -485,8 +437,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *
|
|||
m_pPrimitiveProgramTextured->DeleteProgram();
|
||||
m_pBorderTileProgram->DeleteProgram();
|
||||
m_pBorderTileProgramTextured->DeleteProgram();
|
||||
m_pBorderTileLineProgram->DeleteProgram();
|
||||
m_pBorderTileLineProgramTextured->DeleteProgram();
|
||||
m_pQuadProgram->DeleteProgram();
|
||||
m_pQuadProgramTextured->DeleteProgram();
|
||||
m_pTileProgram->DeleteProgram();
|
||||
|
@ -505,8 +455,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *
|
|||
delete m_pPrimitiveProgramTextured;
|
||||
delete m_pBorderTileProgram;
|
||||
delete m_pBorderTileProgramTextured;
|
||||
delete m_pBorderTileLineProgram;
|
||||
delete m_pBorderTileLineProgramTextured;
|
||||
delete m_pQuadProgram;
|
||||
delete m_pQuadProgramTextured;
|
||||
delete m_pTileProgram;
|
||||
|
@ -652,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);
|
||||
|
@ -672,17 +620,12 @@ 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);
|
||||
int Image3DWidth, Image3DHeight;
|
||||
|
||||
int ConvertWidth = Width;
|
||||
int ConvertHeight = Height;
|
||||
|
||||
if(!IsSingleLayer)
|
||||
{
|
||||
if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0)
|
||||
{
|
||||
dbg_msg("gfx", "3D/2D array texture was resized");
|
||||
|
@ -696,22 +639,13 @@ void CCommandProcessorFragment_OpenGL3_3::TextureCreate(int Slot, int Width, int
|
|||
free(pTexData);
|
||||
pTexData = pNewTexData;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsSingleLayer || (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
|
||||
if((Texture2DTo3D(pTexData, ConvertWidth, ConvertHeight, PixelSize, 16, 16, p3DImageData, Image3DWidth, Image3DHeight)))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1088,9 +1022,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
|
|||
|
||||
CGLSLTileProgram *pProgram = NULL;
|
||||
if(IsTexturedState(pCommand->m_State))
|
||||
{
|
||||
pProgram = m_pBorderTileProgramTextured;
|
||||
}
|
||||
else
|
||||
pProgram = m_pBorderTileProgram;
|
||||
UseProgram(pProgram);
|
||||
|
@ -1099,8 +1031,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
|
|||
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color);
|
||||
|
||||
pProgram->SetUniformVec2(pProgram->m_LocOffset, 1, (float *)&pCommand->m_Offset);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocDir, 1, (float *)&pCommand->m_Dir);
|
||||
pProgram->SetUniform(pProgram->m_LocJumpIndex, (int)pCommand->m_JumpIndex);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocScale, 1, (float *)&pCommand->m_Scale);
|
||||
|
||||
glBindVertexArray(BufferContainer.m_VertArrayID);
|
||||
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID)
|
||||
|
@ -1108,41 +1039,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
|
||||
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID;
|
||||
}
|
||||
glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset, pCommand->m_DrawNum);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand)
|
||||
{
|
||||
int Index = pCommand->m_BufferContainerIndex;
|
||||
// if space not there return
|
||||
if((size_t)Index >= m_vBufferContainers.size())
|
||||
return;
|
||||
|
||||
SBufferContainer &BufferContainer = m_vBufferContainers[Index];
|
||||
if(BufferContainer.m_VertArrayID == 0)
|
||||
return;
|
||||
|
||||
CGLSLTileProgram *pProgram = NULL;
|
||||
if(IsTexturedState(pCommand->m_State))
|
||||
{
|
||||
pProgram = m_pBorderTileLineProgramTextured;
|
||||
}
|
||||
else
|
||||
pProgram = m_pBorderTileLineProgram;
|
||||
UseProgram(pProgram);
|
||||
|
||||
SetState(pCommand->m_State, pProgram, true);
|
||||
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocOffset, 1, (float *)&pCommand->m_Offset);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocDir, 1, (float *)&pCommand->m_Dir);
|
||||
|
||||
glBindVertexArray(BufferContainer.m_VertArrayID);
|
||||
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID)
|
||||
{
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
|
||||
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID;
|
||||
}
|
||||
glDrawElementsInstanced(GL_TRIANGLES, pCommand->m_IndexDrawNum, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset, pCommand->m_DrawNum);
|
||||
glDrawElements(GL_TRIANGLES, pCommand->m_DrawNum * 6, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand)
|
||||
|
|
|
@ -28,10 +28,6 @@ protected:
|
|||
|
||||
CGLSLPrimitiveProgram *m_pPrimitiveProgram;
|
||||
CGLSLPrimitiveProgram *m_pPrimitiveProgramTextured;
|
||||
CGLSLTileProgram *m_pBorderTileProgram;
|
||||
CGLSLTileProgram *m_pBorderTileProgramTextured;
|
||||
CGLSLTileProgram *m_pBorderTileLineProgram;
|
||||
CGLSLTileProgram *m_pBorderTileLineProgramTextured;
|
||||
CGLSLQuadProgram *m_pQuadProgram;
|
||||
CGLSLQuadProgram *m_pQuadProgramTextured;
|
||||
CGLSLTextProgram *m_pTextProgram;
|
||||
|
@ -110,7 +106,6 @@ protected:
|
|||
|
||||
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override;
|
||||
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override;
|
||||
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) override;
|
||||
void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand) override;
|
||||
void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) override;
|
||||
void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) override;
|
||||
|
|
|
@ -155,6 +155,7 @@ public:
|
|||
int m_LocColor;
|
||||
int m_LocOffset;
|
||||
int m_LocDir;
|
||||
int m_LocScale = -1;
|
||||
int m_LocNum;
|
||||
int m_LocJumpIndex;
|
||||
};
|
||||
|
|
|
@ -721,22 +721,17 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
|
|||
float m_aPos[4 * 2];
|
||||
};
|
||||
|
||||
struct SUniformTileGPosBorderLine : public SUniformTileGPos
|
||||
struct SUniformTileGPosBorder : public SUniformTileGPos
|
||||
{
|
||||
vec2 m_Dir;
|
||||
vec2 m_Offset;
|
||||
};
|
||||
|
||||
struct SUniformTileGPosBorder : public SUniformTileGPosBorderLine
|
||||
{
|
||||
int32_t m_JumpIndex;
|
||||
vec2 m_Scale;
|
||||
};
|
||||
|
||||
typedef ColorRGBA SUniformTileGVertColor;
|
||||
|
||||
struct SUniformTileGVertColorAlign
|
||||
{
|
||||
float m_aPad[(64 - 52) / 4];
|
||||
float m_aPad[(64 - 48) / 4];
|
||||
};
|
||||
|
||||
struct SUniformPrimExGPosRotationless
|
||||
|
@ -1011,7 +1006,6 @@ private:
|
|||
SPipelineContainer m_TextPipeline;
|
||||
SPipelineContainer m_TilePipeline;
|
||||
SPipelineContainer m_TileBorderPipeline;
|
||||
SPipelineContainer m_TileBorderLinePipeline;
|
||||
SPipelineContainer m_PrimExPipeline;
|
||||
SPipelineContainer m_PrimExRotationlessPipeline;
|
||||
SPipelineContainer m_SpriteMultiPipeline;
|
||||
|
@ -1274,7 +1268,6 @@ protected:
|
|||
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_TILE_LAYER)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderTileLayer_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderTileLayer *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderTileLayer(static_cast<const CCommandBuffer::SCommand_RenderTileLayer *>(pBaseCommand), ExecBuffer); }};
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_BORDER_TILE)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderBorderTile_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderBorderTile *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderBorderTile(static_cast<const CCommandBuffer::SCommand_RenderBorderTile *>(pBaseCommand), ExecBuffer); }};
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_BORDER_TILE_LINE)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderBorderTileLine_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderBorderTileLine *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderBorderTileLine(static_cast<const CCommandBuffer::SCommand_RenderBorderTileLine *>(pBaseCommand), ExecBuffer); }};
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_QUAD_LAYER)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderQuadLayer_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderQuadLayer *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderQuadLayer(static_cast<const CCommandBuffer::SCommand_RenderQuadLayer *>(pBaseCommand), ExecBuffer); }};
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_TEXT)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderText_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderText *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderText(static_cast<const CCommandBuffer::SCommand_RenderText *>(pBaseCommand), ExecBuffer); }};
|
||||
m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_RENDER_QUAD_CONTAINER)] = {true, [this](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) { Cmd_RenderQuadContainer_FillExecuteBuffer(ExecBuffer, static_cast<const CCommandBuffer::SCommand_RenderQuadContainer *>(pBaseCommand)); }, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_RenderQuadContainer(static_cast<const CCommandBuffer::SCommand_RenderQuadContainer *>(pBaseCommand), ExecBuffer); }};
|
||||
|
@ -2600,8 +2593,7 @@ protected:
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -2645,8 +2637,6 @@ protected:
|
|||
int ConvertWidth = Width;
|
||||
int ConvertHeight = Height;
|
||||
|
||||
if(!Is2DTextureSingleLayer)
|
||||
{
|
||||
if(ConvertWidth == 0 || (ConvertWidth % 16) != 0 || ConvertHeight == 0 || (ConvertHeight % 16) != 0)
|
||||
{
|
||||
dbg_msg("vulkan", "3D/2D array texture was resized");
|
||||
|
@ -2660,29 +2650,19 @@ protected:
|
|||
free(pData);
|
||||
pData = pNewTexData;
|
||||
}
|
||||
}
|
||||
|
||||
void *p3DTexData = pData;
|
||||
bool Needs3DTexDel = false;
|
||||
if(!Is2DTextureSingleLayer)
|
||||
{
|
||||
p3DTexData = malloc((size_t)PixelSize * ConvertWidth * ConvertHeight);
|
||||
void *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
|
||||
{
|
||||
Image3DWidth = ConvertWidth;
|
||||
Image3DHeight = ConvertHeight;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -3224,24 +3204,20 @@ protected:
|
|||
return GetPipeline(m_StandardPipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
}
|
||||
|
||||
VkPipelineLayout &GetTileLayerPipeLayout(int Type, bool IsTextured, size_t BlendModeIndex, size_t DynamicIndex)
|
||||
VkPipelineLayout &GetTileLayerPipeLayout(bool IsBorder, bool IsTextured, size_t BlendModeIndex, size_t DynamicIndex)
|
||||
{
|
||||
if(Type == 0)
|
||||
if(!IsBorder)
|
||||
return GetPipeLayout(m_TilePipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
else if(Type == 1)
|
||||
return GetPipeLayout(m_TileBorderPipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
else
|
||||
return GetPipeLayout(m_TileBorderLinePipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
return GetPipeLayout(m_TileBorderPipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
}
|
||||
|
||||
VkPipeline &GetTileLayerPipe(int Type, bool IsTextured, size_t BlendModeIndex, size_t DynamicIndex)
|
||||
VkPipeline &GetTileLayerPipe(bool IsBorder, bool IsTextured, size_t BlendModeIndex, size_t DynamicIndex)
|
||||
{
|
||||
if(Type == 0)
|
||||
if(!IsBorder)
|
||||
return GetPipeline(m_TilePipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
else if(Type == 1)
|
||||
return GetPipeline(m_TileBorderPipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
else
|
||||
return GetPipeline(m_TileBorderLinePipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
return GetPipeline(m_TileBorderPipeline, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
}
|
||||
|
||||
void GetStateIndices(const SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SState &State, bool &IsTextured, size_t &BlendModeIndex, size_t &DynamicIndex, size_t &AddressModeIndex)
|
||||
|
@ -3372,7 +3348,7 @@ protected:
|
|||
ExecBufferFillDynamicStates(State, ExecBuffer);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool RenderTileLayer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SState &State, int Type, const GL_SColorf &Color, const vec2 &Dir, const vec2 &Off, int32_t JumpIndex, size_t IndicesDrawNum, char *const *pIndicesOffsets, const unsigned int *pDrawCount, size_t InstanceCount)
|
||||
[[nodiscard]] bool RenderTileLayer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SState &State, bool IsBorder, const GL_SColorf &Color, const vec2 &Scale, const vec2 &Off, size_t IndicesDrawNum, char *const *pIndicesOffsets, const unsigned int *pDrawCount)
|
||||
{
|
||||
std::array<float, (size_t)4 * 2> m;
|
||||
GetStateMatrix(State, m);
|
||||
|
@ -3382,8 +3358,8 @@ protected:
|
|||
size_t DynamicIndex;
|
||||
size_t AddressModeIndex;
|
||||
GetStateIndices(ExecBuffer, State, IsTextured, BlendModeIndex, DynamicIndex, AddressModeIndex);
|
||||
auto &PipeLayout = GetTileLayerPipeLayout(Type, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
auto &PipeLine = GetTileLayerPipe(Type, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
auto &PipeLayout = GetTileLayerPipeLayout(IsBorder, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
auto &PipeLine = GetTileLayerPipe(IsBorder, IsTextured, BlendModeIndex, DynamicIndex);
|
||||
|
||||
VkCommandBuffer *pCommandBuffer;
|
||||
if(!GetGraphicCommandBuffer(pCommandBuffer, ExecBuffer.m_ThreadIndex))
|
||||
|
@ -3409,19 +3385,12 @@ protected:
|
|||
mem_copy(VertexPushConstants.m_aPos, m.data(), m.size() * sizeof(float));
|
||||
FragPushConstants = Color;
|
||||
|
||||
if(Type == 1)
|
||||
if(IsBorder)
|
||||
{
|
||||
VertexPushConstants.m_Dir = Dir;
|
||||
VertexPushConstants.m_Scale = Scale;
|
||||
VertexPushConstants.m_Offset = Off;
|
||||
VertexPushConstants.m_JumpIndex = JumpIndex;
|
||||
VertexPushConstantSize = sizeof(SUniformTileGPosBorder);
|
||||
}
|
||||
else if(Type == 2)
|
||||
{
|
||||
VertexPushConstants.m_Dir = Dir;
|
||||
VertexPushConstants.m_Offset = Off;
|
||||
VertexPushConstantSize = sizeof(SUniformTileGPosBorderLine);
|
||||
}
|
||||
|
||||
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, VertexPushConstantSize, &VertexPushConstants);
|
||||
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(SUniformTileGPosBorder) + sizeof(SUniformTileGVertColorAlign), FragPushConstantSize, &FragPushConstants);
|
||||
|
@ -3432,7 +3401,7 @@ protected:
|
|||
{
|
||||
VkDeviceSize IndexOffset = (VkDeviceSize)((ptrdiff_t)pIndicesOffsets[i] / sizeof(uint32_t));
|
||||
|
||||
vkCmdDrawIndexed(CommandBuffer, static_cast<uint32_t>(pDrawCount[i]), InstanceCount, IndexOffset, 0, 0);
|
||||
vkCmdDrawIndexed(CommandBuffer, static_cast<uint32_t>(pDrawCount[i]), 1, IndexOffset, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -4911,21 +4880,19 @@ public:
|
|||
}
|
||||
|
||||
template<bool HasSampler>
|
||||
[[nodiscard]] bool CreateTileGraphicsPipelineImpl(const char *pVertName, const char *pFragName, int Type, SPipelineContainer &PipeContainer, EVulkanBackendTextureModes TexMode, EVulkanBackendBlendModes BlendMode, EVulkanBackendClipModes DynamicMode)
|
||||
[[nodiscard]] bool CreateTileGraphicsPipelineImpl(const char *pVertName, const char *pFragName, bool IsBorder, SPipelineContainer &PipeContainer, EVulkanBackendTextureModes TexMode, EVulkanBackendBlendModes BlendMode, EVulkanBackendClipModes DynamicMode)
|
||||
{
|
||||
std::array<VkVertexInputAttributeDescription, HasSampler ? 2 : 1> 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<VkDescriptorSetLayout, 1> aSetLayouts;
|
||||
aSetLayouts[0] = m_Standard3DTexturedDescriptorSetLayout;
|
||||
|
||||
uint32_t VertPushConstantSize = sizeof(SUniformTileGPos);
|
||||
if(Type == 1)
|
||||
if(IsBorder)
|
||||
VertPushConstantSize = sizeof(SUniformTileGPosBorder);
|
||||
else if(Type == 2)
|
||||
VertPushConstantSize = sizeof(SUniformTileGPosBorderLine);
|
||||
|
||||
uint32_t FragPushConstantSize = sizeof(SUniformTileGVertColor);
|
||||
|
||||
|
@ -4933,11 +4900,11 @@ public:
|
|||
aPushConstants[0] = {VK_SHADER_STAGE_VERTEX_BIT, 0, VertPushConstantSize};
|
||||
aPushConstants[1] = {VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(SUniformTileGPosBorder) + sizeof(SUniformTileGVertColorAlign), FragPushConstantSize};
|
||||
|
||||
return CreateGraphicsPipeline<false>(pVertName, pFragName, PipeContainer, HasSampler ? (sizeof(float) * (2 + 3)) : (sizeof(float) * 2), aAttributeDescriptions, aSetLayouts, aPushConstants, TexMode, BlendMode, DynamicMode);
|
||||
return CreateGraphicsPipeline<false>(pVertName, pFragName, PipeContainer, HasSampler ? (sizeof(float) * 2 + sizeof(uint8_t) * 4) : (sizeof(float) * 2), aAttributeDescriptions, aSetLayouts, aPushConstants, TexMode, BlendMode, DynamicMode);
|
||||
}
|
||||
|
||||
template<bool HasSampler>
|
||||
[[nodiscard]] bool CreateTileGraphicsPipeline(const char *pVertName, const char *pFragName, int Type)
|
||||
[[nodiscard]] bool CreateTileGraphicsPipeline(const char *pVertName, const char *pFragName, bool IsBorder)
|
||||
{
|
||||
bool Ret = true;
|
||||
|
||||
|
@ -4947,7 +4914,7 @@ public:
|
|||
{
|
||||
for(size_t j = 0; j < VULKAN_BACKEND_CLIP_MODE_COUNT; ++j)
|
||||
{
|
||||
Ret &= CreateTileGraphicsPipelineImpl<HasSampler>(pVertName, pFragName, Type, Type == 0 ? m_TilePipeline : (Type == 1 ? m_TileBorderPipeline : m_TileBorderLinePipeline), TexMode, EVulkanBackendBlendModes(i), EVulkanBackendClipModes(j));
|
||||
Ret &= CreateTileGraphicsPipelineImpl<HasSampler>(pVertName, pFragName, IsBorder, !IsBorder ? m_TilePipeline : m_TileBorderPipeline, TexMode, EVulkanBackendBlendModes(i), EVulkanBackendClipModes(j));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5429,7 +5396,6 @@ public:
|
|||
m_TextPipeline.Destroy(m_VKDevice);
|
||||
m_TilePipeline.Destroy(m_VKDevice);
|
||||
m_TileBorderPipeline.Destroy(m_VKDevice);
|
||||
m_TileBorderLinePipeline.Destroy(m_VKDevice);
|
||||
m_PrimExPipeline.Destroy(m_VKDevice);
|
||||
m_PrimExRotationlessPipeline.Destroy(m_VKDevice);
|
||||
m_SpriteMultiPipeline.Destroy(m_VKDevice);
|
||||
|
@ -6086,22 +6052,16 @@ public:
|
|||
if(!CreateTextGraphicsPipeline("shader/vulkan/text.vert.spv", "shader/vulkan/text.frag.spv"))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<false>("shader/vulkan/tile.vert.spv", "shader/vulkan/tile.frag.spv", 0))
|
||||
if(!CreateTileGraphicsPipeline<false>("shader/vulkan/tile.vert.spv", "shader/vulkan/tile.frag.spv", false))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<true>("shader/vulkan/tile_textured.vert.spv", "shader/vulkan/tile_textured.frag.spv", 0))
|
||||
if(!CreateTileGraphicsPipeline<true>("shader/vulkan/tile_textured.vert.spv", "shader/vulkan/tile_textured.frag.spv", false))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<false>("shader/vulkan/tile_border.vert.spv", "shader/vulkan/tile_border.frag.spv", 1))
|
||||
if(!CreateTileGraphicsPipeline<false>("shader/vulkan/tile_border.vert.spv", "shader/vulkan/tile_border.frag.spv", true))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<true>("shader/vulkan/tile_border_textured.vert.spv", "shader/vulkan/tile_border_textured.frag.spv", 1))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<false>("shader/vulkan/tile_border_line.vert.spv", "shader/vulkan/tile_border_line.frag.spv", 2))
|
||||
return -1;
|
||||
|
||||
if(!CreateTileGraphicsPipeline<true>("shader/vulkan/tile_border_line_textured.vert.spv", "shader/vulkan/tile_border_line_textured.frag.spv", 2))
|
||||
if(!CreateTileGraphicsPipeline<true>("shader/vulkan/tile_border_textured.vert.spv", "shader/vulkan/tile_border_textured.frag.spv", true))
|
||||
return -1;
|
||||
|
||||
if(!CreatePrimExGraphicsPipeline("shader/vulkan/primex_rotationless.vert.spv", "shader/vulkan/primex_rotationless.frag.spv", false, true))
|
||||
|
@ -7076,11 +7036,9 @@ public:
|
|||
|
||||
[[nodiscard]] bool Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand, SRenderCommandExecuteBuffer &ExecBuffer)
|
||||
{
|
||||
int Type = 0;
|
||||
vec2 Dir{};
|
||||
vec2 Scale{};
|
||||
vec2 Off{};
|
||||
int32_t JumpIndex = 0;
|
||||
return RenderTileLayer(ExecBuffer, pCommand->m_State, Type, pCommand->m_Color, Dir, Off, JumpIndex, (size_t)pCommand->m_IndicesDrawNum, pCommand->m_pIndicesOffsets, pCommand->m_pDrawCount, 1);
|
||||
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)
|
||||
|
@ -7090,24 +7048,10 @@ public:
|
|||
|
||||
[[nodiscard]] bool Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand, SRenderCommandExecuteBuffer &ExecBuffer)
|
||||
{
|
||||
int Type = 1;
|
||||
vec2 Dir = pCommand->m_Dir;
|
||||
vec2 Scale = pCommand->m_Scale;
|
||||
vec2 Off = pCommand->m_Offset;
|
||||
unsigned int DrawNum = 6;
|
||||
return RenderTileLayer(ExecBuffer, pCommand->m_State, Type, pCommand->m_Color, Dir, Off, pCommand->m_JumpIndex, (size_t)1, &pCommand->m_pIndicesOffset, &DrawNum, pCommand->m_DrawNum);
|
||||
}
|
||||
|
||||
void Cmd_RenderBorderTileLine_FillExecuteBuffer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand)
|
||||
{
|
||||
RenderTileLayer_FillExecuteBuffer(ExecBuffer, 1, pCommand->m_State, pCommand->m_BufferContainerIndex);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand, SRenderCommandExecuteBuffer &ExecBuffer)
|
||||
{
|
||||
int Type = 2;
|
||||
vec2 Dir = pCommand->m_Dir;
|
||||
vec2 Off = pCommand->m_Offset;
|
||||
return RenderTileLayer(ExecBuffer, pCommand->m_State, Type, pCommand->m_Color, Dir, Off, 0, (size_t)1, &pCommand->m_pIndicesOffset, &pCommand->m_IndexDrawNum, pCommand->m_DrawNum);
|
||||
unsigned int DrawNum = pCommand->m_DrawNum * 6;
|
||||
return RenderTileLayer(ExecBuffer, pCommand->m_State, true, pCommand->m_Color, Scale, Off, 1, &pCommand->m_pIndicesOffset, &DrawNum);
|
||||
}
|
||||
|
||||
void Cmd_RenderQuadLayer_FillExecuteBuffer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_RenderQuadLayer *pCommand)
|
||||
|
|
|
@ -281,7 +281,8 @@ public:
|
|||
bool HasQuadBuffering() override { return m_Capabilites.m_QuadBuffering; }
|
||||
bool HasTextBuffering() override { return m_Capabilites.m_TextBuffering; }
|
||||
bool HasQuadContainerBuffering() override { return m_Capabilites.m_QuadContainerBuffering; }
|
||||
bool Has2DTextureArrays() override { return m_Capabilites.m_2DArrayTextures; }
|
||||
bool Uses2DTextureArrays() override { return m_Capabilites.m_2DArrayTextures; }
|
||||
bool HasTextureArraysSupport() override { return m_Capabilites.m_2DArrayTextures || m_Capabilites.m_3DTextures; }
|
||||
|
||||
const char *GetErrorString() override
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -1094,7 +1090,7 @@ void CGraphics_Threaded::QuadsTex3DDrawTL(const CQuadItem *pArray, int Num)
|
|||
{
|
||||
for(int n = 0; n < VertNum; ++n)
|
||||
{
|
||||
if(HasTextureArrays())
|
||||
if(Uses2DTextureArrays())
|
||||
m_aVerticesTex3D[CurNumVert + VertNum * i + n].m_Tex.w = (float)m_CurIndex;
|
||||
else
|
||||
m_aVerticesTex3D[CurNumVert + VertNum * i + n].m_Tex.w = ((float)m_CurIndex + 0.5f) / 256.f;
|
||||
|
@ -1564,7 +1560,7 @@ void CGraphics_Threaded::RenderTileLayer(int BufferContainerIndex, const ColorRG
|
|||
// todo max indices group check!!
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, int JumpIndex, unsigned int DrawNum)
|
||||
void CGraphics_Threaded::RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum)
|
||||
{
|
||||
if(DrawNum == 0)
|
||||
return;
|
||||
|
@ -1576,32 +1572,9 @@ void CGraphics_Threaded::RenderBorderTiles(int BufferContainerIndex, const Color
|
|||
Cmd.m_Color = Color;
|
||||
|
||||
Cmd.m_pIndicesOffset = pIndexBufferOffset;
|
||||
Cmd.m_JumpIndex = JumpIndex;
|
||||
|
||||
Cmd.m_Offset = Offset;
|
||||
Cmd.m_Dir = Dir;
|
||||
|
||||
AddCmd(Cmd);
|
||||
|
||||
m_pCommandBuffer->AddRenderCalls(1);
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::RenderBorderTileLines(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, unsigned int IndexDrawNum, unsigned int RedrawNum)
|
||||
{
|
||||
if(IndexDrawNum == 0 || RedrawNum == 0)
|
||||
return;
|
||||
// Draw a border tile a lot of times
|
||||
CCommandBuffer::SCommand_RenderBorderTileLine Cmd;
|
||||
Cmd.m_State = m_State;
|
||||
Cmd.m_IndexDrawNum = IndexDrawNum;
|
||||
Cmd.m_DrawNum = RedrawNum;
|
||||
Cmd.m_BufferContainerIndex = BufferContainerIndex;
|
||||
Cmd.m_Color = Color;
|
||||
|
||||
Cmd.m_pIndicesOffset = pIndexBufferOffset;
|
||||
|
||||
Cmd.m_Offset = Offset;
|
||||
Cmd.m_Dir = Dir;
|
||||
Cmd.m_Scale = Scale;
|
||||
|
||||
AddCmd(Cmd);
|
||||
|
||||
|
@ -2396,7 +2369,8 @@ int CGraphics_Threaded::IssueInit()
|
|||
m_GLQuadBufferingEnabled = m_pBackend->HasQuadBuffering();
|
||||
m_GLQuadContainerBufferingEnabled = m_pBackend->HasQuadContainerBuffering();
|
||||
m_GLTextBufferingEnabled = (m_GLQuadContainerBufferingEnabled && m_pBackend->HasTextBuffering());
|
||||
m_GLHasTextureArrays = m_pBackend->Has2DTextureArrays();
|
||||
m_GLUses2DTextureArrays = m_pBackend->Uses2DTextureArrays();
|
||||
m_GLHasTextureArraysSupport = m_pBackend->HasTextureArraysSupport();
|
||||
m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth;
|
||||
m_ScreenRefreshRate = g_Config.m_GfxScreenRefreshRate;
|
||||
}
|
||||
|
@ -2630,7 +2604,7 @@ int CGraphics_Threaded::Init()
|
|||
mem_copy(&aNullTextureData[(y * NullTextureDimension + x) * PixelSize], pColor, PixelSize);
|
||||
}
|
||||
}
|
||||
const int TextureLoadFlags = HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
const int TextureLoadFlags = Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
m_NullTexture.Invalidate();
|
||||
m_NullTexture = LoadTextureRaw(NullTextureDimension, NullTextureDimension, CImageInfo::FORMAT_RGBA, aNullTextureData, TextureLoadFlags);
|
||||
dbg_assert(m_NullTexture.IsNullTexture(), "Null texture invalid");
|
||||
|
|
|
@ -117,7 +117,6 @@ public:
|
|||
|
||||
CMD_RENDER_TILE_LAYER, // render a tilelayer
|
||||
CMD_RENDER_BORDER_TILE, // render one tile multiple times
|
||||
CMD_RENDER_BORDER_TILE_LINE, // render an amount of tiles multiple times
|
||||
CMD_RENDER_QUAD_LAYER, // render a quad layer
|
||||
CMD_RENDER_TEXT, // render text
|
||||
CMD_RENDER_QUAD_CONTAINER, // render a quad buffer container
|
||||
|
@ -148,9 +147,7 @@ public:
|
|||
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
|
||||
|
@ -380,28 +377,12 @@ public:
|
|||
SCommand(CMD_RENDER_BORDER_TILE) {}
|
||||
SState m_State;
|
||||
SColorf m_Color; // the color of the whole tilelayer -- already enveloped
|
||||
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
|
||||
unsigned int m_DrawNum;
|
||||
char *m_pIndicesOffset;
|
||||
uint32_t m_DrawNum;
|
||||
int m_BufferContainerIndex;
|
||||
|
||||
vec2 m_Offset;
|
||||
vec2 m_Dir;
|
||||
int m_JumpIndex;
|
||||
};
|
||||
|
||||
struct SCommand_RenderBorderTileLine : public SCommand
|
||||
{
|
||||
SCommand_RenderBorderTileLine() :
|
||||
SCommand(CMD_RENDER_BORDER_TILE_LINE) {}
|
||||
SState m_State;
|
||||
SColorf m_Color; // the color of the whole tilelayer -- already enveloped
|
||||
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
|
||||
unsigned int m_IndexDrawNum;
|
||||
unsigned int m_DrawNum;
|
||||
int m_BufferContainerIndex;
|
||||
|
||||
vec2 m_Offset;
|
||||
vec2 m_Dir;
|
||||
vec2 m_Scale;
|
||||
};
|
||||
|
||||
struct SCommand_RenderQuadLayer : public SCommand
|
||||
|
@ -755,7 +736,8 @@ public:
|
|||
virtual bool HasQuadBuffering() { return false; }
|
||||
virtual bool HasTextBuffering() { return false; }
|
||||
virtual bool HasQuadContainerBuffering() { return false; }
|
||||
virtual bool Has2DTextureArrays() { return false; }
|
||||
virtual bool Uses2DTextureArrays() { return false; }
|
||||
virtual bool HasTextureArraysSupport() { return false; }
|
||||
virtual const char *GetErrorString() { return NULL; }
|
||||
|
||||
virtual const char *GetVendorString() = 0;
|
||||
|
@ -788,7 +770,8 @@ class CGraphics_Threaded : public IEngineGraphics
|
|||
bool m_GLQuadBufferingEnabled;
|
||||
bool m_GLTextBufferingEnabled;
|
||||
bool m_GLQuadContainerBufferingEnabled;
|
||||
bool m_GLHasTextureArrays;
|
||||
bool m_GLUses2DTextureArrays;
|
||||
bool m_GLHasTextureArraysSupport;
|
||||
bool m_GLUseTrianglesAsQuad;
|
||||
|
||||
CCommandBuffer *m_apCommandBuffers[NUM_CMDBUFFERS];
|
||||
|
@ -1214,8 +1197,7 @@ public:
|
|||
void FlushVerticesTex3D() override;
|
||||
|
||||
void RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset) override;
|
||||
void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, int JumpIndex, unsigned int DrawNum) override;
|
||||
void RenderBorderTileLines(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, unsigned int IndexDrawNum, unsigned int RedrawNum) override;
|
||||
virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum) override;
|
||||
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset) override;
|
||||
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) override;
|
||||
|
||||
|
@ -1286,7 +1268,8 @@ public:
|
|||
bool IsQuadBufferingEnabled() override { return m_GLQuadBufferingEnabled; }
|
||||
bool IsTextBufferingEnabled() override { return m_GLTextBufferingEnabled; }
|
||||
bool IsQuadContainerBufferingEnabled() override { return m_GLQuadContainerBufferingEnabled; }
|
||||
bool HasTextureArrays() override { return m_GLHasTextureArrays; }
|
||||
bool Uses2DTextureArrays() override { return m_GLUses2DTextureArrays; }
|
||||
bool HasTextureArraysSupport() override { return m_GLHasTextureArraysSupport; }
|
||||
|
||||
const char *GetVendorString() override;
|
||||
const char *GetVersionString() override;
|
||||
|
|
|
@ -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 @@ public:
|
|||
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
|
||||
|
@ -357,8 +355,7 @@ public:
|
|||
|
||||
// specific render functions
|
||||
virtual void RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset) = 0;
|
||||
virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, int JumpIndex, unsigned int DrawNum) = 0;
|
||||
virtual void RenderBorderTileLines(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Dir, unsigned int IndexDrawNum, unsigned int RedrawNum) = 0;
|
||||
virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum) = 0;
|
||||
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset) = 0;
|
||||
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) = 0;
|
||||
|
||||
|
@ -387,7 +384,8 @@ public:
|
|||
virtual bool IsQuadBufferingEnabled() = 0;
|
||||
virtual bool IsTextBufferingEnabled() = 0;
|
||||
virtual bool IsQuadContainerBufferingEnabled() = 0;
|
||||
virtual bool HasTextureArrays() = 0;
|
||||
virtual bool Uses2DTextureArrays() = 0;
|
||||
virtual bool HasTextureArraysSupport() = 0;
|
||||
|
||||
virtual const char *GetVendorString() = 0;
|
||||
virtual const char *GetVersionString() = 0;
|
||||
|
|
|
@ -101,13 +101,13 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
|
|||
}
|
||||
}
|
||||
|
||||
const int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
const int TextureLoadFlag = Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
|
||||
// load new textures
|
||||
bool ShowWarning = false;
|
||||
for(int i = 0; i < m_Count; i++)
|
||||
{
|
||||
const int LoadFlag = (((m_aTextureUsedByTileOrQuadLayerFlag[i] & 1) != 0) ? TextureLoadFlag : 0) | (((m_aTextureUsedByTileOrQuadLayerFlag[i] & 2) != 0) ? 0 : (Graphics()->IsTileBufferingEnabled() ? IGraphics::TEXLOAD_NO_2D_TEXTURE : 0));
|
||||
const int LoadFlag = (((m_aTextureUsedByTileOrQuadLayerFlag[i] & 1) != 0) ? TextureLoadFlag : 0) | (((m_aTextureUsedByTileOrQuadLayerFlag[i] & 2) != 0) ? 0 : (Graphics()->HasTextureArraysSupport() ? IGraphics::TEXLOAD_NO_2D_TEXTURE : 0));
|
||||
const CMapItemImage_v2 *pImg = (CMapItemImage_v2 *)pMap->GetItem(Start + i);
|
||||
const CImageInfo::EImageFormat Format = pImg->m_Version < CMapItemImage_v2::CURRENT_VERSION ? CImageInfo::FORMAT_RGBA : CImageInfo::ImageFormatFromInt(pImg->m_Format);
|
||||
|
||||
|
@ -220,8 +220,8 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
|
|||
bool GameTypeHasTuneLayer = HasTuneLayer(EntitiesModType) || WasUnknown;
|
||||
|
||||
int TextureLoadFlag = 0;
|
||||
if(Graphics()->IsTileBufferingEnabled())
|
||||
TextureLoadFlag = (Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
||||
|
||||
CImageInfo ImgInfo;
|
||||
bool ImagePNGLoaded = false;
|
||||
|
@ -356,8 +356,8 @@ IGraphics::CTextureHandle CMapImages::GetSpeedupArrow()
|
|||
{
|
||||
if(!m_SpeedupArrowIsLoaded)
|
||||
{
|
||||
int TextureLoadFlag = (Graphics()->HasTextureArrays() ? 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;
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ IGraphics::CTextureHandle CMapImages::UploadEntityLayerText(int TextureSize, int
|
|||
UpdateEntityLayerText(pMem, PixelSize, Width, Height, TextureSize, MaxWidth, YOffset, 1);
|
||||
UpdateEntityLayerText(pMem, PixelSize, Width, Height, TextureSize, MaxWidth, YOffset, 2, 255);
|
||||
|
||||
const int TextureLoadFlag = (Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
||||
const int TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
||||
IGraphics::CTextureHandle Texture = Graphics()->LoadTextureRaw(Width, Height, CImageInfo::FORMAT_RGBA, pMem, TextureLoadFlag);
|
||||
free(pMem);
|
||||
|
||||
|
|
|
@ -143,77 +143,7 @@ void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels
|
|||
}
|
||||
}
|
||||
|
||||
void FillTmpTileSpeedup(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, int Scale, CMapItemGroup *pGroup, short AngleRotate)
|
||||
{
|
||||
if(pTmpTex)
|
||||
{
|
||||
unsigned char x0 = 0;
|
||||
unsigned char y0 = 0;
|
||||
unsigned char x1 = x0 + 1;
|
||||
unsigned char y1 = y0;
|
||||
unsigned char x2 = x0 + 1;
|
||||
unsigned char y2 = y0 + 1;
|
||||
unsigned char x3 = x0;
|
||||
unsigned char y3 = y0 + 1;
|
||||
|
||||
pTmpTex->m_TexCoordTopLeft.x = x0;
|
||||
pTmpTex->m_TexCoordTopLeft.y = y0;
|
||||
pTmpTex->m_TexCoordBottomLeft.x = x3;
|
||||
pTmpTex->m_TexCoordBottomLeft.y = y3;
|
||||
pTmpTex->m_TexCoordTopRight.x = x1;
|
||||
pTmpTex->m_TexCoordTopRight.y = y1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//same as in rotate from Graphics()
|
||||
float Angle = (float)AngleRotate * (pi / 180.0f);
|
||||
float c = std::cos(Angle);
|
||||
float s = std::sin(Angle);
|
||||
float xR, yR;
|
||||
int i;
|
||||
|
||||
int ScaleSmaller = 2;
|
||||
pTmpTile->m_TopLeft.x = x * Scale + ScaleSmaller;
|
||||
pTmpTile->m_TopLeft.y = y * Scale + ScaleSmaller;
|
||||
pTmpTile->m_BottomLeft.x = x * Scale + ScaleSmaller;
|
||||
pTmpTile->m_BottomLeft.y = y * Scale + Scale - ScaleSmaller;
|
||||
pTmpTile->m_TopRight.x = x * Scale + Scale - ScaleSmaller;
|
||||
pTmpTile->m_TopRight.y = y * Scale + ScaleSmaller;
|
||||
pTmpTile->m_BottomRight.x = x * Scale + Scale - ScaleSmaller;
|
||||
pTmpTile->m_BottomRight.y = y * Scale + Scale - ScaleSmaller;
|
||||
|
||||
float *pTmpTileVertices = (float *)pTmpTile;
|
||||
|
||||
vec2 Center;
|
||||
Center.x = pTmpTile->m_TopLeft.x + (Scale - ScaleSmaller) / 2.f;
|
||||
Center.y = pTmpTile->m_TopLeft.y + (Scale - ScaleSmaller) / 2.f;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
xR = pTmpTileVertices[i * 2] - Center.x;
|
||||
yR = pTmpTileVertices[i * 2 + 1] - Center.y;
|
||||
pTmpTileVertices[i * 2] = xR * c - yR * s + Center.x;
|
||||
pTmpTileVertices[i * 2 + 1] = xR * s + yR * c + Center.y;
|
||||
}
|
||||
}
|
||||
|
||||
void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, 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)
|
||||
{
|
||||
|
@ -265,30 +195,32 @@ 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;
|
||||
}
|
||||
|
||||
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;
|
||||
pTmpTile->m_TopLeft.y = y * Scale;
|
||||
pTmpTile->m_BottomLeft.x = x * Scale;
|
||||
pTmpTile->m_BottomLeft.y = y * Scale + Scale;
|
||||
pTmpTile->m_TopRight.x = x * Scale + Scale;
|
||||
pTmpTile->m_TopRight.y = y * Scale;
|
||||
pTmpTile->m_BottomRight.x = x * Scale + Scale;
|
||||
pTmpTile->m_BottomRight.y = y * Scale + Scale;
|
||||
pTmpTile->m_TopLeft.x = x * Scale + Offset.x;
|
||||
pTmpTile->m_TopLeft.y = y * Scale + Offset.y;
|
||||
pTmpTile->m_BottomLeft.x = x * Scale + Offset.x;
|
||||
pTmpTile->m_BottomLeft.y = y * Scale + Scale + Offset.y;
|
||||
pTmpTile->m_TopRight.x = x * Scale + Scale + Offset.x;
|
||||
pTmpTile->m_TopRight.y = y * Scale + Offset.y;
|
||||
pTmpTile->m_BottomRight.x = x * Scale + Scale + Offset.x;
|
||||
pTmpTile->m_BottomRight.y = y * Scale + Scale + Offset.y;
|
||||
}
|
||||
|
||||
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, 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)
|
||||
|
@ -303,35 +235,22 @@ bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height
|
|||
|
||||
m_pTilesOfLayer = new CMapLayers::STileLayerVisuals::STileVisual[Height * Width];
|
||||
|
||||
if(Width > 2)
|
||||
{
|
||||
m_pBorderTop = new CMapLayers::STileLayerVisuals::STileVisual[Width - 2];
|
||||
m_pBorderBottom = new CMapLayers::STileLayerVisuals::STileVisual[Width - 2];
|
||||
}
|
||||
if(Height > 2)
|
||||
{
|
||||
m_pBorderLeft = new CMapLayers::STileLayerVisuals::STileVisual[Height - 2];
|
||||
m_pBorderRight = new CMapLayers::STileLayerVisuals::STileVisual[Height - 2];
|
||||
}
|
||||
m_vBorderTop.resize(Width);
|
||||
m_vBorderBottom.resize(Width);
|
||||
|
||||
m_vBorderLeft.resize(Height);
|
||||
m_vBorderRight.resize(Height);
|
||||
return true;
|
||||
}
|
||||
|
||||
CMapLayers::STileLayerVisuals::~STileLayerVisuals()
|
||||
{
|
||||
delete[] m_pTilesOfLayer;
|
||||
delete[] m_pBorderTop;
|
||||
delete[] m_pBorderBottom;
|
||||
delete[] m_pBorderLeft;
|
||||
delete[] m_pBorderRight;
|
||||
|
||||
m_pTilesOfLayer = NULL;
|
||||
m_pBorderTop = NULL;
|
||||
m_pBorderBottom = NULL;
|
||||
m_pBorderLeft = NULL;
|
||||
m_pBorderRight = NULL;
|
||||
}
|
||||
|
||||
bool AddTile(std::vector<SGraphicTile> &vTmpTiles, std::vector<SGraphicTileTexureCoords> &vTmpTileTexCoords, bool As3DTextureCoord, unsigned char Index, unsigned char Flags, int x, int y, CMapItemGroup *pGroup, bool DoTextureCoords, bool FillSpeedup = false, int AngleRotate = -1)
|
||||
bool AddTile(std::vector<SGraphicTile> &vTmpTiles, std::vector<SGraphicTileTexureCoords> &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)
|
||||
{
|
||||
|
@ -345,9 +264,9 @@ bool AddTile(std::vector<SGraphicTile> &vTmpTiles, std::vector<SGraphicTileTexur
|
|||
pTileTex = &TileTex;
|
||||
}
|
||||
if(FillSpeedup)
|
||||
FillTmpTileSpeedup(&Tile, pTileTex, As3DTextureCoord, Flags, 0, x, y, 32.f, pGroup, AngleRotate);
|
||||
FillTmpTileSpeedup(&Tile, pTileTex, Flags, 0, x, y, Offset, Scale, pGroup, AngleRotate);
|
||||
else
|
||||
FillTmpTile(&Tile, pTileTex, As3DTextureCoord, Flags, Index, x, y, 32.f, pGroup);
|
||||
FillTmpTile(&Tile, pTileTex, Flags, Index, x, y, Offset, Scale, pGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -466,8 +385,6 @@ void CMapLayers::OnMapLoad()
|
|||
std::vector<STmpQuad> vtmpQuads;
|
||||
std::vector<STmpQuadTextured> vtmpQuadsTextured;
|
||||
|
||||
bool As3DTextureCoords = !Graphics()->HasTextureArrays();
|
||||
|
||||
for(int g = 0; g < m_pLayers->NumGroups(); g++)
|
||||
{
|
||||
CMapItemGroup *pGroup = m_pLayers->GetGroup(g);
|
||||
|
@ -696,13 +613,13 @@ void CMapLayers::OnMapLoad()
|
|||
|
||||
//the amount of tiles handled before this tile
|
||||
int TilesHandledCount = vtmpTiles.size();
|
||||
Visuals.m_pTilesOfLayer[y * pTMap->m_Width + x].SetIndexBufferByteOffset((offset_ptr32)(TilesHandledCount * 6 * sizeof(unsigned int)));
|
||||
Visuals.m_pTilesOfLayer[y * pTMap->m_Width + x].SetIndexBufferByteOffset((offset_ptr32)(TilesHandledCount));
|
||||
|
||||
bool AddAsSpeedup = false;
|
||||
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
|
||||
|
@ -710,61 +627,49 @@ void CMapLayers::OnMapLoad()
|
|||
{
|
||||
if(y == 0)
|
||||
{
|
||||
Visuals.m_BorderTopLeft.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderTopLeft.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size()));
|
||||
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() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderBottomLeft.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size()));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{-32, 0}))
|
||||
Visuals.m_BorderBottomLeft.Draw(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Visuals.m_pBorderLeft[y - 1].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderLeftTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderLeftTiles, vtmpBorderLeftTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_pBorderLeft[y - 1].Draw(true);
|
||||
}
|
||||
Visuals.m_vBorderLeft[y].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderLeftTiles.size()));
|
||||
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)
|
||||
{
|
||||
if(y == 0)
|
||||
{
|
||||
Visuals.m_BorderTopRight.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderTopRight.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size()));
|
||||
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() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderBottomRight.SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderCorners.size()));
|
||||
if(AddTile(vtmpBorderCorners, vtmpBorderCornersTexCoords, Index, Flags, 0, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0}))
|
||||
Visuals.m_BorderBottomRight.Draw(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Visuals.m_pBorderRight[y - 1].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderRightTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderRightTiles, vtmpBorderRightTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_pBorderRight[y - 1].Draw(true);
|
||||
Visuals.m_vBorderRight[y].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderRightTiles.size()));
|
||||
if(AddTile(vtmpBorderRightTiles, vtmpBorderRightTilesTexCoords, Index, Flags, 0, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0}))
|
||||
Visuals.m_vBorderRight[y].Draw(true);
|
||||
}
|
||||
}
|
||||
else if(y == 0)
|
||||
if(y == 0)
|
||||
{
|
||||
if(x > 0 && x < pTMap->m_Width - 1)
|
||||
{
|
||||
Visuals.m_pBorderTop[x - 1].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderTopTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderTopTiles, vtmpBorderTopTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_pBorderTop[x - 1].Draw(true);
|
||||
}
|
||||
Visuals.m_vBorderTop[x].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderTopTiles.size()));
|
||||
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)
|
||||
{
|
||||
if(x > 0 && x < pTMap->m_Width - 1)
|
||||
{
|
||||
Visuals.m_pBorderBottom[x - 1].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderBottomTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpBorderBottomTiles, vtmpBorderBottomTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_pBorderBottom[x - 1].Draw(true);
|
||||
}
|
||||
Visuals.m_vBorderBottom[x].SetIndexBufferByteOffset((offset_ptr32)(vtmpBorderBottomTiles.size()));
|
||||
if(AddTile(vtmpBorderBottomTiles, vtmpBorderBottomTilesTexCoords, Index, Flags, x, 0, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate, ivec2{0, 0}))
|
||||
Visuals.m_vBorderBottom[x].Draw(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -772,61 +677,61 @@ void CMapLayers::OnMapLoad()
|
|||
//append one kill tile to the gamelayer
|
||||
if(IsGameLayer)
|
||||
{
|
||||
Visuals.m_BorderKillTile.SetIndexBufferByteOffset((offset_ptr32)(vtmpTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(vtmpTiles, vtmpTileTexCoords, As3DTextureCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords))
|
||||
Visuals.m_BorderKillTile.SetIndexBufferByteOffset((offset_ptr32)(vtmpTiles.size()));
|
||||
if(AddTile(vtmpTiles, vtmpTileTexCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords))
|
||||
Visuals.m_BorderKillTile.Draw(true);
|
||||
}
|
||||
|
||||
//add the border corners, then the borders and fix their byte offsets
|
||||
int TilesHandledCount = vtmpTiles.size();
|
||||
Visuals.m_BorderTopLeft.AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_BorderTopRight.AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_BorderBottomLeft.AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_BorderBottomRight.AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_BorderTopLeft.AddIndexBufferByteOffset(TilesHandledCount);
|
||||
Visuals.m_BorderTopRight.AddIndexBufferByteOffset(TilesHandledCount);
|
||||
Visuals.m_BorderBottomLeft.AddIndexBufferByteOffset(TilesHandledCount);
|
||||
Visuals.m_BorderBottomRight.AddIndexBufferByteOffset(TilesHandledCount);
|
||||
//add the Corners to the tiles
|
||||
vtmpTiles.insert(vtmpTiles.end(), vtmpBorderCorners.begin(), vtmpBorderCorners.end());
|
||||
vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderCornersTexCoords.begin(), vtmpBorderCornersTexCoords.end());
|
||||
|
||||
//now the borders
|
||||
TilesHandledCount = vtmpTiles.size();
|
||||
if(pTMap->m_Width > 2)
|
||||
if(pTMap->m_Width > 0)
|
||||
{
|
||||
for(int i = 0; i < pTMap->m_Width - 2; ++i)
|
||||
for(int i = 0; i < pTMap->m_Width; ++i)
|
||||
{
|
||||
Visuals.m_pBorderTop[i].AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_vBorderTop[i].AddIndexBufferByteOffset(TilesHandledCount);
|
||||
}
|
||||
}
|
||||
vtmpTiles.insert(vtmpTiles.end(), vtmpBorderTopTiles.begin(), vtmpBorderTopTiles.end());
|
||||
vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderTopTilesTexCoords.begin(), vtmpBorderTopTilesTexCoords.end());
|
||||
|
||||
TilesHandledCount = vtmpTiles.size();
|
||||
if(pTMap->m_Width > 2)
|
||||
if(pTMap->m_Width > 0)
|
||||
{
|
||||
for(int i = 0; i < pTMap->m_Width - 2; ++i)
|
||||
for(int i = 0; i < pTMap->m_Width; ++i)
|
||||
{
|
||||
Visuals.m_pBorderBottom[i].AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_vBorderBottom[i].AddIndexBufferByteOffset(TilesHandledCount);
|
||||
}
|
||||
}
|
||||
vtmpTiles.insert(vtmpTiles.end(), vtmpBorderBottomTiles.begin(), vtmpBorderBottomTiles.end());
|
||||
vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderBottomTilesTexCoords.begin(), vtmpBorderBottomTilesTexCoords.end());
|
||||
|
||||
TilesHandledCount = vtmpTiles.size();
|
||||
if(pTMap->m_Height > 2)
|
||||
if(pTMap->m_Height > 0)
|
||||
{
|
||||
for(int i = 0; i < pTMap->m_Height - 2; ++i)
|
||||
for(int i = 0; i < pTMap->m_Height; ++i)
|
||||
{
|
||||
Visuals.m_pBorderLeft[i].AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_vBorderLeft[i].AddIndexBufferByteOffset(TilesHandledCount);
|
||||
}
|
||||
}
|
||||
vtmpTiles.insert(vtmpTiles.end(), vtmpBorderLeftTiles.begin(), vtmpBorderLeftTiles.end());
|
||||
vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderLeftTilesTexCoords.begin(), vtmpBorderLeftTilesTexCoords.end());
|
||||
|
||||
TilesHandledCount = vtmpTiles.size();
|
||||
if(pTMap->m_Height > 2)
|
||||
if(pTMap->m_Height > 0)
|
||||
{
|
||||
for(int i = 0; i < pTMap->m_Height - 2; ++i)
|
||||
for(int i = 0; i < pTMap->m_Height; ++i)
|
||||
{
|
||||
Visuals.m_pBorderRight[i].AddIndexBufferByteOffset(TilesHandledCount * 6 * sizeof(unsigned int));
|
||||
Visuals.m_vBorderRight[i].AddIndexBufferByteOffset(TilesHandledCount);
|
||||
}
|
||||
}
|
||||
vtmpTiles.insert(vtmpTiles.end(), vtmpBorderRightTiles.begin(), vtmpBorderRightTiles.end());
|
||||
|
@ -842,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
|
||||
|
@ -853,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();
|
||||
|
@ -866,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);
|
||||
|
@ -1014,36 +919,36 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
|
|||
int BorderX0, BorderY0, BorderX1, BorderY1;
|
||||
bool DrawBorder = false;
|
||||
|
||||
int Y0 = BorderY0 = std::floor((ScreenY0) / 32);
|
||||
int X0 = BorderX0 = std::floor((ScreenX0) / 32);
|
||||
int Y1 = BorderY1 = std::floor((ScreenY1) / 32);
|
||||
int X1 = BorderX1 = std::floor((ScreenX1) / 32);
|
||||
int Y0 = BorderY0 = std::floor(ScreenY0 / 32);
|
||||
int X0 = BorderX0 = std::floor(ScreenX0 / 32);
|
||||
int Y1 = BorderY1 = std::ceil(ScreenY1 / 32);
|
||||
int X1 = BorderX1 = std::ceil(ScreenX1 / 32);
|
||||
|
||||
if(X0 <= 0)
|
||||
if(X0 < 0)
|
||||
{
|
||||
X0 = 0;
|
||||
DrawBorder = true;
|
||||
}
|
||||
if(Y0 <= 0)
|
||||
if(Y0 < 0)
|
||||
{
|
||||
Y0 = 0;
|
||||
DrawBorder = true;
|
||||
}
|
||||
if(X1 >= pTileLayer->m_Width - 1)
|
||||
if(X1 > pTileLayer->m_Width)
|
||||
{
|
||||
X1 = pTileLayer->m_Width - 1;
|
||||
X1 = pTileLayer->m_Width;
|
||||
DrawBorder = true;
|
||||
}
|
||||
if(Y1 >= pTileLayer->m_Height - 1)
|
||||
if(Y1 > pTileLayer->m_Height)
|
||||
{
|
||||
Y1 = pTileLayer->m_Height - 1;
|
||||
Y1 = pTileLayer->m_Height;
|
||||
DrawBorder = true;
|
||||
}
|
||||
|
||||
bool DrawLayer = true;
|
||||
if(X1 < 0)
|
||||
if(X1 <= 0)
|
||||
DrawLayer = false;
|
||||
if(Y1 < 0)
|
||||
if(Y1 <= 0)
|
||||
DrawLayer = false;
|
||||
if(X0 >= pTileLayer->m_Width)
|
||||
DrawLayer = false;
|
||||
|
@ -1063,14 +968,15 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
|
|||
s_vpIndexOffsets.reserve(Reserve);
|
||||
s_vDrawCounts.reserve(Reserve);
|
||||
|
||||
for(int y = Y0; y <= Y1; ++y)
|
||||
for(int y = Y0; y < Y1; ++y)
|
||||
{
|
||||
if(X0 > X1)
|
||||
continue;
|
||||
int XR = X1 - 1;
|
||||
|
||||
dbg_assert(Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X1].IndexBufferByteOffset() >= Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X0].IndexBufferByteOffset(), "Tile count wrong.");
|
||||
dbg_assert(Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + XR].IndexBufferByteOffset() >= Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X0].IndexBufferByteOffset(), "Tile count wrong.");
|
||||
|
||||
unsigned int NumVertices = ((Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X1].IndexBufferByteOffset() - Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X0].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X1].DoDraw() ? 6lu : 0lu);
|
||||
unsigned int NumVertices = ((Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + XR].IndexBufferByteOffset() - Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + X0].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pTilesOfLayer[y * pTileLayer->m_Width + XR].DoDraw() ? 6lu : 0lu);
|
||||
|
||||
if(NumVertices)
|
||||
{
|
||||
|
@ -1092,23 +998,10 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
|
|||
}
|
||||
|
||||
if(DrawBorder)
|
||||
RenderTileBorder(LayerIndex, Color, pTileLayer, pGroup, BorderX0, BorderY0, BorderX1, BorderY1, -std::floor(-ScreenX1 / 32.f) - BorderX0, -std::floor(-ScreenY1 / 32.f) - BorderY0);
|
||||
RenderTileBorder(LayerIndex, Color, pTileLayer, pGroup, BorderX0, BorderY0, BorderX1, BorderY1);
|
||||
}
|
||||
|
||||
void CMapLayers::RenderTileBorderCornerTiles(int WidthOffsetToOrigin, int HeightOffsetToOrigin, int TileCountWidth, int TileCountHeight, int BufferContainerIndex, const ColorRGBA &Color, offset_ptr_size IndexBufferOffset, const vec2 &Offset, const vec2 &Dir)
|
||||
{
|
||||
// if border is still in range of the original corner, it doesn't needs to be redrawn
|
||||
bool CornerVisible = (WidthOffsetToOrigin - 1 < TileCountWidth) && (HeightOffsetToOrigin - 1 < TileCountHeight);
|
||||
|
||||
int CountX = minimum(WidthOffsetToOrigin, TileCountWidth);
|
||||
int CountY = minimum(HeightOffsetToOrigin, TileCountHeight);
|
||||
|
||||
int Count = (CountX * CountY) - (CornerVisible ? 1 : 0); // Don't draw the corner again
|
||||
|
||||
Graphics()->RenderBorderTiles(BufferContainerIndex, Color, IndexBufferOffset, Offset, Dir, CountX, Count);
|
||||
}
|
||||
|
||||
void CMapLayers::RenderTileBorder(int LayerIndex, const ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1, int ScreenWidthTileCount, int ScreenHeightTileCount)
|
||||
void CMapLayers::RenderTileBorder(int LayerIndex, const ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1)
|
||||
{
|
||||
STileLayerVisuals &Visuals = *m_vpTileLayerVisuals[LayerIndex];
|
||||
|
||||
|
@ -1117,145 +1010,147 @@ void CMapLayers::RenderTileBorder(int LayerIndex, const ColorRGBA &Color, CMapIt
|
|||
int Y1 = BorderY1;
|
||||
int X1 = BorderX1;
|
||||
|
||||
int CountWidth = ScreenWidthTileCount;
|
||||
int CountHeight = ScreenHeightTileCount;
|
||||
if(X0 < 0)
|
||||
X0 = 0;
|
||||
if(Y0 < 0)
|
||||
Y0 = 0;
|
||||
if(X1 > pTileLayer->m_Width)
|
||||
X1 = pTileLayer->m_Width;
|
||||
if(Y1 > pTileLayer->m_Height)
|
||||
Y1 = pTileLayer->m_Height;
|
||||
|
||||
if(X0 < 1)
|
||||
X0 = 1;
|
||||
if(Y0 < 1)
|
||||
Y0 = 1;
|
||||
if(X1 >= pTileLayer->m_Width - 1)
|
||||
X1 = pTileLayer->m_Width - 2;
|
||||
if(Y1 >= pTileLayer->m_Height - 1)
|
||||
Y1 = pTileLayer->m_Height - 2;
|
||||
|
||||
if(BorderX0 <= 0)
|
||||
// corners
|
||||
if(BorderX0 < 0)
|
||||
{
|
||||
// Draw corners on left side
|
||||
if(BorderY0 <= 0)
|
||||
if(BorderY0 < 0)
|
||||
{
|
||||
if(Visuals.m_BorderTopLeft.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = BorderX0 * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 32.f;
|
||||
Offset.x = 0;
|
||||
Offset.y = 0;
|
||||
vec2 Scale;
|
||||
Scale.x = absolute(BorderX0);
|
||||
Scale.y = absolute(BorderY0);
|
||||
|
||||
RenderTileBorderCornerTiles(absolute(BorderX0) + 1, absolute(BorderY0) + 1, CountWidth, CountHeight, Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderTopLeft.IndexBufferByteOffset(), Offset, Dir);
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderTopLeft.IndexBufferByteOffset(), Offset, Scale, 1);
|
||||
}
|
||||
}
|
||||
if(BorderY1 >= pTileLayer->m_Height - 1)
|
||||
if(BorderY1 > pTileLayer->m_Height)
|
||||
{
|
||||
if(Visuals.m_BorderBottomLeft.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = BorderX0 * 32.f;
|
||||
Offset.y = (BorderY1 - (pTileLayer->m_Height - 1)) * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = -32.f;
|
||||
Offset.x = 0;
|
||||
Offset.y = pTileLayer->m_Height * 32.0f;
|
||||
vec2 Scale;
|
||||
Scale.x = absolute(BorderX0);
|
||||
Scale.y = BorderY1 - pTileLayer->m_Height;
|
||||
|
||||
RenderTileBorderCornerTiles(absolute(BorderX0) + 1, (BorderY1 - (pTileLayer->m_Height - 1)) + 1, CountWidth, CountHeight, Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderBottomLeft.IndexBufferByteOffset(), Offset, Dir);
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderBottomLeft.IndexBufferByteOffset(), Offset, Scale, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(BorderX1 > pTileLayer->m_Width)
|
||||
{
|
||||
// Draw corners on right side
|
||||
if(BorderY0 < 0)
|
||||
{
|
||||
if(Visuals.m_BorderTopRight.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = pTileLayer->m_Width * 32.0f;
|
||||
Offset.y = 0;
|
||||
vec2 Scale;
|
||||
Scale.x = BorderX1 - pTileLayer->m_Width;
|
||||
Scale.y = absolute(BorderY0);
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderTopRight.IndexBufferByteOffset(), Offset, Scale, 1);
|
||||
}
|
||||
}
|
||||
if(BorderY1 > pTileLayer->m_Height)
|
||||
{
|
||||
if(Visuals.m_BorderBottomRight.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = pTileLayer->m_Width * 32.0f;
|
||||
Offset.y = pTileLayer->m_Height * 32.0f;
|
||||
vec2 Scale;
|
||||
Scale.x = BorderX1 - pTileLayer->m_Width;
|
||||
Scale.y = BorderY1 - pTileLayer->m_Height;
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderBottomRight.IndexBufferByteOffset(), Offset, Scale, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(BorderX1 > pTileLayer->m_Width)
|
||||
{
|
||||
// Draw right border
|
||||
if(Y0 < pTileLayer->m_Height && Y1 > 0)
|
||||
{
|
||||
int YB = Y1 - 1;
|
||||
unsigned int DrawNum = ((Visuals.m_vBorderRight[YB].IndexBufferByteOffset() - Visuals.m_vBorderRight[Y0].IndexBufferByteOffset()) / (sizeof(unsigned int) * 6)) + (Visuals.m_vBorderRight[YB].DoDraw() ? 1lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_vBorderRight[Y0].IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = 32.f * pTileLayer->m_Width;
|
||||
Offset.y = 0.f;
|
||||
vec2 Scale;
|
||||
Scale.x = BorderX1 - pTileLayer->m_Width;
|
||||
Scale.y = 1.f;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
}
|
||||
if(BorderX0 < 0)
|
||||
{
|
||||
// Draw left border
|
||||
if(Y0 < pTileLayer->m_Height - 1 && Y1 > 0)
|
||||
if(Y0 < pTileLayer->m_Height && Y1 > 0)
|
||||
{
|
||||
unsigned int DrawNum = ((Visuals.m_pBorderLeft[Y1 - 1].IndexBufferByteOffset() - Visuals.m_pBorderLeft[Y0 - 1].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pBorderLeft[Y1 - 1].DoDraw() ? 6lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_pBorderLeft[Y0 - 1].IndexBufferByteOffset();
|
||||
int YB = Y1 - 1;
|
||||
unsigned int DrawNum = ((Visuals.m_vBorderLeft[YB].IndexBufferByteOffset() - Visuals.m_vBorderLeft[Y0].IndexBufferByteOffset()) / (sizeof(unsigned int) * 6)) + (Visuals.m_vBorderLeft[YB].DoDraw() ? 1lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_vBorderLeft[Y0].IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = 32.f * BorderX0;
|
||||
Offset.y = 0.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 0.f;
|
||||
Graphics()->RenderBorderTileLines(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Dir, DrawNum, minimum(absolute(BorderX0), CountWidth));
|
||||
}
|
||||
}
|
||||
|
||||
if(BorderX1 >= pTileLayer->m_Width - 1)
|
||||
{
|
||||
// Draw corners on right side
|
||||
if(BorderY0 <= 0)
|
||||
{
|
||||
if(Visuals.m_BorderTopRight.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = (BorderX1 - (pTileLayer->m_Width - 1)) * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = -32.f;
|
||||
Dir.y = 32.f;
|
||||
|
||||
RenderTileBorderCornerTiles((BorderX1 - (pTileLayer->m_Width - 1)) + 1, absolute(BorderY0) + 1, CountWidth, CountHeight, Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderTopRight.IndexBufferByteOffset(), Offset, Dir);
|
||||
}
|
||||
}
|
||||
if(BorderY1 >= pTileLayer->m_Height - 1)
|
||||
{
|
||||
if(Visuals.m_BorderBottomRight.DoDraw())
|
||||
{
|
||||
vec2 Offset;
|
||||
Offset.x = (BorderX1 - (pTileLayer->m_Width - 1)) * 32.f;
|
||||
Offset.y = (BorderY1 - (pTileLayer->m_Height - 1)) * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = -32.f;
|
||||
Dir.y = -32.f;
|
||||
|
||||
RenderTileBorderCornerTiles((BorderX1 - (pTileLayer->m_Width - 1)) + 1, (BorderY1 - (pTileLayer->m_Height - 1)) + 1, CountWidth, CountHeight, Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderBottomRight.IndexBufferByteOffset(), Offset, Dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(BorderX1 > pTileLayer->m_Width - 1)
|
||||
{
|
||||
// Draw right border
|
||||
if(Y0 < pTileLayer->m_Height - 1 && Y1 > 0)
|
||||
{
|
||||
unsigned int DrawNum = ((Visuals.m_pBorderRight[Y1 - 1].IndexBufferByteOffset() - Visuals.m_pBorderRight[Y0 - 1].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pBorderRight[Y1 - 1].DoDraw() ? 6lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_pBorderRight[Y0 - 1].IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = 32.f * (BorderX1 - (pTileLayer->m_Width - 1));
|
||||
Offset.y = 0.f;
|
||||
vec2 Dir;
|
||||
Dir.x = -32.f;
|
||||
Dir.y = 0.f;
|
||||
Graphics()->RenderBorderTileLines(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Dir, DrawNum, minimum((BorderX1 - (pTileLayer->m_Width - 1)), CountWidth));
|
||||
Offset.x = 0;
|
||||
Offset.y = 0;
|
||||
vec2 Scale;
|
||||
Scale.x = absolute(BorderX0);
|
||||
Scale.y = 1;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
}
|
||||
if(BorderY0 < 0)
|
||||
{
|
||||
// Draw top border
|
||||
if(X0 < pTileLayer->m_Width - 1 && X1 > 0)
|
||||
if(X0 < pTileLayer->m_Width && X1 > 0)
|
||||
{
|
||||
unsigned int DrawNum = ((Visuals.m_pBorderTop[X1 - 1].IndexBufferByteOffset() - Visuals.m_pBorderTop[X0 - 1].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pBorderTop[X1 - 1].DoDraw() ? 6lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_pBorderTop[X0 - 1].IndexBufferByteOffset();
|
||||
int XR = X1 - 1;
|
||||
unsigned int DrawNum = ((Visuals.m_vBorderTop[XR].IndexBufferByteOffset() - Visuals.m_vBorderTop[X0].IndexBufferByteOffset()) / (sizeof(unsigned int) * 6)) + (Visuals.m_vBorderTop[XR].DoDraw() ? 1lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_vBorderTop[X0].IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = 0.f;
|
||||
Offset.y = 32.f * BorderY0;
|
||||
vec2 Dir;
|
||||
Dir.x = 0.f;
|
||||
Dir.y = 32.f;
|
||||
Graphics()->RenderBorderTileLines(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Dir, DrawNum, minimum(absolute(BorderY0), CountHeight));
|
||||
Offset.y = 0;
|
||||
vec2 Scale;
|
||||
Scale.x = 1;
|
||||
Scale.y = absolute(BorderY0);
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
}
|
||||
if(BorderY1 >= pTileLayer->m_Height)
|
||||
if(BorderY1 > pTileLayer->m_Height)
|
||||
{
|
||||
// Draw bottom border
|
||||
if(X0 < pTileLayer->m_Width - 1 && X1 > 0)
|
||||
if(X0 < pTileLayer->m_Width && X1 > 0)
|
||||
{
|
||||
unsigned int DrawNum = ((Visuals.m_pBorderBottom[X1 - 1].IndexBufferByteOffset() - Visuals.m_pBorderBottom[X0 - 1].IndexBufferByteOffset()) / sizeof(unsigned int)) + (Visuals.m_pBorderBottom[X1 - 1].DoDraw() ? 6lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_pBorderBottom[X0 - 1].IndexBufferByteOffset();
|
||||
int XR = X1 - 1;
|
||||
unsigned int DrawNum = ((Visuals.m_vBorderBottom[XR].IndexBufferByteOffset() - Visuals.m_vBorderBottom[X0].IndexBufferByteOffset()) / (sizeof(unsigned int) * 6)) + (Visuals.m_vBorderBottom[XR].DoDraw() ? 1lu : 0lu);
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_vBorderBottom[X0].IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = 0.f;
|
||||
Offset.y = 32.f * (BorderY1 - (pTileLayer->m_Height - 1));
|
||||
vec2 Dir;
|
||||
Dir.x = 0.f;
|
||||
Dir.y = -32.f;
|
||||
Graphics()->RenderBorderTileLines(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Dir, DrawNum, minimum((BorderY1 - (pTileLayer->m_Height - 1)), CountHeight));
|
||||
Offset.y = 32.f * pTileLayer->m_Height;
|
||||
vec2 Scale;
|
||||
Scale.x = 1;
|
||||
Scale.y = BorderY1 - pTileLayer->m_Height;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1271,18 +1166,18 @@ void CMapLayers::RenderKillTileBorder(int LayerIndex, const ColorRGBA &Color, CM
|
|||
|
||||
bool DrawBorder = false;
|
||||
|
||||
int BorderY0 = (int)(ScreenY0 / 32) - 1;
|
||||
int BorderX0 = (int)(ScreenX0 / 32) - 1;
|
||||
int BorderY1 = (int)(ScreenY1 / 32) + 1;
|
||||
int BorderX1 = (int)(ScreenX1 / 32) + 1;
|
||||
int BorderY0 = std::floor(ScreenY0 / 32);
|
||||
int BorderX0 = std::floor(ScreenX0 / 32);
|
||||
int BorderY1 = std::ceil(ScreenY1 / 32);
|
||||
int BorderX1 = std::ceil(ScreenX1 / 32);
|
||||
|
||||
if(BorderX0 < -201)
|
||||
DrawBorder = true;
|
||||
if(BorderY0 < -201)
|
||||
DrawBorder = true;
|
||||
if(BorderX1 >= pTileLayer->m_Width + 201)
|
||||
if(BorderX1 > pTileLayer->m_Width + 201)
|
||||
DrawBorder = true;
|
||||
if(BorderY1 >= pTileLayer->m_Height + 201)
|
||||
if(BorderY1 > pTileLayer->m_Height + 201)
|
||||
DrawBorder = true;
|
||||
|
||||
if(!DrawBorder)
|
||||
|
@ -1311,64 +1206,54 @@ void CMapLayers::RenderKillTileBorder(int LayerIndex, const ColorRGBA &Color, CM
|
|||
// Draw left kill tile border
|
||||
if(BorderX0 < -201)
|
||||
{
|
||||
unsigned int DrawNum = 1;
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = BorderX0 * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 32.f;
|
||||
|
||||
int Count = (absolute(BorderX0) - 201) * (BorderY1 - BorderY0);
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset(), Offset, Dir, (absolute(BorderX0) - 201), Count);
|
||||
Offset.x = 32.f * BorderX0;
|
||||
Offset.y = 32.f * BorderY0;
|
||||
vec2 Scale;
|
||||
Scale.x = -201 - BorderX0;
|
||||
Scale.y = BorderY1 - BorderY0;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
// Draw top kill tile border
|
||||
if(BorderY0 < -201)
|
||||
{
|
||||
unsigned int DrawNum = 1;
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
int OffX0 = (BorderX0 < -201 ? -201 : BorderX0);
|
||||
int OffX1 = (BorderX1 >= pTileLayer->m_Width + 201 ? pTileLayer->m_Width + 201 : BorderX1);
|
||||
OffX0 = clamp(OffX0, -201, (int)pTileLayer->m_Width + 201);
|
||||
OffX1 = clamp(OffX1, -201, (int)pTileLayer->m_Width + 201);
|
||||
Offset.x = OffX0 * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 32.f;
|
||||
|
||||
int Count = (OffX1 - OffX0) * (absolute(BorderY0) - 201);
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset(), Offset, Dir, (OffX1 - OffX0), Count);
|
||||
Offset.x = maximum(BorderX0, -201) * 32.0f;
|
||||
Offset.y = 32.f * BorderY0;
|
||||
vec2 Scale;
|
||||
Scale.x = minimum(BorderX1, pTileLayer->m_Width + 201) - maximum(BorderX0, -201);
|
||||
Scale.y = -201 - BorderY0;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
if(BorderX1 >= pTileLayer->m_Width + 201)
|
||||
// Draw right kill tile border
|
||||
if(BorderX1 > pTileLayer->m_Width + 201)
|
||||
{
|
||||
unsigned int DrawNum = 1;
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
Offset.x = (pTileLayer->m_Width + 201) * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 32.f;
|
||||
|
||||
int Count = (BorderX1 - (pTileLayer->m_Width + 201)) * (BorderY1 - BorderY0);
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset(), Offset, Dir, (BorderX1 - (pTileLayer->m_Width + 201)), Count);
|
||||
Offset.x = 32.0f * (pTileLayer->m_Width + 201);
|
||||
Offset.y = 32.0f * BorderY0;
|
||||
vec2 Scale;
|
||||
Scale.x = BorderX1 - (pTileLayer->m_Width + 201);
|
||||
Scale.y = BorderY1 - BorderY0;
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
if(BorderY1 >= pTileLayer->m_Height + 201)
|
||||
// Draw bottom kill tile border
|
||||
if(BorderY1 > pTileLayer->m_Height + 201)
|
||||
{
|
||||
unsigned int DrawNum = 1;
|
||||
offset_ptr_size pOffset = (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset();
|
||||
vec2 Offset;
|
||||
int OffX0 = (BorderX0 < -201 ? -201 : BorderX0);
|
||||
int OffX1 = (BorderX1 >= pTileLayer->m_Width + 201 ? pTileLayer->m_Width + 201 : BorderX1);
|
||||
OffX0 = clamp(OffX0, -201, (int)pTileLayer->m_Width + 201);
|
||||
OffX1 = clamp(OffX1, -201, (int)pTileLayer->m_Width + 201);
|
||||
Offset.x = OffX0 * 32.f;
|
||||
Offset.y = (pTileLayer->m_Height + 201) * 32.f;
|
||||
vec2 Dir;
|
||||
Dir.x = 32.f;
|
||||
Dir.y = 32.f;
|
||||
|
||||
int Count = (OffX1 - OffX0) * (BorderY1 - (pTileLayer->m_Height + 201));
|
||||
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, (offset_ptr_size)Visuals.m_BorderKillTile.IndexBufferByteOffset(), Offset, Dir, (OffX1 - OffX0), Count);
|
||||
Offset.x = maximum(BorderX0, -201) * 32.0f;
|
||||
Offset.y = 32.0f * (pTileLayer->m_Height + 201);
|
||||
vec2 Scale;
|
||||
Scale.x = minimum(BorderX1, pTileLayer->m_Width + 201) - maximum(BorderX0, -201);
|
||||
Scale.y = BorderY1 - (pTileLayer->m_Height + 201);
|
||||
Graphics()->RenderBorderTiles(Visuals.m_BufferContainerIndex, Color, pOffset, Offset, Scale, DrawNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1960,6 +1845,7 @@ void CMapLayers::OnRender()
|
|||
Graphics()->TextureSet(m_pImages->GetSpeedupArrow());
|
||||
RenderTileLayer(TileLayerCounter - 3, Color, pTMap, pGroup);
|
||||
Graphics()->WrapNormal();
|
||||
|
||||
if(g_Config.m_ClTextEntities)
|
||||
{
|
||||
Graphics()->TextureSet(m_pImages->GetOverlayBottom());
|
||||
|
|
|
@ -40,7 +40,7 @@ class CMapLayers : public CComponent
|
|||
struct STileLayerVisuals
|
||||
{
|
||||
STileLayerVisuals() :
|
||||
m_pTilesOfLayer(nullptr), m_pBorderTop(nullptr), m_pBorderLeft(nullptr), m_pBorderRight(nullptr), m_pBorderBottom(nullptr)
|
||||
m_pTilesOfLayer(nullptr)
|
||||
{
|
||||
m_Width = 0;
|
||||
m_Height = 0;
|
||||
|
@ -63,27 +63,27 @@ class CMapLayers : public CComponent
|
|||
public:
|
||||
bool DoDraw()
|
||||
{
|
||||
return (m_IndexBufferByteOffset & 0x00000001) != 0;
|
||||
return (m_IndexBufferByteOffset & 0x10000000) != 0;
|
||||
}
|
||||
|
||||
void Draw(bool SetDraw)
|
||||
{
|
||||
m_IndexBufferByteOffset = (SetDraw ? 0x00000001 : (offset_ptr32)0) | (m_IndexBufferByteOffset & 0xFFFFFFFE);
|
||||
m_IndexBufferByteOffset = (SetDraw ? 0x10000000 : (offset_ptr32)0) | (m_IndexBufferByteOffset & 0xEFFFFFFF);
|
||||
}
|
||||
|
||||
offset_ptr IndexBufferByteOffset()
|
||||
{
|
||||
return ((offset_ptr)(m_IndexBufferByteOffset & 0xFFFFFFFE));
|
||||
return ((offset_ptr)(m_IndexBufferByteOffset & 0xEFFFFFFF) * 6 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void SetIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
|
||||
{
|
||||
m_IndexBufferByteOffset = IndexBufferByteOff | (m_IndexBufferByteOffset & 0x00000001);
|
||||
m_IndexBufferByteOffset = IndexBufferByteOff | (m_IndexBufferByteOffset & 0x10000000);
|
||||
}
|
||||
|
||||
void AddIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
|
||||
{
|
||||
m_IndexBufferByteOffset = ((m_IndexBufferByteOffset & 0xFFFFFFFE) + IndexBufferByteOff) | (m_IndexBufferByteOffset & 0x00000001);
|
||||
m_IndexBufferByteOffset = ((m_IndexBufferByteOffset & 0xEFFFFFFF) + IndexBufferByteOff) | (m_IndexBufferByteOffset & 0x10000000);
|
||||
}
|
||||
};
|
||||
STileVisual *m_pTilesOfLayer;
|
||||
|
@ -95,10 +95,10 @@ class CMapLayers : public CComponent
|
|||
|
||||
STileVisual m_BorderKillTile; //end of map kill tile -- game layer only
|
||||
|
||||
STileVisual *m_pBorderTop;
|
||||
STileVisual *m_pBorderLeft;
|
||||
STileVisual *m_pBorderRight;
|
||||
STileVisual *m_pBorderBottom;
|
||||
std::vector<STileVisual> m_vBorderTop;
|
||||
std::vector<STileVisual> m_vBorderLeft;
|
||||
std::vector<STileVisual> m_vBorderRight;
|
||||
std::vector<STileVisual> m_vBorderBottom;
|
||||
|
||||
unsigned int m_Width;
|
||||
unsigned int m_Height;
|
||||
|
@ -132,8 +132,6 @@ class CMapLayers : public CComponent
|
|||
|
||||
void LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer);
|
||||
|
||||
void RenderTileBorderCornerTiles(int WidthOffsetToOrigin, int HeightOffsetToOrigin, int TileCountWidth, int TileCountHeight, int BufferContainerIndex, const ColorRGBA &Color, offset_ptr_size IndexBufferOffset, const vec2 &Offset, const vec2 &Dir);
|
||||
|
||||
protected:
|
||||
virtual bool CanRenderMenuBackground() { return true; }
|
||||
|
||||
|
@ -155,7 +153,7 @@ public:
|
|||
virtual void OnMapLoad() override;
|
||||
|
||||
void RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup);
|
||||
void RenderTileBorder(int LayerIndex, const ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1, int ScreenWidthTileCount, int ScreenHeightTileCount);
|
||||
void RenderTileBorder(int LayerIndex, const ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1);
|
||||
void RenderKillTileBorder(int LayerIndex, const ColorRGBA &Color, CMapItemLayerTilemap *pTileLayer, CMapItemGroup *pGroup);
|
||||
void RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer, CMapItemGroup *pGroup, bool ForceRender = false);
|
||||
|
||||
|
|
|
@ -459,6 +459,9 @@ void CRenderTools::RenderTileRectangle(int RectX, int RectY, int RectW, int Rect
|
|||
pfnEval(ColorEnvOffset, ColorEnv, Channels, pUser);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -501,6 +504,26 @@ void CRenderTools::RenderTileRectangle(int RectX, int RectY, int RectW, int Rect
|
|||
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(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);
|
||||
|
@ -508,7 +531,11 @@ void CRenderTools::RenderTileRectangle(int RectX, int RectY, int RectW, int Rect
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
@ -530,7 +557,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
pfnEval(ColorEnvOffset, ColorEnv, Channels, pUser);
|
||||
}
|
||||
|
||||
if(Graphics()->IsTileBufferingEnabled())
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DBegin();
|
||||
else
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -613,7 +640,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
float x3 = Nudge + Px0 / TexSize + Frac;
|
||||
float y3 = Nudge + Py1 / TexSize - Frac;
|
||||
|
||||
if(Graphics()->IsTileBufferingEnabled())
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
{
|
||||
x0 = 0;
|
||||
y0 = 0;
|
||||
|
@ -655,7 +682,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
y1 = Tmp;
|
||||
}
|
||||
|
||||
if(Graphics()->IsTileBufferingEnabled())
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
{
|
||||
Graphics()->QuadsSetSubsetFree(x0, y0, x1, y1, x2, y2, x3, y3, Index);
|
||||
IGraphics::CQuadItem QuadItem(x * Scale, y * Scale, Scale, Scale);
|
||||
|
@ -673,7 +700,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
}
|
||||
}
|
||||
|
||||
if(Graphics()->IsTileBufferingEnabled())
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
|
@ -918,6 +945,9 @@ void CRenderTools::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, Co
|
|||
float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth();
|
||||
float FinalTilesetScale = FinalTileSize / TilePixelSize;
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DBegin();
|
||||
else
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(Color);
|
||||
|
||||
|
@ -987,13 +1017,37 @@ void CRenderTools::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, Co
|
|||
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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
@ -1010,6 +1064,9 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedupTile, int w, int h, fl
|
|||
float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth();
|
||||
float FinalTilesetScale = FinalTileSize / TilePixelSize;
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DBegin();
|
||||
else
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(Color);
|
||||
|
||||
|
@ -1079,13 +1136,37 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedupTile, int w, int h, fl
|
|||
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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
@ -1102,6 +1183,9 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float
|
|||
float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth();
|
||||
float FinalTilesetScale = FinalTileSize / TilePixelSize;
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DBegin();
|
||||
else
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(Color);
|
||||
|
||||
|
@ -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,13 +1310,25 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float
|
|||
y1 = Tmp;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
@ -1235,6 +1343,9 @@ void CRenderTools::RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, Co
|
|||
float FinalTileSize = Scale / (ScreenX1 - ScreenX0) * Graphics()->ScreenWidth();
|
||||
float FinalTilesetScale = FinalTileSize / TilePixelSize;
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DBegin();
|
||||
else
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(Color);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Graphics()->HasTextureArraysSupport())
|
||||
Graphics()->QuadsTex3DEnd();
|
||||
else
|
||||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
|
|
@ -3941,7 +3941,7 @@ bool CEditor::ReplaceImage(const char *pFileName, int StorageType, bool CheckDup
|
|||
}
|
||||
|
||||
pImg->m_AutoMapper.Load(pImg->m_aName);
|
||||
int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
int TextureLoadFlag = Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, TextureLoadFlag, pFileName);
|
||||
|
@ -4000,7 +4000,7 @@ bool CEditor::AddImage(const char *pFileName, int StorageType, void *pUser)
|
|||
DilateImage((unsigned char *)ImgInfo.m_pData, ImgInfo.m_Width, ImgInfo.m_Height);
|
||||
}
|
||||
|
||||
int TextureLoadFlag = pEditor->Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
int TextureLoadFlag = pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, TextureLoadFlag, pFileName);
|
||||
|
@ -7561,7 +7561,7 @@ void CEditor::Reset(bool CreateDefault)
|
|||
|
||||
int CEditor::GetTextureUsageFlag()
|
||||
{
|
||||
return Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
return Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
}
|
||||
|
||||
IGraphics::CTextureHandle CEditor::GetFrontTexture()
|
||||
|
|
|
@ -505,7 +505,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
|||
pImg->m_Height = ImgInfo.m_Height;
|
||||
pImg->m_Format = ImgInfo.m_Format;
|
||||
pImg->m_pData = ImgInfo.m_pData;
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = m_pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, TextureLoadFlag, aBuf);
|
||||
|
@ -524,7 +524,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
|||
const size_t DataSize = (size_t)pImg->m_Width * pImg->m_Height * CImageInfo::PixelSize(Format);
|
||||
pImg->m_pData = malloc(DataSize);
|
||||
mem_copy(pImg->m_pData, pData, DataSize);
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(pImg->m_Width % 16 != 0 || pImg->m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = m_pEditor->Graphics()->LoadTextureRaw(pImg->m_Width, pImg->m_Height, pImg->m_Format, pImg->m_pData, TextureLoadFlag);
|
||||
|
|
|
@ -154,7 +154,7 @@ static std::shared_ptr<CEditorImage> ImageInfoToEditorImage(CEditor *pEditor, co
|
|||
pEditorImage->m_Format = Image.m_Format;
|
||||
pEditorImage->m_pData = Image.m_pData;
|
||||
|
||||
int TextureLoadFlag = pEditor->Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
int TextureLoadFlag = pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
pEditorImage->m_Texture = pEditor->Graphics()->LoadTextureRaw(Image.m_Width, Image.m_Height, Image.m_Format, Image.m_pData, TextureLoadFlag, pName);
|
||||
pEditorImage->m_External = 0;
|
||||
str_copy(pEditorImage->m_aName, pName);
|
||||
|
|
Loading…
Reference in a new issue