BGE: Remove RAS_IRasterizer::IndexPrimitivesMulti()

The work that was being done in IndexPrimitiveMulti() is now done by
IndexPrimitive() and we always assume multitexture support.
This commit is contained in:
Mitchell Stokes 2015-12-06 14:35:14 -08:00
parent a4a5d85755
commit 9d03307033
13 changed files with 43 additions and 179 deletions

@ -267,7 +267,6 @@ public:
* IndexPrimitives: Renders primitives from mesh slot. * IndexPrimitives: Renders primitives from mesh slot.
*/ */
virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0; virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms) = 0;
/** /**
* IndexPrimitives_3DText will render text into the polygons. * IndexPrimitives_3DText will render text into the polygons.

@ -649,15 +649,13 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
else else
ms.m_bDisplayList = true; ms.m_bDisplayList = true;
// for text drawing using faces if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) {
if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) // for text drawing using faces
rasty->IndexPrimitives_3DText(ms, m_material); rasty->IndexPrimitives_3DText(ms, m_material);
// for multitexturing }
else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) else {
rasty->IndexPrimitivesMulti(ms);
// use normal IndexPrimitives
else
rasty->IndexPrimitives(ms); rasty->IndexPrimitives(ms);
}
rasty->PopMatrix(); rasty->PopMatrix();
} }

@ -44,7 +44,6 @@ public:
virtual void Exit()=0; virtual void Exit()=0;
virtual void IndexPrimitives(RAS_MeshSlot& ms)=0; virtual void IndexPrimitives(RAS_MeshSlot& ms)=0;
virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms)=0;
virtual void SetDrawingMode(int drawingmode)=0; virtual void SetDrawingMode(int drawingmode)=0;

@ -243,6 +243,7 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
if (ms.m_bDisplayList) { if (ms.m_bDisplayList) {
localSlot = FindOrAdd(ms); localSlot = FindOrAdd(ms);
localSlot->DrawList(); localSlot->DrawList();
if (localSlot->End()) { if (localSlot->End()) {
// save slot here too, needed for replicas and object using same mesh // save slot here too, needed for replicas and object using same mesh
// => they have the same vertexarray but different mesh slot // => they have the same vertexarray but different mesh slot
@ -250,7 +251,7 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
return; return;
} }
} }
RAS_OpenGLRasterizer::IndexPrimitives(ms); RAS_OpenGLRasterizer::IndexPrimitives(ms);
if (ms.m_bDisplayList) { if (ms.m_bDisplayList) {
@ -259,31 +260,6 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
} }
} }
void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
RAS_ListSlot* localSlot =0;
if (ms.m_bDisplayList) {
localSlot = FindOrAdd(ms);
localSlot->DrawList();
if (localSlot->End()) {
// save slot here too, needed for replicas and object using same mesh
// => they have the same vertexarray but different mesh slot
ms.m_DisplayList = localSlot;
return;
}
}
RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);
if (ms.m_bDisplayList) {
localSlot->EndList();
ms.m_DisplayList = localSlot;
}
}
bool RAS_ListRasterizer::Init(void) bool RAS_ListRasterizer::Init(void)
{ {
return RAS_OpenGLRasterizer::Init(); return RAS_OpenGLRasterizer::Init();

@ -60,7 +60,6 @@ public:
virtual ~RAS_ListRasterizer(); virtual ~RAS_ListRasterizer();
virtual void IndexPrimitives(class RAS_MeshSlot& ms); virtual void IndexPrimitives(class RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual bool Init(); virtual bool Init();
virtual void Exit(); virtual void Exit();

@ -740,14 +740,6 @@ void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
m_storage->IndexPrimitives(ms); m_storage->IndexPrimitives(ms);
} }
void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
if (ms.m_pDerivedMesh)
m_failsafe_storage->IndexPrimitivesMulti(ms);
else
m_storage->IndexPrimitivesMulti(ms);
}
void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat) void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
{ {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);

@ -186,7 +186,6 @@ public:
virtual void SwapBuffers(); virtual void SwapBuffers();
virtual void IndexPrimitives(class RAS_MeshSlot &ms); virtual void IndexPrimitives(class RAS_MeshSlot &ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms);
virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat); virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat); virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);

@ -59,16 +59,6 @@ void RAS_StorageIM::Exit()
{ {
} }
void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, false);
}
void RAS_StorageIM::IndexPrimitivesMulti(class RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, true);
}
void RAS_StorageIM::TexCoord(const RAS_TexVert &tv) void RAS_StorageIM::TexCoord(const RAS_TexVert &tv)
{ {
int unit; int unit;
@ -206,15 +196,17 @@ static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matn
return DM_DRAW_OPTION_SKIP; return DM_DRAW_OPTION_SKIP;
} }
void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms)
{
bool obcolor = ms.m_bObjectColor; bool obcolor = ms.m_bObjectColor;
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
MT_Vector4& rgba = ms.m_RGBAcolor; MT_Vector4& rgba = ms.m_RGBAcolor;
RAS_MeshSlot::iterator it; RAS_MeshSlot::iterator it;
if (ms.m_pDerivedMesh) { if (ms.m_pDerivedMesh) {
// mesh data is in derived mesh, // mesh data is in derived mesh,
current_bucket = ms.m_bucket; current_bucket = ms.m_bucket;
current_polymat = current_bucket->GetPolyMaterial(); current_polymat = current_bucket->GetPolyMaterial();
current_ms = &ms; current_ms = &ms;
@ -229,7 +221,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
this->SetCullFace(false); this->SetCullFace(false);
if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
// GetMaterialIndex return the original mface material index, // GetMaterialIndex return the original mface material index,
// increment by 1 to match what derived mesh is doing // increment by 1 to match what derived mesh is doing
current_blmat_nr = current_polymat->GetMaterialIndex()+1; current_blmat_nr = current_polymat->GetMaterialIndex()+1;
// For GLSL we need to retrieve the GPU material attribute // For GLSL we need to retrieve the GPU material attribute
@ -255,7 +247,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
for (ms.begin(it); !ms.end(it); ms.next(it)) { for (ms.begin(it); !ms.end(it); ms.next(it)) {
RAS_TexVert *vertex; RAS_TexVert *vertex;
size_t i, j, numvert; size_t i, j, numvert;
numvert = it.array->m_type; numvert = it.array->m_type;
if (it.array->m_type == RAS_DisplayArray::LINE) { if (it.array->m_type == RAS_DisplayArray::LINE) {
@ -294,10 +286,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
glNormal3fv(vertex->getNormal()); glNormal3fv(vertex->getNormal());
if (multi) TexCoord(*vertex);
TexCoord(*vertex);
else
glTexCoord2fv(vertex->getUV(0));
} }
glVertex3fv(vertex->getXYZ()); glVertex3fv(vertex->getXYZ());

@ -41,7 +41,6 @@ public:
virtual void Exit(); virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms); virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
@ -56,8 +55,6 @@ protected:
void TexCoord(const RAS_TexVert &tv); void TexCoord(const RAS_TexVert &tv);
void SetCullFace(bool enable); void SetCullFace(bool enable);
void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi);
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
public: public:

@ -56,68 +56,7 @@ void RAS_StorageVA::Exit()
{ {
} }
void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot& ms) void RAS_StorageVA::IndexPrimitives(class RAS_MeshSlot& ms)
{
static const GLsizei stride = sizeof(RAS_TexVert);
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
RAS_MeshSlot::iterator it;
GLenum drawmode;
if (!wireframe)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
// use glDrawElements to draw each vertexarray
for (ms.begin(it); !ms.end(it); ms.next(it)) {
if (it.totindex == 0)
continue;
// drawing mode
if (it.array->m_type == RAS_DisplayArray::TRIANGLE)
drawmode = GL_TRIANGLES;
else if (it.array->m_type == RAS_DisplayArray::QUAD)
drawmode = GL_QUADS;
else
drawmode = GL_LINES;
// colors
if (drawmode != GL_LINES && !wireframe) {
if (ms.m_bObjectColor) {
const MT_Vector4& rgba = ms.m_RGBAcolor;
glDisableClientState(GL_COLOR_ARRAY);
glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
}
else {
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glEnableClientState(GL_COLOR_ARRAY);
}
}
else
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
if (!wireframe) {
glTexCoordPointer(2, GL_FLOAT, stride, it.vertex->getUV(0));
if (glIsEnabled(GL_COLOR_ARRAY))
glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
}
// here the actual drawing takes places
glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
if (!wireframe) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}
}
void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms)
{ {
static const GLsizei stride = sizeof(RAS_TexVert); static const GLsizei stride = sizeof(RAS_TexVert);
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true; bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true;

@ -44,7 +44,6 @@ public:
virtual void Exit(); virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms); virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};

@ -80,7 +80,7 @@ void VBO::UpdateIndices()
&data->m_index[0], GL_STATIC_DRAW); &data->m_index[0], GL_STATIC_DRAW);
} }
void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi) void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer)
{ {
int unit; int unit;
@ -100,41 +100,32 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset); glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset);
if (multi) for (unit = 0; unit < texco_num; ++unit)
{ {
for (unit = 0; unit < texco_num; ++unit) glClientActiveTexture(GL_TEXTURE0_ARB + unit);
{ switch (texco[unit]) {
glClientActiveTexture(GL_TEXTURE0_ARB + unit); case RAS_IRasterizer::RAS_TEXCO_ORCO:
switch (texco[unit]) { case RAS_IRasterizer::RAS_TEXCO_GLOB:
case RAS_IRasterizer::RAS_TEXCO_ORCO: glEnableClientState(GL_TEXTURE_COORD_ARRAY);
case RAS_IRasterizer::RAS_TEXCO_GLOB: glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); break;
glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset); case RAS_IRasterizer::RAS_TEXCO_UV:
break; glEnableClientState(GL_TEXTURE_COORD_ARRAY);
case RAS_IRasterizer::RAS_TEXCO_UV: glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit)));
glEnableClientState(GL_TEXTURE_COORD_ARRAY); break;
glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit))); case RAS_IRasterizer::RAS_TEXCO_NORM:
break; glEnableClientState(GL_TEXTURE_COORD_ARRAY);
case RAS_IRasterizer::RAS_TEXCO_NORM: glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); break;
glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset); case RAS_IRasterizer::RAS_TEXTANGENT:
break; glEnableClientState(GL_TEXTURE_COORD_ARRAY);
case RAS_IRasterizer::RAS_TEXTANGENT: glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); break;
glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset); default:
break; break;
default:
break;
}
} }
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
else //TexFace
{
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, this->stride, this->uv_offset);
} }
glClientActiveTextureARB(GL_TEXTURE0_ARB);
if (GLEW_ARB_vertex_program) if (GLEW_ARB_vertex_program)
{ {
@ -163,7 +154,7 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
} }
} }
} }
glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0); glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
@ -206,16 +197,6 @@ void RAS_StorageVBO::Exit()
} }
void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms) void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, false);
}
void RAS_StorageVBO::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, true);
}
void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{ {
RAS_MeshSlot::iterator it; RAS_MeshSlot::iterator it;
VBO *vbo; VBO *vbo;
@ -233,6 +214,6 @@ void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
vbo->UpdateData(); vbo->UpdateData();
} }
vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer, multi); vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer);
} }
} }

@ -42,7 +42,7 @@ public:
VBO(RAS_DisplayArray *data, unsigned int indices); VBO(RAS_DisplayArray *data, unsigned int indices);
~VBO(); ~VBO();
void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi); void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer);
void UpdateData(); void UpdateData();
void UpdateIndices(); void UpdateIndices();
@ -73,7 +73,6 @@ public:
virtual void Exit(); virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms); virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
@ -89,8 +88,6 @@ protected:
std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup; std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup;
virtual void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi);
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
public: public:
void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); } void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }