Advertisement

glDrawElements in OOP

Started by March 16, 2001 04:53 AM
2 comments, last by HanSoloCL 23 years, 8 months ago
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.count,GL_UNSIGNED_BY TE,vertexIndicies.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&lt;tri.indexCount;i++) glDrawElements(tri.vertexIndicies.mode,tri.vertexIndicies.count,GL_UNS IGNED_INT,tri.vertexIndicies.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 </i>
shouldn''t this:
glDrawElements(vertexIndicies.mode,vertexIndicies.count,GL_UNSIGNED_BY
TE,vertexIndicies.indicies);<br><br>be this:<br>glDrawElements(vertexIndicies.mode,vertexIndicies.count,GL_UNSIGNED_BY<br>TE,vertexIndicies.indicies);<br> </i>
Advertisement
yes of course... its ist indexVerticies.... only a failure in the posting.. in my programm it is … has anybody a clue how i can make this work?<br><br>Christoph </i>
ok ok ok.... i git it... i dit GL_UNSIGNED_BYTE in the draw method... it must have been GL_UNSIGNED_INT

This topic is closed to new replies.

Advertisement