18 #include "precompiled.h"
52 : m_IndexArray(GL_STATIC_DRAW), m_Array(GL_STATIC_DRAW)
54 size_t numVertices = mdef->GetNumVertices();
137 mdef->SetRenderData(
m, shadermodeldef);
204 size_t numVertices = mdef->GetNumVertices();
276 shader->VertexPointer(3, GL_FLOAT, stride, base + shadermodel->
m_Position.
offset);
279 shader->NormalPointer(GL_FLOAT, stride, base + shadermodel->
m_Normal.
offset);
282 shader->ColorPointer(3, GL_UNSIGNED_BYTE, stride, base + shadermodel->
m_Color.
offset);
284 shader->AssertPointersBound();
287 size_t numFaces = mdldef->GetNumFaces();
293 glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase);
295 pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1,
296 (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase);
void * rtl_AllocateAligned(size_t size, size_t align)
VertexArray::Attribute m_Color
static void BuildUV(const CModelDefPtr &mdef, const VertexArrayIterator< float[2]> &UV, int UVset)
BuildUV: Copy UV coordinates into the given vertex array.
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
void EndPass(int streamflags)
EndPass: Cleanup OpenGL state set up by BeginPass.
ShaderModelRendererInternals * m
void RenderModel(const CShaderProgramPtr &shader, int streamflags, CModel *model, CModelRData *data)
RenderModel: Invoke the rendering commands for the given model.
VertexArrayIterator< u16 > GetIterator() const
Gets the iterator over the (only) attribute in this array, i.e. a u16.
Internal data of the ShaderModelRenderer.
#define RENDERDATA_UPDATE_VERTICES
ShaderModel(const void *key)
VertexIndexArray m_IndexArray
Indices are the same for all models, so share them.
void AddAttribute(Attribute *attr)
VertexArray m_Array
Static per-CModelDef vertex array.
#define RENDERDATA_UPDATE_COLOR
static void BuildColor4ub(CModel *model, const VertexArrayIterator< CVector3D > &Normal, const VertexArrayIterator< SColor4ub > &Color)
BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space ...
VertexArray m_Array
Dynamic per-CModel vertex array.
VertexArray::Attribute m_Position
Position and normals/lighting are recalculated on CPU every frame.
A VertexArray that is specialised to handle 16-bit array indices.
void UpdateModelData(CModel *model, CModelRData *data, int updateflags)
UpdateModelData: Calculate per-model data for each frame.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
T round_up_to_pow2(T x)
round up to next larger power of two.
ShaderModelDef * shadermodeldef
Previously prepared modeldef.
static void BuildPositionAndNormals(CModel *model, const VertexArrayIterator< CVector3D > &Position, const VertexArrayIterator< CVector3D > &Normal)
BuildPositionAndNormals: Build animated vertices and normals, transformed into world space...
~ShaderModelVertexRenderer()
void PrepareModelDef(const CShaderProgramPtr &shader, int streamflags, const CModelDef &def)
PrepareModelDef: Setup OpenGL state for rendering of models that use the given CModelDef object as ba...
static void BuildIndices(const CModelDefPtr &mdef, const VertexArrayIterator< u16 > &Indices)
BuildIndices: Create the indices array for the given CModelDef.
void SetNumVertices(size_t num)
size_t normalsNumVertices
ShaderModelVertexRenderer(bool cpuLighting)
VertexArrayIterator< T > GetIterator() const
void BeginPass(int streamflags)
BeginPass: Setup global OpenGL state for this ModelVertexRenderer.
ShaderModelDef(const CModelDefPtr &mdef)
char * normals
Scratch space for normal vector calculation.
Class CModelRData: Render data that is maintained per CModel.
CModelRData * CreateModelData(const void *key, CModel *model)
CreateModelData: Create internal data for one model.
void rtl_FreeAligned(void *alignedPointer)
const CModelDefPtr & GetModelDef()
static void Unbind()
Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it...
VertexArray::Attribute m_Normal
shared_ptr< CShaderProgram > CShaderProgramPtr
CModelDefRPrivate * GetRenderData(const void *key) const
VertexArray::Attribute m_UV
UV coordinates are stored in the static array.
boost::shared_ptr< CModelDef > CModelDefPtr