zalayeto's picture

Drawing 3D


I'm new with OpenTK. I'm just starting to work with it so i'm trying to draw simple objects. I don't have any problems drawing 2d objects, but now i want to create a cone and i don't have any idea how to do it, can anyone help me ?

I've found the function Cylinder in OpenTK.Graphics.Glu but i'm not able to draw anything with it.

I was looking at docs, searching in the forum but i haven't found anything that can help me




Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
james_lohr's picture

Hi David,

OpenTK just wraps OpenGL, which certainly has the capability to render all sorts of shapes. However, what it is not is a graphics engine with a library of pre-made primitives. It has all the tools to create an engine, but you'll have to either do this yourself or use some other library on top of it if you want to hit the ground running. Glu (which is what you have found) provides a few utilities which might help you along the way, but they are not particularly useful in generating an interesting 3d environment.

If you want to render 3d objects, you'll either have to generate them procedurally, or load them as models.

For example, procedurally generating a cone is trivial: you can use z = r*cos(theta), x = r*sin(theta) to calculate the points in the base, and then use a triangle fan starting at the point of the code to render the surface.

If you want to be able to use OpenTK to render a 3D scene, then you're simply going to have to learn OpenGL. A good place to start is the NeHe tutorials: