Archived

This topic is now archived and is closed to further replies.

HanSoloCL

glDrawElements in OOP

Recommended Posts

HanSoloCL    122
my DrawObject Class looks like this: class BaseObject { public: BaseObject(); virtual ~BaseObject(); arrayVEC_31D *vertexArray; arrayVEC_31D *normalArray; arrayVEC_31D *texcoordArray; arrayVEC_31D *colorArray; indexArray *vertexIndicies; unsigned int vertCount; unsigned int indexCount; void setactive(void); bool Draw(void); }; the array look like this: typedef class _indexArray { public: _indexArray(){}; virtual ~_indexArray() { delete [] indicies; }; GLenum mode; int count; unsigned int *indicies; }indexArray; typedef class ArrayVEC_31D { public: ArrayVEC_31D(unsigned int dim) { count=dim; array=new vec_3[dim]; }; virtual ~ArrayVEC_31D() { delete [] array; }; unsigned int count; vec_3 *array; }arrayVEC_31D; so... in my main programm i initialize a okject tri with vertex data... with the setactive method i set glEnableClientState(GL_VERTEX_ARRAY) and the vertexPointer... the draw method looks like this: bool BaseObject::Draw(void) { for (int i=0;i.mode,vertexIndicies[i].count,GL_UNSIGNED_BY TE,vertexIndicies[i].indicies); } return TRUE; } my main drawscene looks like this: bool neXt_MainFrame::DrawScene(void) { glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); glTranslatef(0.0f,0.0f,-7.0f); glRotatef(testrot,0.0f,0.0f,1.0f); ///test tri.InitTri(); tri.setactive(); for (unsigned int i=0;i<tri.indexCount;i++) glDrawElements(tri.vertexIndicies[i].mode,tri.vertexIndicies[i].count,GL_UNS IGNED_INT,tri.vertexIndicies[i].indicies); /*tri.Draw();*/ <------------------------------My Problem testrot+=1.0f;///test glPopMatrix(); return TRUE; } tri is a object from BaseObject. if i do the drawing with the for loop in the drawscene the triangle is drawn. if i do the drawing with tri.Draw() nothing is drawn. i dont understand why, because the for loop is the same as in the Draw() method. if anybody has experience with this... please help.. Christoph

Share this post


Link to post
Share on other sites
sjelkjd    171
shouldn''t this:
glDrawElements(vertexIndicies.mode,vertexIndicies.count,GL_UNSIGNED_BY
TE,vertexIndicies[i].indicies);

be this:
glDrawElements(vertexIndicies[i].mode,vertexIndicies[i].count,GL_UNSIGNED_BY
TE,vertexIndicies[i].indicies);

Share this post


Link to post
Share on other sites
HanSoloCL    122
yes of course... its ist indexVerticies.... only a failure in the posting.. in my programm it is [i]... has anybody a clue how i can make this work?

Christoph

Share this post


Link to post
Share on other sites