Changeset View
Standalone View
source/renderer/Renderer.cpp
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | CStr CRendererStatsTable::GetCellText(size_t row, size_t col) | ||||
char buf[256]; | char buf[256]; | ||||
switch(row) | switch(row) | ||||
{ | { | ||||
case Row_DrawCalls: | case Row_DrawCalls: | ||||
if (col == 0) | if (col == 0) | ||||
return "# draw calls"; | return "# draw calls"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_DrawCalls); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_DrawCalls); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_TerrainTris: | case Row_TerrainTris: | ||||
if (col == 0) | if (col == 0) | ||||
return "# terrain tris"; | return "# terrain tris"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_TerrainTris); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_TerrainTris); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_WaterTris: | case Row_WaterTris: | ||||
if (col == 0) | if (col == 0) | ||||
return "# water tris"; | return "# water tris"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_WaterTris); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_WaterTris); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_ModelTris: | case Row_ModelTris: | ||||
if (col == 0) | if (col == 0) | ||||
return "# model tris"; | return "# model tris"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_ModelTris); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_ModelTris); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_OverlayTris: | case Row_OverlayTris: | ||||
if (col == 0) | if (col == 0) | ||||
return "# overlay tris"; | return "# overlay tris"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_OverlayTris); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_OverlayTris); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_BlendSplats: | case Row_BlendSplats: | ||||
if (col == 0) | if (col == 0) | ||||
return "# blend splats"; | return "# blend splats"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_BlendSplats); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_BlendSplats); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_Particles: | case Row_Particles: | ||||
if (col == 0) | if (col == 0) | ||||
return "# particles"; | return "# particles"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_Particles); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_Particles); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_VBReserved: | case Row_VBReserved: | ||||
if (col == 0) | if (col == 0) | ||||
return "VB reserved"; | return "VB reserved"; | ||||
sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_VBMan.GetBytesReserved() / 1024); | sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_VBMan.GetBytesReserved() / 1024); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_VBAllocated: | case Row_VBAllocated: | ||||
if (col == 0) | if (col == 0) | ||||
return "VB allocated"; | return "VB allocated"; | ||||
sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_VBMan.GetBytesAllocated() / 1024); | sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_VBMan.GetBytesAllocated() / 1024); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_TextureMemory: | case Row_TextureMemory: | ||||
if (col == 0) | if (col == 0) | ||||
return "textures uploaded"; | return "textures uploaded"; | ||||
sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_Renderer.GetTextureManager().GetBytesUploaded() / 1024); | sprintf_s(buf, sizeof(buf), "%lu kB", (unsigned long)g_Renderer.GetTextureManager().GetBytesUploaded() / 1024); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
case Row_ShadersLoaded: | case Row_ShadersLoaded: | ||||
if (col == 0) | if (col == 0) | ||||
return "shader effects loaded"; | return "shader effects loaded"; | ||||
sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)g_Renderer.GetShaderManager().GetNumEffectsLoaded()); | sprintf_s(buf, sizeof(buf), "%lu", (unsigned long)g_Renderer.GetShaderManager().GetNumEffectsLoaded()); | ||||
return buf; | return buf; | ||||
Lint: CPPCheckBear (returnDanglingLifetime) Returning pointer to local variable 'buf' that will be invalid when returning. Lint: CPPCheckBear (returnDanglingLifetime): `Returning pointer to local variable 'buf' that will be invalid when returning.` | |||||
default: | default: | ||||
return "???"; | return "???"; | ||||
} | } | ||||
} | } | ||||
AbstractProfileTable* CRendererStatsTable::GetChild(size_t UNUSED(row)) | AbstractProfileTable* CRendererStatsTable::GetChild(size_t UNUSED(row)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 465 Lines • ▼ Show 20 Lines | void CRenderer::SetClearColor(SColor4ub color) | ||||
m_ClearColor[1] = float(color.G) / 255.0f; | m_ClearColor[1] = float(color.G) / 255.0f; | ||||
m_ClearColor[2] = float(color.B) / 255.0f; | m_ClearColor[2] = float(color.B) / 255.0f; | ||||
m_ClearColor[3] = float(color.A) / 255.0f; | m_ClearColor[3] = float(color.A) / 255.0f; | ||||
} | } | ||||
void CRenderer::RenderShadowMap(const CShaderDefines& context) | void CRenderer::RenderShadowMap(const CShaderDefines& context) | ||||
{ | { | ||||
PROFILE3_GPU("shadow map"); | PROFILE3_GPU("shadow map"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render shadow map"); | |||||
m->shadow.BeginRender(); | m->shadow.BeginRender(); | ||||
{ | { | ||||
PROFILE("render patches"); | PROFILE("render patches"); | ||||
glCullFace(GL_FRONT); | glCullFace(GL_FRONT); | ||||
glEnable(GL_CULL_FACE); | glEnable(GL_CULL_FACE); | ||||
m->terrainRenderer.RenderPatches(CULL_SHADOWS); | m->terrainRenderer.RenderPatches(CULL_SHADOWS); | ||||
Show All 19 Lines | void CRenderer::RenderShadowMap(const CShaderDefines& context) | ||||
m->shadow.EndRender(); | m->shadow.EndRender(); | ||||
m->SetOpenGLCamera(m_ViewCamera); | m->SetOpenGLCamera(m_ViewCamera); | ||||
} | } | ||||
void CRenderer::RenderPatches(const CShaderDefines& context, int cullGroup) | void CRenderer::RenderPatches(const CShaderDefines& context, int cullGroup) | ||||
{ | { | ||||
PROFILE3_GPU("patches"); | PROFILE3_GPU("patches"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render patches"); | |||||
#if CONFIG2_GLES | #if CONFIG2_GLES | ||||
#warning TODO: implement wireface/edged rendering mode GLES | #warning TODO: implement wireface/edged rendering mode GLES | ||||
#else | #else | ||||
// switch on wireframe if we need it | // switch on wireframe if we need it | ||||
if (m_TerrainRenderMode == WIREFRAME) | if (m_TerrainRenderMode == WIREFRAME) | ||||
{ | { | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
Show All 36 Lines | else if (m_TerrainRenderMode == EDGED_FACES) | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void CRenderer::RenderModels(const CShaderDefines& context, int cullGroup) | void CRenderer::RenderModels(const CShaderDefines& context, int cullGroup) | ||||
{ | { | ||||
PROFILE3_GPU("models"); | PROFILE3_GPU("models"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render models"); | |||||
int flags = 0; | int flags = 0; | ||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
if (m_ModelRenderMode == WIREFRAME) | if (m_ModelRenderMode == WIREFRAME) | ||||
{ | { | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
} | } | ||||
Show All 19 Lines | else if (m_ModelRenderMode == EDGED_FACES) | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void CRenderer::RenderTransparentModels(const CShaderDefines& context, int cullGroup, ETransparentMode transparentMode, bool disableFaceCulling) | void CRenderer::RenderTransparentModels(const CShaderDefines& context, int cullGroup, ETransparentMode transparentMode, bool disableFaceCulling) | ||||
{ | { | ||||
PROFILE3_GPU("transparent models"); | PROFILE3_GPU("transparent models"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render transparent models"); | |||||
int flags = 0; | int flags = 0; | ||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
// switch on wireframe if we need it | // switch on wireframe if we need it | ||||
if (m_ModelRenderMode == WIREFRAME) | if (m_ModelRenderMode == WIREFRAME) | ||||
{ | { | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | void CRenderer::ComputeRefractionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const | ||||
camera.SetProjection(scaleMat * camera.GetProjection()); | camera.SetProjection(scaleMat * camera.GetProjection()); | ||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// RenderReflections: render the water reflections to the reflection texture | // RenderReflections: render the water reflections to the reflection texture | ||||
void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | ||||
{ | { | ||||
PROFILE3_GPU("water reflections"); | PROFILE3_GPU("water reflections"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render water reflections"); | |||||
WaterManager& wm = m->waterManager; | WaterManager& wm = m->waterManager; | ||||
// Remember old camera | // Remember old camera | ||||
CCamera normalCamera = m_ViewCamera; | CCamera normalCamera = m_ViewCamera; | ||||
ComputeReflectionCamera(m_ViewCamera, scissor); | ComputeReflectionCamera(m_ViewCamera, scissor); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// RenderRefractions: render the water refractions to the refraction texture | // RenderRefractions: render the water refractions to the refraction texture | ||||
void CRenderer::RenderRefractions(const CShaderDefines& context, const CBoundingBoxAligned &scissor) | void CRenderer::RenderRefractions(const CShaderDefines& context, const CBoundingBoxAligned &scissor) | ||||
{ | { | ||||
PROFILE3_GPU("water refractions"); | PROFILE3_GPU("water refractions"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render water refractions"); | |||||
WaterManager& wm = m->waterManager; | WaterManager& wm = m->waterManager; | ||||
// Remember old camera | // Remember old camera | ||||
CCamera normalCamera = m_ViewCamera; | CCamera normalCamera = m_ViewCamera; | ||||
ComputeRefractionCamera(m_ViewCamera, scissor); | ComputeRefractionCamera(m_ViewCamera, scissor); | ||||
Show All 40 Lines | glDisable(GL_SCISSOR_TEST); | ||||
m->SetOpenGLCamera(m_ViewCamera); | m->SetOpenGLCamera(m_ViewCamera); | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||||
} | } | ||||
void CRenderer::RenderSilhouettes(const CShaderDefines& context) | void CRenderer::RenderSilhouettes(const CShaderDefines& context) | ||||
{ | { | ||||
PROFILE3_GPU("silhouettes"); | PROFILE3_GPU("silhouettes"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render water silhouettes"); | |||||
CShaderDefines contextOccluder = context; | CShaderDefines contextOccluder = context; | ||||
contextOccluder.Add(str_MODE_SILHOUETTEOCCLUDER, str_1); | contextOccluder.Add(str_MODE_SILHOUETTEOCCLUDER, str_1); | ||||
CShaderDefines contextDisplay = context; | CShaderDefines contextDisplay = context; | ||||
contextDisplay.Add(str_MODE_SILHOUETTEDISPLAY, str_1); | contextDisplay.Add(str_MODE_SILHOUETTEDISPLAY, str_1); | ||||
// Render silhouettes of units hidden behind terrain or occluders. | // Render silhouettes of units hidden behind terrain or occluders. | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | else | ||||
pglBlendColorEXT(0, 0, 0, 0); | pglBlendColorEXT(0, 0, 0, 0); | ||||
glDisable(GL_STENCIL_TEST); | glDisable(GL_STENCIL_TEST); | ||||
} | } | ||||
} | } | ||||
void CRenderer::RenderParticles(int cullGroup) | void CRenderer::RenderParticles(int cullGroup) | ||||
{ | { | ||||
PROFILE3_GPU("particles"); | PROFILE3_GPU("particles"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render particles"); | |||||
m->particleRenderer.RenderParticles(cullGroup); | m->particleRenderer.RenderParticles(cullGroup); | ||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
if (m_ModelRenderMode == EDGED_FACES) | if (m_ModelRenderMode == EDGED_FACES) | ||||
{ | { | ||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
Show All 16 Lines | #if !CONFIG2_GLES | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// RenderSubmissions: force rendering of any batched objects | // RenderSubmissions: force rendering of any batched objects | ||||
void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) | void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) | ||||
{ | { | ||||
PROFILE3("render submissions"); | PROFILE3("Render submissions"); | ||||
OGL_SCOPED_DEBUG_GROUP("Render submissions"); | |||||
GetScene().GetLOSTexture().InterpolateLOS(); | GetScene().GetLOSTexture().InterpolateLOS(); | ||||
CShaderDefines context = m->globalContext; | CShaderDefines context = m->globalContext; | ||||
int cullGroup = CULL_DEFAULT; | int cullGroup = CULL_DEFAULT; | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
▲ Show 20 Lines • Show All 686 Lines • Show Last 20 Lines |
Returning pointer to local variable 'buf' that will be invalid when returning.