mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-11 06:27:45 +00:00
Render skyboxes with rotation-only view matrix, a few new CDrawUtil overloads, other rendering tweaks
This commit is contained in:
@@ -97,6 +97,12 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB)
|
||||
DrawLine(PointA, PointB, CColor::skWhite);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB)
|
||||
{
|
||||
// Overload for 2D lines
|
||||
DrawLine(CVector3f(PointA.x, PointA.y, 0.f), CVector3f(PointB.x, PointB.y, 0.f), CColor::skWhite);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const CColor& LineColor)
|
||||
{
|
||||
Init();
|
||||
@@ -116,6 +122,12 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const
|
||||
mLineVertices.Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB, const CColor& LineColor)
|
||||
{
|
||||
// Overload for 2D lines
|
||||
DrawLine(CVector3f(PointA.x, PointA.y, 0.f), CVector3f(PointB.x, PointB.y, 0.f), LineColor);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawCube()
|
||||
{
|
||||
Init();
|
||||
@@ -129,6 +141,14 @@ void CDrawUtil::DrawCube(const CColor& Color)
|
||||
DrawCube();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawCube(const CVector3f& Position, const CColor& Color)
|
||||
{
|
||||
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position).ToMatrix4f();
|
||||
CGraphics::UpdateMVPBlock();
|
||||
UseColorShader(Color);
|
||||
DrawCube();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawShadedCube(const CColor& Color)
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -54,9 +54,12 @@ public:
|
||||
static void DrawSquare(const CVector2f& TexUL, const CVector2f& TexUR, const CVector2f& TexBR, const CVector2f& TexBL);
|
||||
static void DrawSquare(const float *pTexCoords);
|
||||
static void DrawLine(const CVector3f& PointA, const CVector3f& PointB);
|
||||
static void DrawLine(const CVector2f& PointA, const CVector2f& PointB);
|
||||
static void DrawLine(const CVector3f& PointA, const CVector3f& PointB, const CColor& LineColor);
|
||||
static void DrawLine(const CVector2f& PointA, const CVector2f& PointB, const CColor& LineColor);
|
||||
static void DrawCube();
|
||||
static void DrawCube(const CColor& Color);
|
||||
static void DrawCube(const CVector3f& Position, const CColor& Color);
|
||||
static void DrawShadedCube(const CColor& Color);
|
||||
static void DrawWireCube();
|
||||
static void DrawWireCube(const CAABox& AABox, const CColor& Color);
|
||||
|
||||
@@ -126,6 +126,7 @@ void CRenderer::RenderBuckets(CCamera& Camera)
|
||||
{
|
||||
if (!mInitialized) Init();
|
||||
mSceneFramebuffer.Bind();
|
||||
Camera.LoadMatrices();
|
||||
|
||||
// Set backface culling
|
||||
if (mOptions & eEnableBackfaceCull) glEnable(GL_CULL_FACE);
|
||||
@@ -250,21 +251,18 @@ void CRenderer::RenderBloom()
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void CRenderer::RenderSky(CModel *pSkyboxModel, CVector3f CameraPosition)
|
||||
void CRenderer::RenderSky(CModel *pSkyboxModel, CCamera& Camera)
|
||||
{
|
||||
if (!mInitialized) Init();
|
||||
|
||||
if (!pSkyboxModel) return;
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
Camera.LoadRotationOnlyMatrices();
|
||||
|
||||
CTransform4f ModelMtx;
|
||||
ModelMtx.Translate(CameraPosition);
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = ModelMtx.ToMatrix4f();
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
CGraphics::UpdateVertexBlock();
|
||||
CGraphics::UpdatePixelBlock();
|
||||
CGraphics::UpdateLightBlock();
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
// Render
|
||||
void RenderBuckets(CCamera& Camera);
|
||||
void RenderBloom();
|
||||
void RenderSky(CModel *pSkyboxModel, CVector3f CameraPosition);
|
||||
void RenderSky(CModel *pSkyboxModel, CCamera& Camera);
|
||||
void AddOpaqueMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void AddTransparentMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void BeginFrame();
|
||||
|
||||
Reference in New Issue
Block a user