Archived

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

niedernsill

GluNewtess...

Recommended Posts

Here''s an example, but it is in C, not VB.
I''m not planning to translate it. Sorry.

  
#define NB_POINTS 100
GLdouble points[NB_POINTS][3] = { ... }; // Set your vertex data here

GLUtesselatorObj* t_obj;
int i;
t_obj = gluNewTess(); // Create The Tesselator Object

if
(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 need

gluTessCallback(t_obj, GLU_END, (void (*)())glEnd);
// Begin drawing

gluTessBeginPolygon(t_obj, NULL);
gluTessBeginContour(t_obj);
// Draw all points

for
(i = 0; i < NB_POINTS; i++)
{
gluTessVertex(t_obj, points[i], points[i]); // Draw one Vertex.

}
// Finish drawing

gluTessEndContour(t_obj);
gluTessEndPolygon(t_obj);
// Delete the Tesselator Object

gluDeleteTess(t_obj);

Share this post


Link to post
Share on other sites
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[i][0];
vertex[1] = data[i][1];
vertex[2] = 0.;
gluTessVertex(t_obj, vertex, data[i]); // Draw one more Vertex.
}
gluEndPolygon(t_obj); // Stop Drawing.
/**
* Delete the tesselator.
*/

gluDeleteTess(t_obj);
}

C''est un peu plus du C++ que du C, mais la traduction est immédiate.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites