Skip to content

Commit

Permalink
Switch to a fragment shader solution for border tile rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupeyy committed Nov 2, 2023
1 parent dbfe888 commit bb85926
Show file tree
Hide file tree
Showing 19 changed files with 372 additions and 465 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,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
Expand All @@ -1564,6 +1566,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
Expand Down
16 changes: 5 additions & 11 deletions cmake/BuildVulkanShaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,12 @@ 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("-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("" "" "${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_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")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.vert" "data/shader/vulkan/quad.vert.spv")
Expand Down
28 changes: 28 additions & 0 deletions data/shader/tile_border.frag
Original file line number Diff line number Diff line change
@@ -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
}
25 changes: 25 additions & 0 deletions data/shader/tile_border.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
layout (location = 0) in vec2 inVertex;
#ifdef TW_TILE_TEXTURED
layout (location = 1) in vec3 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
TexCoord = vec3(inVertexTexCoord.xy * gScale, inVertexTexCoord.z);
#endif
}
28 changes: 28 additions & 0 deletions data/shader/vulkan/tile_border.frag
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 30 additions & 0 deletions data/shader/vulkan/tile_border.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable

layout (location = 0) in vec2 inVertex;
#ifdef TW_TILE_TEXTURED
layout (location = 1) in vec3 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
TexCoord = vec3(inVertexTexCoord.xy * gPosBO.gScale, inVertexTexCoord.z);
#endif
}
15 changes: 1 addition & 14 deletions src/engine/client/backend/opengl/backend_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,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;
Expand Down Expand Up @@ -2184,19 +2183,7 @@ 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);
}

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;

SBufferContainer &BufferContainer = m_vBufferContainers[Index];

RenderBorderTileLineEmulation(BufferContainer, pCommand->m_State, pCommand->m_Color, pCommand->m_pIndicesOffset, pCommand->m_IndexDrawNum, pCommand->m_DrawNum, pCommand->m_Offset, pCommand->m_Dir);
//RenderBorderTileEmulation(BufferContainer, pCommand->m_State, pCommand->m_Color, pCommand->m_pIndicesOffset, pCommand->m_DrawNum, pCommand->m_Offset, pCommand->m_Scale);
}

void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand)
Expand Down
2 changes: 0 additions & 2 deletions src/engine/client/backend/opengl/backend_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class CCommandProcessorFragment_OpenGL : public CCommandProcessorFragment_GLBase

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"); }
Expand Down Expand Up @@ -189,7 +188,6 @@ class CCommandProcessorFragment_OpenGL2 : public CCommandProcessorFragment_OpenG

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;
Expand Down
105 changes: 8 additions & 97 deletions src/engine/client/backend/opengl/backend_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -1088,9 +1036,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);
Expand All @@ -1099,50 +1045,15 @@ 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);

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, 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);
pProgram->SetUniformVec2(pProgram->m_LocScale, 1, (float *)&pCommand->m_Scale);

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)
Expand Down
3 changes: 0 additions & 3 deletions src/engine/client/backend/opengl/backend_opengl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class CCommandProcessorFragment_OpenGL3_3 : public CCommandProcessorFragment_Ope
CGLSLPrimitiveProgram *m_pPrimitiveProgramTextured;
CGLSLTileProgram *m_pBorderTileProgram;
CGLSLTileProgram *m_pBorderTileProgramTextured;
CGLSLTileProgram *m_pBorderTileLineProgram;
CGLSLTileProgram *m_pBorderTileLineProgramTextured;
CGLSLQuadProgram *m_pQuadProgram;
CGLSLQuadProgram *m_pQuadProgramTextured;
CGLSLTextProgram *m_pTextProgram;
Expand Down Expand Up @@ -110,7 +108,6 @@ class CCommandProcessorFragment_OpenGL3_3 : public CCommandProcessorFragment_Ope

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;
Expand Down
Loading

0 comments on commit bb85926

Please sign in to comment.