# Thread: Plot 3D : both solid fill and wireframe triangles

1. ## Plot 3D : both solid fill and wireframe triangles

Hi

I'm a newbie in OpenGL. I'm trying to create a C# library to plot (X,Y,Z) surface made from connected triangles (I just pass axis X and Y array.

My specs are:

* each triangle just use a plain color depending on their z-value (gradient: red to blue) => no lighting / shade effect.

* the resulting surface is "solid" (filled) along with its wireframe (in black).

* labeling (text and decimal) on axes shall be displayed.

Questions:

* Do you know any existing open-source implementation for .NET ?

* Do you recommand to use GL_TRIANGLE_STRIP or GL_TRIANGLES to build the surface ?

* How to both fill a triangle AND draw its black border ? I couldn't find any satisafctory answer...

Best Regards,

2. ## Re: Plot 3D : both solid fill and wireframe triangles

1. i know that there are, but i haven't used C# myself, take a look at nehe.gamedev.net, i know that there are some C# openGL examples there.

2. GL_TRIANGLES is definitely easier to use than GL_TRIANGLE_STRIP.

3. simple first draw them as solids, then draw them as wireframe, perhaps with some polygon offset if needed.

3. ## Re: Plot 3D : both solid fill and wireframe triangles

thanks zeoverlord

I'll give a try to the polygon offset because drawing polygon fill+line does not look professional at all.

http://www.opengl.org/discussion_boa...=020246#000000

but obviously there are still limitations ... so NO definitive solution to this ???

:°(

4. ## Re: Plot 3D : both solid fill and wireframe triangles

Values 1.0 1.0 seem to be good for a lot of cases.

5. ## Re: Plot 3D : both solid fill and wireframe triangles

Well thanks!

The use of glPolygonOffset(1,1) seems satisfactory at this time.

zeoverlord says that GL_TRIANGLES is definitely easier to use than GL_TRIANGLE_STRIP. Ok but what about performance in my case (solid fill + wireframe) : will it improve ?

6. ## Re: Plot 3D : both solid fill and wireframe triangles

Triangle strips can be a bit better for perf, and well suited for regular grids.
For arbitrary triangles, stay with GL_TRIANGLES for a start.

Do you have performance problems now ?
Try display lists, or VBO.

7. ## Re: Plot 3D : both solid fill and wireframe triangles

For using C# with OpenGL, you should have a look at the Tao framework. It comes with tons of examples, including a C# implementation of the NeHe tutorials.

http://www.taoframework.com/

8. ## Re: Plot 3D : both solid fill and wireframe triangles

I'll take a look at Tao : does it provide code example of efficent 3d plotting (solid fill + wireframe) ?

I got another problem : coloring the triangles. I choose to paint them each with a uniform color depending on their z-value. From blue to red - how surprising ;-)
My solution is based on a color gradient : for that the code uses the HSL color space to move the hue according to the z-value (float between 0-red and 0.666-blue). What I don't understand is that if I lower the saturation and brightness, the plot becomes completely *white* !!??!

Is that linked to the color depth associated with my opengl scene ? Am I in 256 colors only ? How can I check and how to change it ??? (I couldn't figure that out)

Best regards

9. ## Re: Plot 3D : both solid fill and wireframe triangles

>>the code uses the HSL color space to move the hue according to the z-value
Most likely you have a bug in this part of the code.

10. ## Re: Plot 3D : both solid fill and wireframe triangles

ok,

I guess by default opengl windows lib works at 24 or 32 bits color depth ?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•