Minor color refactors, added DrawPrimitives, rewritten remaining effect rendering
parent
37bdc8665f
commit
750a470b9a
|
@ -37,22 +37,11 @@ namespace Gfx
|
||||||
* \struct Color
|
* \struct Color
|
||||||
* \brief RGBA color
|
* \brief RGBA color
|
||||||
*/
|
*/
|
||||||
struct Color
|
struct Color : glm::vec4
|
||||||
{
|
{
|
||||||
//! Red, green, blue and alpha components
|
|
||||||
float r, g, b, a;
|
|
||||||
|
|
||||||
//! Constructor; default values are (0,0,0,0) = black
|
//! Constructor; default values are (0,0,0,0) = black
|
||||||
explicit Color(float aR = 0.0f, float aG = 0.0f, float aB = 0.0f, float aA = 0.0f)
|
explicit Color(float aR = 0.0f, float aG = 0.0f, float aB = 0.0f, float aA = 0.0f)
|
||||||
: r(aR), g(aG), b(aB), a(aA) {}
|
: glm::vec4(aR, aG, aB, aA) {}
|
||||||
|
|
||||||
Color(const glm::vec4& color)
|
|
||||||
: r(color.r), g(color.g), b(color.b), a(color.a) {}
|
|
||||||
|
|
||||||
operator glm::vec4() const
|
|
||||||
{
|
|
||||||
return { r, g, b, a };
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Color Inverse() const
|
inline Color Inverse() const
|
||||||
{
|
{
|
||||||
|
@ -112,22 +101,11 @@ struct Color
|
||||||
*
|
*
|
||||||
* May be used for precise pixel manipulations.
|
* May be used for precise pixel manipulations.
|
||||||
*/
|
*/
|
||||||
struct IntColor
|
struct IntColor : glm::u8vec4
|
||||||
{
|
{
|
||||||
//! Red, green, blue and alpha components
|
|
||||||
unsigned char r, g, b, a;
|
|
||||||
|
|
||||||
//! Constructor; default values are (0,0,0,0) = black
|
//! Constructor; default values are (0,0,0,0) = black
|
||||||
explicit IntColor(unsigned char aR = 0, unsigned char aG = 0, unsigned char aB = 0, unsigned char aA = 0)
|
explicit IntColor(unsigned char aR = 0, unsigned char aG = 0, unsigned char aB = 0, unsigned char aA = 0)
|
||||||
: r(aR), g(aG), b(aB), a(aA) {}
|
: glm::u8vec4(aR, aG, aB, aA) {}
|
||||||
|
|
||||||
IntColor(const glm::u8vec4& color)
|
|
||||||
: r(color.r), g(color.g), b(color.b), a(color.a) {}
|
|
||||||
|
|
||||||
operator glm::u8vec4() const
|
|
||||||
{
|
|
||||||
return { r, g, b, a };
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Color IntColorToColor(IntColor color)
|
inline Color IntColorToColor(IntColor color)
|
||||||
|
|
|
@ -191,6 +191,8 @@ public:
|
||||||
virtual void DrawObject(const CVertexBuffer* buffer) = 0;
|
virtual void DrawObject(const CVertexBuffer* buffer) = 0;
|
||||||
//! Draws a primitive
|
//! Draws a primitive
|
||||||
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices) = 0;
|
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices) = 0;
|
||||||
|
//! Draws a set of primitives
|
||||||
|
virtual void DrawPrimitives(PrimitiveType type, int drawCount, int count[], const Vertex3D* vertices) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3237,8 +3237,6 @@ void CEngine::Draw3DScene()
|
||||||
|
|
||||||
m_water->DrawSurf(); // draws water surface
|
m_water->DrawSurf(); // draws water surface
|
||||||
|
|
||||||
objectRenderer->End();
|
|
||||||
|
|
||||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_WATER);
|
CProfiler::StopPerformanceCounter(PCNT_RENDER_WATER);
|
||||||
|
|
||||||
RenderPendingDebugDraws();
|
RenderPendingDebugDraws();
|
||||||
|
@ -3246,17 +3244,19 @@ void CEngine::Draw3DScene()
|
||||||
if (m_debugGoto)
|
if (m_debugGoto)
|
||||||
{
|
{
|
||||||
glm::mat4 worldMatrix = glm::mat4(1.0f);
|
glm::mat4 worldMatrix = glm::mat4(1.0f);
|
||||||
//m_device->SetTransform(TRANSFORM_WORLD, worldMatrix);
|
objectRenderer->SetTransparency(TransparencyMode::NONE);
|
||||||
|
objectRenderer->SetLighting(false);
|
||||||
//SetState(ENG_RSTATE_OPAQUE_COLOR);
|
objectRenderer->SetModelMatrix(glm::mat4(1.0f));
|
||||||
|
|
||||||
for (const auto& line : m_displayGoto)
|
for (const auto& line : m_displayGoto)
|
||||||
{
|
{
|
||||||
m_device->DrawPrimitive(PrimitiveType::LINE_STRIP, line.data(), line.size());
|
objectRenderer->DrawPrimitive(PrimitiveType::LINE_STRIP, line.size(), line.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_displayGoto.clear();
|
m_displayGoto.clear();
|
||||||
|
|
||||||
|
objectRenderer->End();
|
||||||
|
|
||||||
auto particleRenderer = m_device->GetParticleRenderer();
|
auto particleRenderer = m_device->GetParticleRenderer();
|
||||||
particleRenderer->Begin();
|
particleRenderer->Begin();
|
||||||
particleRenderer->SetProjectionMatrix(m_matProj);
|
particleRenderer->SetProjectionMatrix(m_matProj);
|
||||||
|
@ -3266,10 +3266,10 @@ void CEngine::Draw3DScene()
|
||||||
m_particle->DrawParticle(SH_WORLD); // draws the particles of the 3D world
|
m_particle->DrawParticle(SH_WORLD); // draws the particles of the 3D world
|
||||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_PARTICLE_WORLD);
|
CProfiler::StopPerformanceCounter(PCNT_RENDER_PARTICLE_WORLD);
|
||||||
|
|
||||||
particleRenderer->End();
|
|
||||||
|
|
||||||
m_lightning->Draw(); // draws lightning
|
m_lightning->Draw(); // draws lightning
|
||||||
|
|
||||||
|
particleRenderer->End();
|
||||||
|
|
||||||
DrawForegroundImage(); // draws the foreground
|
DrawForegroundImage(); // draws the foreground
|
||||||
|
|
||||||
if (! m_overFront) DrawOverColor(); // draws the foreground color
|
if (! m_overFront) DrawOverColor(); // draws the foreground color
|
||||||
|
@ -3448,18 +3448,12 @@ void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const glm::mat4& tra
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
||||||
const int firstDraw = m_pendingDebugDraws.firsts.size();
|
const int firstDraw = m_pendingDebugDraws.counts.size();
|
||||||
const int firstVert = m_pendingDebugDraws.vertices.size();
|
const int firstVert = m_pendingDebugDraws.vertices.size();
|
||||||
|
|
||||||
m_pendingDebugDraws.firsts.resize(m_pendingDebugDraws.firsts.size() + NUM_LINE_STRIPS);
|
|
||||||
m_pendingDebugDraws.counts.resize(m_pendingDebugDraws.counts.size() + NUM_LINE_STRIPS);
|
m_pendingDebugDraws.counts.resize(m_pendingDebugDraws.counts.size() + NUM_LINE_STRIPS);
|
||||||
m_pendingDebugDraws.vertices.resize(m_pendingDebugDraws.vertices.size() + verticesTemplate.size());
|
m_pendingDebugDraws.vertices.resize(m_pendingDebugDraws.vertices.size() + verticesTemplate.size());
|
||||||
|
|
||||||
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
|
||||||
{
|
|
||||||
m_pendingDebugDraws.firsts[i + firstDraw] = firstVert + i * VERTS_IN_LINE_STRIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
||||||
{
|
{
|
||||||
m_pendingDebugDraws.counts[i + firstDraw] = VERTS_IN_LINE_STRIP;
|
m_pendingDebugDraws.counts[i + firstDraw] = VERTS_IN_LINE_STRIP;
|
||||||
|
@ -3468,7 +3462,7 @@ void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const glm::mat4& tra
|
||||||
for (std::size_t i = 0; i < verticesTemplate.size(); ++i)
|
for (std::size_t i = 0; i < verticesTemplate.size(); ++i)
|
||||||
{
|
{
|
||||||
auto pos = Math::Transform(transform, sphere.pos + verticesTemplate[i] * sphere.radius);
|
auto pos = Math::Transform(transform, sphere.pos + verticesTemplate[i] * sphere.radius);
|
||||||
m_pendingDebugDraws.vertices[i + firstVert] = VertexCol{pos, color};
|
m_pendingDebugDraws.vertices[i + firstVert] = Vertex3D{ pos, {}, color };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3477,18 +3471,12 @@ void CEngine::RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const
|
||||||
static constexpr int NUM_LINE_STRIPS = 4;
|
static constexpr int NUM_LINE_STRIPS = 4;
|
||||||
static constexpr int VERTS_IN_LINE_STRIP = 4;
|
static constexpr int VERTS_IN_LINE_STRIP = 4;
|
||||||
|
|
||||||
const int firstDraw = m_pendingDebugDraws.firsts.size();
|
const int firstDraw = m_pendingDebugDraws.counts.size();
|
||||||
const int firstVert = m_pendingDebugDraws.vertices.size();
|
const int firstVert = m_pendingDebugDraws.vertices.size();
|
||||||
|
|
||||||
m_pendingDebugDraws.firsts.resize(m_pendingDebugDraws.firsts.size() + NUM_LINE_STRIPS);
|
|
||||||
m_pendingDebugDraws.counts.resize(m_pendingDebugDraws.counts.size() + NUM_LINE_STRIPS);
|
m_pendingDebugDraws.counts.resize(m_pendingDebugDraws.counts.size() + NUM_LINE_STRIPS);
|
||||||
m_pendingDebugDraws.vertices.resize(m_pendingDebugDraws.vertices.size() + NUM_LINE_STRIPS * VERTS_IN_LINE_STRIP);
|
m_pendingDebugDraws.vertices.resize(m_pendingDebugDraws.vertices.size() + NUM_LINE_STRIPS * VERTS_IN_LINE_STRIP);
|
||||||
|
|
||||||
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
|
||||||
{
|
|
||||||
m_pendingDebugDraws.firsts[i + firstDraw] = firstVert + (i * VERTS_IN_LINE_STRIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
for (int i = 0; i < NUM_LINE_STRIPS; ++i)
|
||||||
{
|
{
|
||||||
m_pendingDebugDraws.counts[i + firstDraw] = NUM_LINE_STRIPS;
|
m_pendingDebugDraws.counts[i + firstDraw] = NUM_LINE_STRIPS;
|
||||||
|
@ -3496,42 +3484,43 @@ void CEngine::RenderDebugBox(const glm::vec3& mins, const glm::vec3& maxs, const
|
||||||
|
|
||||||
auto vert = m_pendingDebugDraws.vertices.begin() + firstVert;
|
auto vert = m_pendingDebugDraws.vertices.begin() + firstVert;
|
||||||
|
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, mins.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, mins.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, mins.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, mins.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, maxs.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, maxs.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, maxs.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, maxs.y, maxs.z}), {}, color };
|
||||||
|
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, mins.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, mins.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, mins.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, mins.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, maxs.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, maxs.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, maxs.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, maxs.y, mins.z}), {}, color };
|
||||||
|
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, mins.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, mins.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, mins.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, mins.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, maxs.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, maxs.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, maxs.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, maxs.y, mins.z}), {}, color };
|
||||||
|
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, mins.y, mins.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, mins.y, mins.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, mins.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, mins.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{maxs.x, maxs.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{maxs.x, maxs.y, maxs.z}), {}, color };
|
||||||
*vert++ = VertexCol{Math::Transform(transform, glm::vec3{mins.x, maxs.y, maxs.z}), color};
|
*vert++ = Vertex3D{ Math::Transform(transform, glm::vec3{mins.x, maxs.y, maxs.z}), {}, color };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::RenderPendingDebugDraws()
|
void CEngine::RenderPendingDebugDraws()
|
||||||
{
|
{
|
||||||
if (m_pendingDebugDraws.firsts.empty()) return;
|
if (m_pendingDebugDraws.counts.empty()) return;
|
||||||
|
|
||||||
//m_device->SetTransform(TRANSFORM_WORLD, glm::mat4(1.0f));
|
auto renderer = m_device->GetObjectRenderer();
|
||||||
|
renderer->SetTransparency(TransparencyMode::NONE);
|
||||||
|
renderer->SetLighting(false);
|
||||||
|
renderer->SetModelMatrix(glm::mat4(1.0f));
|
||||||
|
renderer->SetPrimaryTexture(Texture{});
|
||||||
|
renderer->SetSecondaryTexture(Texture{});
|
||||||
|
|
||||||
//SetState(ENG_RSTATE_OPAQUE_COLOR);
|
renderer->DrawPrimitives(PrimitiveType::LINE_STRIP,
|
||||||
|
m_pendingDebugDraws.counts.size(),
|
||||||
|
m_pendingDebugDraws.counts.data(),
|
||||||
|
m_pendingDebugDraws.vertices.data());
|
||||||
|
|
||||||
m_device->DrawPrimitives(PrimitiveType::LINE_STRIP,
|
|
||||||
m_pendingDebugDraws.vertices.data(),
|
|
||||||
m_pendingDebugDraws.firsts.data(),
|
|
||||||
m_pendingDebugDraws.counts.data(),
|
|
||||||
m_pendingDebugDraws.firsts.size());
|
|
||||||
|
|
||||||
m_pendingDebugDraws.firsts.clear();
|
|
||||||
m_pendingDebugDraws.counts.clear();
|
m_pendingDebugDraws.counts.clear();
|
||||||
m_pendingDebugDraws.vertices.clear();
|
m_pendingDebugDraws.vertices.clear();
|
||||||
}
|
}
|
||||||
|
@ -4396,7 +4385,7 @@ void CEngine::DrawShadowSpots()
|
||||||
//SetState(ENG_RSTATE_TTEXTURE_WHITE, Color(intensity, intensity, intensity, intensity));
|
//SetState(ENG_RSTATE_TTEXTURE_WHITE, Color(intensity, intensity, intensity, intensity));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertex, 4);
|
//m_device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertex, 4);
|
||||||
AddStatisticTriangle(2);
|
AddStatisticTriangle(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4424,7 +4413,7 @@ void CEngine::DrawBackground()
|
||||||
|
|
||||||
void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
|
void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
|
||||||
{
|
{
|
||||||
glm::vec2 p1(0.0f, 0.5f);
|
glm::vec2 p1(0.0f, 0.0f);
|
||||||
glm::vec2 p2(1.0f, 1.0f);
|
glm::vec2 p2(1.0f, 1.0f);
|
||||||
|
|
||||||
glm::u8vec4 color[3] =
|
glm::u8vec4 color[3] =
|
||||||
|
@ -4434,29 +4423,19 @@ void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
auto renderer = m_device->GetObjectRenderer();
|
Vertex2D vertex[4] =
|
||||||
renderer->Begin();
|
|
||||||
renderer->SetProjectionMatrix(m_matProjInterface);
|
|
||||||
renderer->SetViewMatrix(m_matViewInterface);
|
|
||||||
renderer->SetModelMatrix(m_matWorldInterface);
|
|
||||||
renderer->SetLighting(false);
|
|
||||||
|
|
||||||
renderer->SetPrimaryTexture(Texture{});
|
|
||||||
renderer->SetSecondaryTexture(Texture{});
|
|
||||||
renderer->SetDepthTest(false);
|
|
||||||
|
|
||||||
Vertex3D vertex[4] =
|
|
||||||
{
|
{
|
||||||
{ glm::vec3(p1.x, p1.y, 0.0f), color[1] },
|
{ { p1.x, p1.y }, {}, color[1] },
|
||||||
{ glm::vec3(p1.x, p2.y, 0.0f), color[0] },
|
{ { p1.x, p2.y }, {}, color[0] },
|
||||||
{ glm::vec3(p2.x, p1.y, 0.0f), color[1] },
|
{ { p2.x, p1.y }, {}, color[1] },
|
||||||
{ glm::vec3(p2.x, p2.y, 0.0f), color[0] }
|
{ { p2.x, p2.y }, {}, color[0] }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto renderer = m_device->GetUIRenderer();
|
||||||
|
renderer->SetTexture(Texture{});
|
||||||
|
renderer->SetTransparency(TransparencyMode::NONE);
|
||||||
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertex);
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertex);
|
||||||
AddStatisticTriangle(2);
|
AddStatisticTriangle(2);
|
||||||
|
|
||||||
renderer->End();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::DrawBackgroundImage()
|
void CEngine::DrawBackgroundImage()
|
||||||
|
@ -4535,6 +4514,7 @@ void CEngine::DrawBackgroundImage()
|
||||||
|
|
||||||
auto renderer = m_device->GetUIRenderer();
|
auto renderer = m_device->GetUIRenderer();
|
||||||
renderer->SetTexture(m_backgroundTex);
|
renderer->SetTexture(m_backgroundTex);
|
||||||
|
renderer->SetTransparency(TransparencyMode::NONE);
|
||||||
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertices);
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertices);
|
||||||
AddStatisticTriangle(2);
|
AddStatisticTriangle(2);
|
||||||
}
|
}
|
||||||
|
@ -5149,7 +5129,7 @@ bool CEngine::GetDebugGoto()
|
||||||
return m_debugGoto;
|
return m_debugGoto;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::AddDebugGotoLine(std::vector<Gfx::VertexCol> line)
|
void CEngine::AddDebugGotoLine(std::vector<Gfx::Vertex3D> line)
|
||||||
{
|
{
|
||||||
m_displayGoto.push_back(line);
|
m_displayGoto.push_back(line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ public:
|
||||||
|
|
||||||
void SetDebugGoto(bool debugGoto);
|
void SetDebugGoto(bool debugGoto);
|
||||||
bool GetDebugGoto();
|
bool GetDebugGoto();
|
||||||
void AddDebugGotoLine(std::vector<Gfx::VertexCol> line);
|
void AddDebugGotoLine(std::vector<Gfx::Vertex3D> line);
|
||||||
void SetDebugGotoBitmap(std::unique_ptr<CImage> debugImage);
|
void SetDebugGotoBitmap(std::unique_ptr<CImage> debugImage);
|
||||||
|
|
||||||
void SetWindowCoordinates();
|
void SetWindowCoordinates();
|
||||||
|
@ -1398,8 +1398,7 @@ protected:
|
||||||
|
|
||||||
struct PendingDebugDraw
|
struct PendingDebugDraw
|
||||||
{
|
{
|
||||||
std::vector<VertexCol> vertices;
|
std::vector<Vertex3D> vertices;
|
||||||
std::vector<int> firsts;
|
|
||||||
std::vector<int> counts;
|
std::vector<int> counts;
|
||||||
}
|
}
|
||||||
m_pendingDebugDraws;
|
m_pendingDebugDraws;
|
||||||
|
@ -1477,7 +1476,7 @@ protected:
|
||||||
|
|
||||||
std::unordered_map<std::string, int> m_staticMeshBaseObjects;
|
std::unordered_map<std::string, int> m_staticMeshBaseObjects;
|
||||||
|
|
||||||
std::vector<std::vector<VertexCol>> m_displayGoto;
|
std::vector<std::vector<Vertex3D>> m_displayGoto;
|
||||||
std::unique_ptr<CImage> m_displayGotoImage;
|
std::unique_ptr<CImage> m_displayGotoImage;
|
||||||
|
|
||||||
//! Pause the animation updates
|
//! Pause the animation updates
|
||||||
|
|
|
@ -221,12 +221,13 @@ void CLightning::Draw()
|
||||||
if (m_phase != LightningPhase::Flash) return;
|
if (m_phase != LightningPhase::Flash) return;
|
||||||
|
|
||||||
CDevice* device = m_engine->GetDevice();
|
CDevice* device = m_engine->GetDevice();
|
||||||
|
auto renderer = device->GetParticleRenderer();
|
||||||
|
|
||||||
glm::mat4 mat = glm::mat4(1.0f);
|
auto texture = m_engine->LoadTexture("textures/effect00.png");
|
||||||
//device->SetTransform(TRANSFORM_WORLD, mat);
|
|
||||||
|
|
||||||
//m_engine->SetTexture("textures/effect00.png");
|
renderer->SetModelMatrix(glm::mat4(1.0f));
|
||||||
//m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK);
|
renderer->SetTexture(texture);
|
||||||
|
renderer->SetTransparency(TransparencyMode::BLACK);
|
||||||
|
|
||||||
glm::vec2 texInf;
|
glm::vec2 texInf;
|
||||||
texInf.x = 64.5f/256.0f;
|
texInf.x = 64.5f/256.0f;
|
||||||
|
@ -241,7 +242,7 @@ void CLightning::Draw()
|
||||||
glm::vec3 n = glm::normalize(p1-eye);
|
glm::vec3 n = glm::normalize(p1-eye);
|
||||||
|
|
||||||
glm::vec3 corner[4];
|
glm::vec3 corner[4];
|
||||||
Vertex vertex[4];
|
Vertex3D vertex[4];
|
||||||
|
|
||||||
for (std::size_t i = 0; i < m_segments.size() - 1; i++)
|
for (std::size_t i = 0; i < m_segments.size() - 1; i++)
|
||||||
{
|
{
|
||||||
|
@ -272,22 +273,24 @@ void CLightning::Draw()
|
||||||
corner[3].y = p2.y;
|
corner[3].y = p2.y;
|
||||||
corner[3].z = rot.y+m_segments[i+1].shift.y;
|
corner[3].z = rot.y+m_segments[i+1].shift.y;
|
||||||
|
|
||||||
|
IntColor white = IntColor(255, 255, 255, 255);
|
||||||
|
|
||||||
if (p2.y < p1.y)
|
if (p2.y < p1.y)
|
||||||
{
|
{
|
||||||
vertex[0] = { corner[1], n, { texSup.x, texSup.y } };
|
vertex[0] = { corner[1], white, { texSup.x, texSup.y } };
|
||||||
vertex[1] = { corner[0], n, { texInf.x, texSup.y } };
|
vertex[1] = { corner[0], white, { texInf.x, texSup.y } };
|
||||||
vertex[2] = { corner[3], n, { texSup.x, texInf.y } };
|
vertex[2] = { corner[3], white, { texSup.x, texInf.y } };
|
||||||
vertex[3] = { corner[2], n, { texInf.x, texInf.y } };
|
vertex[3] = { corner[2], white, { texInf.x, texInf.y } };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vertex[0] = { corner[0], n, { texSup.x, texSup.y } };
|
vertex[0] = { corner[0], white, { texSup.x, texSup.y } };
|
||||||
vertex[1] = { corner[1], n, { texInf.x, texSup.y } };
|
vertex[1] = { corner[1], white, { texInf.x, texSup.y } };
|
||||||
vertex[2] = { corner[2], n, { texSup.x, texInf.y } };
|
vertex[2] = { corner[2], white, { texSup.x, texInf.y } };
|
||||||
vertex[3] = { corner[3], n, { texInf.x, texInf.y } };
|
vertex[3] = { corner[3], white, { texInf.x, texInf.y } };
|
||||||
}
|
}
|
||||||
|
|
||||||
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertex, 4);
|
renderer->DrawParticle(PrimitiveType::TRIANGLE_STRIP, 4, vertex);
|
||||||
m_engine->AddStatisticTriangle(2);
|
m_engine->AddStatisticTriangle(2);
|
||||||
|
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
|
|
|
@ -134,7 +134,7 @@ CGL33ObjectRenderer::CGL33ObjectRenderer(CGL33Device* device)
|
||||||
// Generic buffer
|
// Generic buffer
|
||||||
glGenBuffers(1, &m_bufferVBO);
|
glGenBuffers(1, &m_bufferVBO);
|
||||||
glBindBuffer(GL_COPY_WRITE_BUFFER, m_bufferVBO);
|
glBindBuffer(GL_COPY_WRITE_BUFFER, m_bufferVBO);
|
||||||
glBufferData(GL_COPY_WRITE_BUFFER, m_bufferCapacity, nullptr, GL_STREAM_DRAW);
|
glBufferData(GL_COPY_WRITE_BUFFER, 8 * sizeof(Vertex3D), nullptr, GL_STREAM_DRAW);
|
||||||
|
|
||||||
glGenVertexArrays(1, &m_bufferVAO);
|
glGenVertexArrays(1, &m_bufferVAO);
|
||||||
glBindVertexArray(m_bufferVAO);
|
glBindVertexArray(m_bufferVAO);
|
||||||
|
@ -398,17 +398,29 @@ void CGL33ObjectRenderer::DrawObject(const CVertexBuffer* buffer)
|
||||||
|
|
||||||
void CGL33ObjectRenderer::DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices)
|
void CGL33ObjectRenderer::DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices)
|
||||||
{
|
{
|
||||||
|
DrawPrimitives(type, 1, &count, vertices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGL33ObjectRenderer::DrawPrimitives(PrimitiveType type, int drawCount, int count[], const Vertex3D* vertices)
|
||||||
|
{
|
||||||
|
m_first.resize(drawCount);
|
||||||
|
|
||||||
|
GLint offset = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < drawCount; i++)
|
||||||
|
{
|
||||||
|
m_first[i] = offset;
|
||||||
|
offset += count[i];
|
||||||
|
}
|
||||||
|
|
||||||
glBindVertexArray(m_bufferVAO);
|
glBindVertexArray(m_bufferVAO);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, m_bufferVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, m_bufferVBO);
|
||||||
|
|
||||||
size_t size = count * sizeof(Vertex3D);
|
size_t size = offset * sizeof(Vertex3D);
|
||||||
|
|
||||||
if (m_bufferCapacity < size)
|
|
||||||
m_bufferCapacity = size;
|
|
||||||
|
|
||||||
// Send new vertices to GPU
|
// Send new vertices to GPU
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, m_bufferVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, m_bufferVBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, m_bufferCapacity, nullptr, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STREAM_DRAW);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, size, vertices);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, size, vertices);
|
||||||
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D),
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D),
|
||||||
|
@ -426,5 +438,5 @@ void CGL33ObjectRenderer::DrawPrimitive(PrimitiveType type, int count, const Ver
|
||||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex3D),
|
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex3D),
|
||||||
reinterpret_cast<void*>(offsetof(Vertex3D, uv2)));
|
reinterpret_cast<void*>(offsetof(Vertex3D, uv2)));
|
||||||
|
|
||||||
glDrawArrays(TranslateGfxPrimitive(type), 0, count);
|
glMultiDrawArrays(TranslateGfxPrimitive(type), m_first.data(), count, drawCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ public:
|
||||||
virtual void DrawObject(const CVertexBuffer* buffer) override;
|
virtual void DrawObject(const CVertexBuffer* buffer) override;
|
||||||
//! Draws a primitive
|
//! Draws a primitive
|
||||||
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices) override;
|
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex3D* vertices) override;
|
||||||
|
//! Draws a set of primitives
|
||||||
|
virtual void DrawPrimitives(PrimitiveType type, int drawCount, int count[], const Vertex3D* vertices) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CGL33Device* const m_device;
|
CGL33Device* const m_device;
|
||||||
|
@ -152,8 +154,8 @@ private:
|
||||||
GLuint m_bufferVBO = 0;
|
GLuint m_bufferVBO = 0;
|
||||||
// Vertex array object
|
// Vertex array object
|
||||||
GLuint m_bufferVAO = 0;
|
GLuint m_bufferVAO = 0;
|
||||||
// VBO capacity
|
// Offsets
|
||||||
GLsizei m_bufferCapacity = 8 * sizeof(Vertex3D);
|
std::vector<GLint> m_first;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Gfx::VertexCol> debugLine;
|
std::vector<Gfx::Vertex3D> debugLine;
|
||||||
if (m_bmTotal > 0)
|
if (m_bmTotal > 0)
|
||||||
{
|
{
|
||||||
Gfx::Color color = Gfx::Color(0.0f, 1.0f, 0.0f);
|
Gfx::Color color = Gfx::Color(0.0f, 1.0f, 0.0f);
|
||||||
|
@ -101,14 +101,18 @@ bool CTaskGoto::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
if (i > m_bmIndex-1)
|
if (i > m_bmIndex-1)
|
||||||
color = Gfx::Color(1.0f, 0.0f, 0.0f);
|
color = Gfx::Color(1.0f, 0.0f, 0.0f);
|
||||||
debugLine.push_back({ AdjustPoint(m_bmPoints[i]), color });
|
|
||||||
|
auto intcolor = Gfx::ColorToIntColor(color);
|
||||||
|
|
||||||
|
debugLine.push_back({ AdjustPoint(m_bmPoints[i]), {}, intcolor });
|
||||||
}
|
}
|
||||||
m_engine->AddDebugGotoLine(debugLine);
|
m_engine->AddDebugGotoLine(debugLine);
|
||||||
debugLine.clear();
|
debugLine.clear();
|
||||||
}
|
}
|
||||||
Gfx::Color color = Gfx::Color(0.0f, 0.0f, 1.0f);
|
Gfx::Color color = Gfx::Color(0.0f, 0.0f, 1.0f);
|
||||||
debugLine.push_back({ m_object->GetPosition(), color });
|
auto pos = AdjustPoint(m_bmTotal > 0 && m_bmIndex <= m_bmTotal && m_phase != TGP_BEAMSEARCH ? m_bmPoints[m_bmIndex] : m_goal);
|
||||||
debugLine.push_back({ AdjustPoint(m_bmTotal > 0 && m_bmIndex <= m_bmTotal && m_phase != TGP_BEAMSEARCH ? m_bmPoints[m_bmIndex] : m_goal), color });
|
debugLine.push_back({ m_object->GetPosition(), {}, color });
|
||||||
|
debugLine.push_back({ pos, {}, color });
|
||||||
m_engine->AddDebugGotoLine(debugLine);
|
m_engine->AddDebugGotoLine(debugLine);
|
||||||
|
|
||||||
if (m_object->GetSelect() && m_bmChanged)
|
if (m_object->GetSelect() && m_bmChanged)
|
||||||
|
|
Loading…
Reference in New Issue