Commit bbe8a03c authored by Christopher Tenter's avatar Christopher Tenter
Browse files

support for immediate mode in new renderer

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15868 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d8b9536f
......@@ -159,10 +159,44 @@ void RenderObject::setMaterial( const SceneGraph::Material* _mat )
RenderObject::RenderObject()
: priority(0),
vertexBuffer(0), indexBuffer(0), sysmemIndexBuffer(0),
primitiveMode(GL_TRIANGLES), numIndices(0), indexOffset(0), indexType(GL_UNSIGNED_INT),
vertexDecl(0),
culling(true), blending(false), alphaTest(false),
depthTest(true), depthWrite(true),
fillMode(GL_FILL), depthFunc(GL_LESS),
blendSrc(GL_SRC_ALPHA), blendDest(GL_ONE_MINUS_SRC_ALPHA),
depthRange(0.0f, 1.0f),
diffuse(0.6f, 0.6f, 0.6f), ambient(0.1f, 0.1f, 0.1f),
specular(0.0f, 0.0f, 0.0f), emissive(0.05f, 0.05f, 0.05f),
alpha(1.0f), shininess(100.0f),
texture(0),
debugID(0), debugName(0),
internalFlags_(0)
{
memset(this, 0, sizeof(RenderObject));
// set modelview and proj to identity
float I[16] = {1.0f, .0f, .0f, .0f,
.0f, 1.0f, .0f, .0f,
.0f, .0f, 1.0f, .0f,
.0f, .0f, .0f, 1.0f};
modelview = GLMatrixf(I);
proj = modelview;
memset(&shaderDesc, 0, sizeof(shaderDesc));
colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1;
}
void RenderObject::executeImmediateMode()
{
// implemented by deriving class
}
QString RenderObject::toString() const
{
......
......@@ -269,6 +269,14 @@ struct ACGDLLEXPORT RenderObject
void setupShaderGenFromDrawmode(const SceneGraph::DrawModes::DrawModeProperties* _props);
/** \brief Whenever the need for glBegin() glEnd() immediate mode arises,
this can be implemented by a deriving class of RenderObject.
Also it gets called only if numIndices is set to 0.
glBegin and glEnd have to be called in here.
*/
virtual void executeImmediateMode();
/** Returns a text representation of the RenderObject for debugging purposes.
*/
QString toString() const;
......
......@@ -368,29 +368,37 @@ void Renderer::bindObjectRenderStates(ACG::RenderObject* _obj)
void Renderer::drawObject(ACG::RenderObject* _obj)
{
// indexed drawing?
bool noIndices = true;
if (_obj->indexBuffer || _obj->sysmemIndexBuffer)
noIndices = false;
if (_obj->numIndices)
{
// indexed drawing?
bool noIndices = true;
if (_obj->indexBuffer || _obj->sysmemIndexBuffer)
noIndices = false;
glPolygonMode(GL_FRONT_AND_BACK, _obj->fillMode);
glPolygonMode(GL_FRONT_AND_BACK, _obj->fillMode);
if (noIndices)
glDrawArrays(_obj->primitiveMode, _obj->indexOffset, _obj->numIndices);
else
{
// ------------------------------------------
// index offset stuff not tested
int indexSize = 0;
switch (_obj->indexType)
if (noIndices)
glDrawArrays(_obj->primitiveMode, _obj->indexOffset, _obj->numIndices);
else
{
case GL_UNSIGNED_INT: indexSize = 4; break;
case GL_UNSIGNED_SHORT: indexSize = 2; break;
default: indexSize = 1; break;
}
// ------------------------------------------
// index offset stuff not tested
int indexSize = 0;
switch (_obj->indexType)
{
case GL_UNSIGNED_INT: indexSize = 4; break;
case GL_UNSIGNED_SHORT: indexSize = 2; break;
default: indexSize = 1; break;
}
glDrawElements(_obj->primitiveMode, _obj->numIndices, _obj->indexType,
((const char*)_obj->sysmemIndexBuffer) + _obj->indexOffset * indexSize);
glDrawElements(_obj->primitiveMode, _obj->numIndices, _obj->indexType,
((const char*)_obj->sysmemIndexBuffer) + _obj->indexOffset * indexSize);
}
}
else
{
// user defined draw-call
_obj->executeImmediateMode();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment