2015-07-26 21:39:49 +00:00
|
|
|
#ifndef CDRAWUTIL
|
|
|
|
#define CDRAWUTIL
|
|
|
|
|
|
|
|
#include <OpenGL/CVertexBuffer.h>
|
|
|
|
#include <OpenGL/CDynamicVertexBuffer.h>
|
|
|
|
#include <OpenGL/CIndexBuffer.h>
|
|
|
|
#include <Resource/model/CModel.h>
|
2015-11-24 15:43:26 +00:00
|
|
|
#include <Resource/CLight.h>
|
2015-07-26 21:39:49 +00:00
|
|
|
|
2015-11-26 10:42:42 +00:00
|
|
|
// todo: CDrawUtil should work with CRenderer to queue primitives for rendering
|
|
|
|
// rather than trying to draw them straight away, so that CDrawUtil functions can
|
|
|
|
// be called from anywhere in the codebase and still function correctly
|
2015-07-26 21:39:49 +00:00
|
|
|
class CDrawUtil
|
|
|
|
{
|
|
|
|
// 7x7 Grid
|
|
|
|
static CVertexBuffer mGridVertices;
|
|
|
|
static CIndexBuffer mGridIndices;
|
|
|
|
|
|
|
|
// Square
|
|
|
|
static CDynamicVertexBuffer mSquareVertices;
|
|
|
|
static CIndexBuffer mSquareIndices;
|
|
|
|
|
|
|
|
// Line
|
|
|
|
static CDynamicVertexBuffer mLineVertices;
|
|
|
|
static CIndexBuffer mLineIndices;
|
|
|
|
|
|
|
|
// Cube
|
2015-12-13 20:52:17 +00:00
|
|
|
static TResPtr<CModel> mpCubeModel;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Wire Cube
|
|
|
|
static CVertexBuffer mWireCubeVertices;
|
|
|
|
static CIndexBuffer mWireCubeIndices;
|
|
|
|
|
|
|
|
// Sphere
|
2015-12-13 20:52:17 +00:00
|
|
|
static TResPtr<CModel> mpSphereModel;
|
|
|
|
static TResPtr<CModel> mpDoubleSidedSphereModel;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
2015-11-29 10:00:18 +00:00
|
|
|
// Wire Sphere
|
2015-12-13 20:52:17 +00:00
|
|
|
static TResPtr<CModel> mpWireSphereModel;
|
2015-11-29 10:00:18 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
// Shaders
|
|
|
|
static CShader *mpColorShader;
|
|
|
|
static CShader *mpColorShaderLighting;
|
2015-11-24 15:43:26 +00:00
|
|
|
static CShader *mpBillboardShader;
|
|
|
|
static CShader *mpLightBillboardShader;
|
2015-07-26 21:39:49 +00:00
|
|
|
static CShader *mpTextureShader;
|
|
|
|
static CShader *mpCollisionShader;
|
|
|
|
static CShader *mpTextShader;
|
|
|
|
|
|
|
|
// Textures
|
2015-12-13 20:52:17 +00:00
|
|
|
static TResPtr<CTexture> mpCheckerTexture;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
2015-12-13 20:52:17 +00:00
|
|
|
static TResPtr<CTexture> mpLightTextures[4];
|
|
|
|
static TResPtr<CTexture> mpLightMasks[4];
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
// Have all the above members been initialized?
|
|
|
|
static bool mDrawUtilInitialized;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void DrawGrid();
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawSquare();
|
|
|
|
static void DrawSquare(const CVector2f& TexUL, const CVector2f& TexUR, const CVector2f& TexBR, const CVector2f& TexBL);
|
|
|
|
static void DrawSquare(const float *pTexCoords);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawLine(const CVector3f& PointA, const CVector3f& PointB);
|
2015-08-24 01:03:36 +00:00
|
|
|
static void DrawLine(const CVector2f& PointA, const CVector2f& PointB);
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawLine(const CVector3f& PointA, const CVector3f& PointB, const CColor& LineColor);
|
2015-08-24 01:03:36 +00:00
|
|
|
static void DrawLine(const CVector2f& PointA, const CVector2f& PointB, const CColor& LineColor);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawCube();
|
|
|
|
static void DrawCube(const CColor& Color);
|
2015-08-24 01:03:36 +00:00
|
|
|
static void DrawCube(const CVector3f& Position, const CColor& Color);
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawShadedCube(const CColor& Color);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawWireCube();
|
|
|
|
static void DrawWireCube(const CAABox& AABox, const CColor& Color);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void DrawSphere(bool DoubleSided = false);
|
|
|
|
static void DrawSphere(const CColor& Color);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-11-29 10:00:18 +00:00
|
|
|
static void DrawWireSphere(const CVector3f& Position, float Radius, const CColor& Color = CColor::skWhite);
|
|
|
|
|
2015-11-24 15:43:26 +00:00
|
|
|
static void DrawBillboard(CTexture* pTexture, const CVector3f& Position, const CVector2f& Scale = CVector2f::skOne, const CColor& Tint = CColor::skWhite);
|
|
|
|
|
|
|
|
static void DrawLightBillboard(ELightType Type, const CColor& LightColor, const CVector3f& Position, const CVector2f& Scale = CVector2f::skOne, const CColor& Tint = CColor::skWhite);
|
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static void UseColorShader(const CColor& Color);
|
|
|
|
static void UseColorShaderLighting(const CColor& Color);
|
|
|
|
static void UseTextureShader();
|
|
|
|
static void UseTextureShader(const CColor& TintColor);
|
2015-11-26 10:42:42 +00:00
|
|
|
static void UseCollisionShader(const CColor& TintColor = CColor::skWhite);
|
2015-11-24 15:43:26 +00:00
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
static CShader* GetTextShader();
|
|
|
|
static void LoadCheckerboardTexture(u32 GLTextureUnit);
|
2015-11-24 15:43:26 +00:00
|
|
|
static CTexture* GetLightTexture(ELightType Type);
|
|
|
|
static CTexture* GetLightMask(ELightType Type);
|
2015-07-26 21:39:49 +00:00
|
|
|
static CModel* GetCubeModel();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CDrawUtil(); // Private constructor to prevent class from being instantiated
|
|
|
|
static void Init();
|
|
|
|
static void InitGrid();
|
|
|
|
static void InitSquare();
|
|
|
|
static void InitLine();
|
|
|
|
static void InitCube();
|
|
|
|
static void InitWireCube();
|
|
|
|
static void InitSphere();
|
2015-11-29 10:00:18 +00:00
|
|
|
static void InitWireSphere();
|
2015-07-26 21:39:49 +00:00
|
|
|
static void InitShaders();
|
|
|
|
static void InitTextures();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void Shutdown();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CDRAWUTIL
|
|
|
|
|