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

fixed vertex-decl for GLPrimitive refs #1231

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15831 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f2503db0
......@@ -40,6 +40,9 @@
* *
\*===========================================================================*/
#include <iostream>
#include <stdio.h>
#include "GLPrimitives.hh"
#include <ACG/GL/IRenderer.hh>
......@@ -59,9 +62,15 @@ GLPrimitive::GLPrimitive() :
vbo_(0)
{
vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION);
vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_NORMAL);
vertexDecl_.addElement(GL_FLOAT, 2, VERTEX_USAGE_TEXCOORD);
VertexElement elemArray[] = { {GL_FLOAT, 3, VERTEX_USAGE_POSITION, 0, {0} },
{GL_FLOAT, 3, VERTEX_USAGE_NORMAL, 0, {12} },
{GL_FLOAT, 2, VERTEX_USAGE_TEXCOORD, 0, {24} }};
vertexDecl_.addElements(3, elemArray);
// vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION);
// vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_NORMAL);
// vertexDecl_.addElement(GL_FLOAT, 2, VERTEX_USAGE_TEXCOORD);
}
//------------------------------------------------------------------------
......@@ -127,6 +136,7 @@ void GLPrimitive::bindVBO()
//------------------------------------------------------------------------
bool GLPrimitive::checkVBO()
{
// create vbo if not done yet
......@@ -142,6 +152,7 @@ bool GLPrimitive::checkVBO()
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, numTris_ * 3 * 8 * 4, vboData_, GL_STATIC_DRAW_ARB);
delete[] vboData_;
vboData_ = 0;
} else if (vboDataInvalid_) {
......@@ -186,6 +197,7 @@ void GLPrimitive::addToRenderer( class IRenderer* _renderer, RenderObject* _ro )
_ro->glDrawArrays(GL_TRIANGLES, 0, getNumTriangles() * 3);
_renderer->addRenderObject(_ro);
}
}
......
......@@ -272,7 +272,7 @@ void VertexDeclaration::activateShaderPipeline(GLSL::Program* _prog) const
unsigned int numElements = getNumElements();
unsigned int vertexStride = getVertexStride();
for (unsigned int i = 0; i < numElements; ++i)
for (unsigned int i = 0; i < 1; ++i)
{
const VertexElement* pElem = &elements_[i];
......@@ -291,7 +291,6 @@ void VertexDeclaration::activateShaderPipeline(GLSL::Program* _prog) const
glEnableVertexAttribArray(loc);
}
}
}
......@@ -390,6 +389,7 @@ QString VertexDeclaration::toString() const
<< " - [type: " << typeString
<< ", count: " << el->numElements_
<< ", usage: " << usage
<< ", shader-input: " << el->shaderInputName_
<< ", offset: " << el->byteOffset_ << "]\n";
}
......
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