Wireframe render functions for CModel and CStaticModel added
This commit is contained in:
parent
901ae6a832
commit
4cd9220763
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
enum ERenderOptions
|
enum ERenderOptions
|
||||||
{
|
{
|
||||||
|
eNoRenderOptions = 0x0,
|
||||||
eDrawWorld = 0x1,
|
eDrawWorld = 0x1,
|
||||||
eDrawWorldCollision = 0x2,
|
eDrawWorldCollision = 0x2,
|
||||||
eDrawObjects = 0x4,
|
eDrawObjects = 0x4,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CModel.h"
|
#include "CModel.h"
|
||||||
|
#include <Core/CDrawUtil.h>
|
||||||
#include <Core/CRenderer.h>
|
#include <Core/CRenderer.h>
|
||||||
#include <OpenGL/GLCommon.h>
|
#include <OpenGL/GLCommon.h>
|
||||||
|
|
||||||
|
@ -97,11 +98,11 @@ void CModel::DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet)
|
||||||
MatSet = mMaterialSets.size() - 1;
|
MatSet = mMaterialSets.size() - 1;
|
||||||
|
|
||||||
// Bind material
|
// Bind material
|
||||||
|
if ((Options & eNoMaterialSetup) == 0)
|
||||||
|
{
|
||||||
SSurface *pSurf = mSurfaces[Surface];
|
SSurface *pSurf = mSurfaces[Surface];
|
||||||
CMaterial *pMat = mMaterialSets[MatSet]->MaterialByIndex(pSurf->MaterialID);
|
CMaterial *pMat = mMaterialSets[MatSet]->MaterialByIndex(pSurf->MaterialID);
|
||||||
|
|
||||||
if ((Options & eNoMaterialSetup) == 0)
|
|
||||||
{
|
|
||||||
if ((!(Options & eEnableOccluders)) && (pMat->Options() & CMaterial::eOccluder))
|
if ((!(Options & eEnableOccluders)) && (pMat->Options() & CMaterial::eOccluder))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -121,6 +122,23 @@ void CModel::DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet)
|
||||||
mVBO.Unbind();
|
mVBO.Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModel::DrawWireframe(ERenderOptions Options, const CColor& WireColor)
|
||||||
|
{
|
||||||
|
if (!mBuffered) BufferGL();
|
||||||
|
|
||||||
|
// Set up wireframe
|
||||||
|
CDrawUtil::UseColorShader(WireColor);
|
||||||
|
Options |= eNoMaterialSetup;
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
|
||||||
|
// Draw surfaces
|
||||||
|
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||||
|
DrawSurface(Options, iSurf, 0);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
}
|
||||||
|
|
||||||
u32 CModel::GetMatSetCount()
|
u32 CModel::GetMatSetCount()
|
||||||
{
|
{
|
||||||
return mMaterialSets.size();
|
return mMaterialSets.size();
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
void ClearGLBuffer();
|
void ClearGLBuffer();
|
||||||
void Draw(ERenderOptions Options, u32 MatSet);
|
void Draw(ERenderOptions Options, u32 MatSet);
|
||||||
void DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet);
|
void DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet);
|
||||||
|
void DrawWireframe(ERenderOptions Options, const CColor& WireColor = CColor::skWhite);
|
||||||
|
|
||||||
u32 GetMatSetCount();
|
u32 GetMatSetCount();
|
||||||
u32 GetMatCount();
|
u32 GetMatCount();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CStaticModel.h"
|
#include "CStaticModel.h"
|
||||||
|
#include <Core/CDrawUtil.h>
|
||||||
#include <Core/CRenderer.h>
|
#include <Core/CRenderer.h>
|
||||||
#include <OpenGL/GLCommon.h>
|
#include <OpenGL/GLCommon.h>
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@ void CStaticModel::Draw(ERenderOptions Options)
|
||||||
|
|
||||||
// Draw IBOs
|
// Draw IBOs
|
||||||
mVBO.Bind();
|
mVBO.Bind();
|
||||||
|
glLineWidth(1.f);
|
||||||
|
|
||||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||||
{
|
{
|
||||||
|
@ -122,6 +124,7 @@ void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface)
|
||||||
if (!mBuffered) BufferGL();
|
if (!mBuffered) BufferGL();
|
||||||
|
|
||||||
mVBO.Bind();
|
mVBO.Bind();
|
||||||
|
glLineWidth(1.f);
|
||||||
if ((Options & eNoMaterialSetup) == 0) mpMaterial->SetCurrent(Options);
|
if ((Options & eNoMaterialSetup) == 0) mpMaterial->SetCurrent(Options);
|
||||||
|
|
||||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||||
|
@ -141,6 +144,23 @@ void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface)
|
||||||
mVBO.Unbind();
|
mVBO.Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CStaticModel::DrawWireframe(ERenderOptions Options, const CColor& WireColor)
|
||||||
|
{
|
||||||
|
if (!mBuffered) BufferGL();
|
||||||
|
|
||||||
|
// Set up wireframe
|
||||||
|
CDrawUtil::UseColorShader(WireColor);
|
||||||
|
Options |= eNoMaterialSetup;
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
|
||||||
|
// Draw surfaces
|
||||||
|
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||||
|
DrawSurface(Options, iSurf);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
}
|
||||||
|
|
||||||
CMaterial* CStaticModel::GetMaterial()
|
CMaterial* CStaticModel::GetMaterial()
|
||||||
{
|
{
|
||||||
return mpMaterial;
|
return mpMaterial;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
void ClearGLBuffer();
|
void ClearGLBuffer();
|
||||||
void Draw(ERenderOptions Options);
|
void Draw(ERenderOptions Options);
|
||||||
void DrawSurface(ERenderOptions Options, u32 Surface);
|
void DrawSurface(ERenderOptions Options, u32 Surface);
|
||||||
|
void DrawWireframe(ERenderOptions Options, const CColor& WireColor);
|
||||||
|
|
||||||
CMaterial* GetMaterial();
|
CMaterial* GetMaterial();
|
||||||
void SetMaterial(CMaterial *pMat);
|
void SetMaterial(CMaterial *pMat);
|
||||||
|
|
Loading…
Reference in New Issue