Advertisement

GluNewtess...

Started by January 16, 2002 09:38 AM
3 comments, last by niedernsill 23 years, 1 month ago
How use the gluNewTess.. function in VB to draw complex polygon (GL_POLYGON will only render convex shapes) ? thanks
Here''s an example, but it is in C, not VB.
I''m not planning to translate it. Sorry.

  #define NB_POINTS 100GLdouble points[NB_POINTS][3] = { ... }; // Set your vertex data hereGLUtesselatorObj*	t_obj;int i;t_obj = gluNewTess(); // Create The Tesselator Objectif (t_obj == NULL) // Could we Create a Tesselator ?{ return; // If No, then Return}// Prepare the Tesselator''s Callbacks.gluTessCallback(t_obj, GLU_BEGIN, (void (*)())glBegin);gluTessCallback(t_obj, GLU_VERTEX, (void (*)())glVertex3dv); // Set the glVertex function you needgluTessCallback(t_obj, GLU_END, (void (*)())glEnd);// Begin drawinggluTessBeginPolygon(t_obj, NULL);gluTessBeginContour(t_obj);// Draw all pointsfor (i = 0; i < NB_POINTS; i++){ gluTessVertex(t_obj, points[i], points[i]); // Draw one Vertex.}// Finish drawinggluTessEndContour(t_obj); gluTessEndPolygon(t_obj);// Delete the Tesselator ObjectgluDeleteTess(t_obj);  
Advertisement
Salut et merci...

Je possède un polygone (collection de point x,y) non convexe... l''utilisation de GLU permet-ele vraiment de dessiner ce genre de polygones ?

Fallait l''dire toud''suite

Essaye plutôt ça, c''est du sur-mesure :

  // The Number of the Vertices in the Polygon.const int count = 4;// Index used to Draw the Polygon.int i;// Data to Draw. These are the Vertices 2D Coordinates.GLfloat data[count][2] ={ { -1.f, -1.f }, { 0.f, +1.f }, { 1.f, -1.f }, { 0.f,  0.f }};// Array for use in gluTessVertex().GLdouble vertex[3];// Tesselator.GLUtesselatorObj*	t_obj;t_obj = gluNewTess(); // If No, then try to Create it.if (t_obj != NULL) // Could we Create a Tesselator ?{ /**  * Prepare the Tesselator''s Callbacks.  */ gluTessCallback(t_obj, GLU_BEGIN, (void (__stdcall*)())glBegin); gluTessCallback(t_obj, GLU_VERTEX, (void (__stdcall*)())glVertex2fv); gluTessCallback(t_obj, GLU_END, (void (__stdcall*)())glEnd); /**  * Draw the 2D Polygon.  */ gluBeginPolygon(t_obj); // Begin to Draw. for  (i = 0; i < count; i++) {  vertex[0] = data[0];<br>  vertex[1] = data[1];<br>  vertex[2] = 0.;<br>  gluTessVertex(t_obj, vertex, data); // Draw one more Vertex.<br> }<br> gluEndPolygon(t_obj); // Stop Drawing.<br> /**<br>  * Delete the tesselator.<br>  */</font><br> gluDeleteTess(t_obj);<br>}  </pre></font></td></tr></table></center><!–ENDSCRIPT–><br>C''est un peu plus du C++ que du C, mais la traduction est immédiate.    
Hello, I must use VB to make a engine 3d...

How can I declare the object GLUtesslatorobj with VB ?
This code isn''t correct :
dim t_obj as GLUtesslatorobj
set t_obj = new gluNewTess

And, how coding Callback in VB. Someone can mayby Help me ?
Many thanks

This topic is closed to new replies.

Advertisement