2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-18 02:42:32 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "zeus/CVector3f.hpp"
|
2017-04-22 21:46:18 +00:00
|
|
|
#include "zeus/CVector4f.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "zeus/CColor.hpp"
|
2016-02-18 02:42:32 +00:00
|
|
|
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
2017-04-22 21:46:18 +00:00
|
|
|
#include "hecl/VertexBufferPool.hpp"
|
|
|
|
#include "hecl/UniformBufferPool.hpp"
|
2016-02-18 02:42:32 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2016-02-18 02:42:32 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
class CLineRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class EPrimitiveMode
|
|
|
|
{
|
|
|
|
Lines,
|
|
|
|
LineStrip,
|
|
|
|
LineLoop
|
|
|
|
};
|
|
|
|
|
2017-04-22 21:46:18 +00:00
|
|
|
struct SDrawVertTex
|
|
|
|
{
|
|
|
|
zeus::CVector4f pos;
|
|
|
|
zeus::CColor color;
|
|
|
|
zeus::CVector2f uv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SDrawVertNoTex
|
|
|
|
{
|
|
|
|
zeus::CVector4f pos;
|
|
|
|
zeus::CColor color;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SDrawUniform
|
|
|
|
{
|
|
|
|
zeus::CColor moduColor;
|
|
|
|
};
|
|
|
|
|
2016-02-18 07:56:14 +00:00
|
|
|
private:
|
2016-02-18 02:42:32 +00:00
|
|
|
EPrimitiveMode m_mode;
|
|
|
|
u32 m_maxVerts;
|
|
|
|
u32 m_nextVert = 0;
|
|
|
|
bool m_final = false;
|
|
|
|
bool m_textured;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CVector3f m_firstPos;
|
|
|
|
zeus::CVector3f m_secondPos;
|
|
|
|
zeus::CVector2f m_firstUV;
|
|
|
|
zeus::CColor m_firstColor;
|
2016-02-18 02:42:32 +00:00
|
|
|
float m_firstWidth;
|
2018-06-24 01:01:29 +00:00
|
|
|
float m_firstW;
|
2016-02-18 02:42:32 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CVector3f m_lastPos;
|
|
|
|
zeus::CVector3f m_lastPos2;
|
|
|
|
zeus::CVector2f m_lastUV;
|
|
|
|
zeus::CColor m_lastColor;
|
2016-02-18 02:42:32 +00:00
|
|
|
float m_lastWidth;
|
2018-06-24 01:01:29 +00:00
|
|
|
float m_lastW;
|
2016-02-18 02:42:32 +00:00
|
|
|
|
2018-01-15 07:39:25 +00:00
|
|
|
static rstl::reserved_vector<SDrawVertTex, 1024> g_StaticLineVertsTex;
|
|
|
|
static rstl::reserved_vector<SDrawVertNoTex, 1024> g_StaticLineVertsNoTex;
|
2017-04-22 21:46:18 +00:00
|
|
|
|
|
|
|
static hecl::VertexBufferPool<SDrawVertTex> s_vertPoolTex;
|
|
|
|
static hecl::VertexBufferPool<SDrawVertNoTex> s_vertPoolNoTex;
|
|
|
|
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
|
|
|
|
|
2016-02-18 02:42:32 +00:00
|
|
|
public:
|
2017-04-22 21:46:18 +00:00
|
|
|
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
|
|
|
|
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
|
|
|
|
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IShaderDataBinding> m_shaderBind;
|
2016-02-18 02:42:32 +00:00
|
|
|
|
2017-04-22 06:42:32 +00:00
|
|
|
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
|
2018-05-08 05:10:24 +00:00
|
|
|
EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture,
|
2018-05-20 06:14:57 +00:00
|
|
|
bool additive, bool zTest = false, bool zGEqual = false);
|
2018-05-08 05:10:24 +00:00
|
|
|
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture,
|
2018-05-20 06:14:57 +00:00
|
|
|
bool additive, bool zTest = false, bool zGEqual = false);
|
2017-04-22 06:42:32 +00:00
|
|
|
CLineRenderer(CLineRenderer&&) = default;
|
2016-02-18 02:42:32 +00:00
|
|
|
|
|
|
|
void Reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
void AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
|
|
|
|
const zeus::CVector2f& uv=zeus::CVector2f::skZero);
|
|
|
|
void Render(const zeus::CColor& moduColor=zeus::CColor::skWhite);
|
2016-02-18 02:42:32 +00:00
|
|
|
|
2017-04-22 21:46:18 +00:00
|
|
|
static void UpdateBuffers()
|
|
|
|
{
|
|
|
|
s_vertPoolTex.updateBuffers();
|
|
|
|
s_vertPoolNoTex.updateBuffers();
|
|
|
|
s_uniformPool.updateBuffers();
|
|
|
|
}
|
|
|
|
|
2016-02-18 02:42:32 +00:00
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|