Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/HWLightingModelRenderer.cpp
Show All 12 Lines | |||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "lib/config2.h" | |||||
#include "lib/ogl.h" | #include "lib/ogl.h" | ||||
#include "lib/sysdep/rtl.h" | #include "lib/sysdep/rtl.h" | ||||
#include "maths/Vector3D.h" | #include "maths/Vector3D.h" | ||||
#include "graphics/Color.h" | #include "graphics/Color.h" | ||||
#include "graphics/LightEnv.h" | #include "graphics/LightEnv.h" | ||||
#include "graphics/Model.h" | #include "graphics/Model.h" | ||||
#include "graphics/ModelDef.h" | #include "graphics/ModelDef.h" | ||||
#include "graphics/ShaderProgram.h" | #include "graphics/ShaderProgram.h" | ||||
#include "renderer/HWLightingModelRenderer.h" | #include "renderer/HWLightingModelRenderer.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/RenderModifiers.h" | #include "renderer/RenderModifiers.h" | ||||
#include "renderer/VertexArray.h" | #include "renderer/VertexArray.h" | ||||
struct ShaderModelDef : public CModelDefRPrivate | struct ShaderModelDef : public CModelDefRPrivate | ||||
{ | { | ||||
/// Indices are the same for all models, so share them | /// Indices are the same for all models, so share them | ||||
VertexIndexArray m_IndexArray; | VertexIndexArray m_IndexArray; | ||||
/// Static per-CModelDef vertex array | /// Static per-CModelDef vertex array | ||||
VertexArray m_Array; | VertexArray m_Array; | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | void ShaderModelVertexRenderer::RenderModel(const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data) | ||||
size_t numFaces = mdldef->GetNumFaces(); | size_t numFaces = mdldef->GetNumFaces(); | ||||
if (!g_Renderer.m_SkipSubmit) | if (!g_Renderer.m_SkipSubmit) | ||||
{ | { | ||||
// Draw with DrawRangeElements where available, since it might be more efficient | // Draw with DrawRangeElements where available, since it might be more efficient | ||||
#if CONFIG2_GLES | #if CONFIG2_GLES | ||||
glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase); | glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase); | ||||
#else | #else | ||||
pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1, | glDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1, | ||||
(GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase); | (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase); | ||||
#endif | #endif | ||||
} | } | ||||
// bump stats | // bump stats | ||||
g_Renderer.m_Stats.m_DrawCalls++; | g_Renderer.m_Stats.m_DrawCalls++; | ||||
g_Renderer.m_Stats.m_ModelTris += numFaces; | g_Renderer.m_Stats.m_ModelTris += numFaces; | ||||
} | } | ||||
Wildfire Games · Phabricator