
OpenGL tessellator
Posted Thursday, 17 January, 2008 - 14:44 by Anonymous inHello Everybody,
I'm quite new to OpenGL, but I need to use its tessellation algorithm to retrieve the resulting triangles.
I've seen that OpenTK contains the tessellation class but being completely new to the toolkit I'm having problems to understand what to do and I couldn't find any sample.
Yesterday i spent some time trying to do the same with the TaoFramework only to discover that their implementation is bugged.
Forgive me if the problem sounds silly.
What I'm now trying to achieve is really simple (to describe).
Eventually I'll need to tessellate a polygon with a hole inside but for the moment a simple rectangle tessellation would be ok.
Apparently i should use something like
Dim rect As Double()() = New Double(4)() {New Double() {50, 50, 0}, New Double() {200, 50, 0}, New Double() {200, 200, 0}, New Double() {50, 200, 0}, New Double() {0, 125, 0}} Dim mydata As IntPtr = IntPtr.Zero Dim mycallback As IntPtr Dim t As Integer = OpenTK.OpenGL.Glu.NewTes() OpenTK.OpenGL.Glu.TessCallback(t, OpenTK.OpenGL.Enums.TessCallback.End, mycallback) OpenTK.OpenGL.Glu.BeginPolygon(t) OpenTK.OpenGL.Glu.TessBeginContour(t) OpenTK.OpenGL.Glu.TessVertex(t, rect(0), mydata) OpenTK.OpenGL.Glu.TessVertex(t, rect(1), mydata) OpenTK.OpenGL.Glu.TessVertex(t, rect(2), mydata) OpenTK.OpenGL.Glu.TessVertex(t, rect(3), mydata) OpenTK.OpenGL.Glu.TessEndContour(t) OpenTK.OpenGL.Glu.EndPolygon(t)
But what kind of of structure should be behind the two IntPtr's?
I don't need to display the resulting triangles but to retrieve a list of them along with vertex coordinates.
Please note that although I'm patching a VB application any c# code will be ok for me.
Any help will be highly appreciated,
Claudio


Comments
Re: OpenGL tessellator
The Glu tesselator does in fact work, and I very happy to finally have a fully functional triangulation program in C#.
The Tao project attempted to bind the tesselator, but it crashes with an access violation. Even their sample program!
If anyone is interested I'd be willing to share some code. Otherwise, I have posted a few additional (and hopefully helpful) comments on Fiddler's post on the 0.9.1 progress update here:
http://www.opentk.com/news/0.9.1_progress_on_glu_tesselation#attachments
Re: OpenGL tessellator
Some working Glu tesselator sample would be appreciated, adding a tutorial for it is on the todo-list for 0.9.2
Re: OpenGL tessellator
Here is my implementation of a triangulation class using the OpenTK Glu bindings; I hope someone finds it useful.
It should be able to be ported to any C# project with little to no modification. Anyone who wishes to use it can do so freely.
-Justin Nordin
Re: OpenGL tessellator
We have a complete port of the GLU tesselator from mesa to unmanaged c#.
You can find it in the SVN repository at:
https://sourceforge.net/projects/agg-sharp
I am currently planing on using OpenTK for our hardware abstraction layer.