erkisnotgod's picture

Need help with Teapot program (Newbie to OpenTK )

I'm trying to access the teapot functionality as this is part of my class assignment.
I have tries making calls to the LoadAll(), but still cannot find how to render a teapot.

Can someone point me in the right direction?

Thanks!


Comments

Comment viewing options

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

By teapot, I assume you're referring to glutSolidTeapot()?

Unfortunately, glutSolidTeapot() is part of GLUT -- which OpenTK doesn't wrap. Therefore, that functionality isn't available.

You could duplicate the functionality by downloading the model and writing a file loader for it. This may seem daunting, but if it's for a class then this is probably a great way to learn.

Feel free to ask questions.

erkisnotgod's picture

Good info!
I understand the vertices given, but what are these refering to, before the given vertices?
Rim:
{ 102, 103, 104, 105, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15 }
Body:
{ 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27 }
{ 24, 25, 26, 27, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40 }
Lid:
{ 96, 96, 96, 96, 97, 98, 99, 100,
101, 101, 101, 101, 0, 1, 2, 3 }
{ 0, 1, 2, 3, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117 }
Handle:
{ 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56 }
{ 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 28, 65, 66, 67 }
Spout:
{ 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83 }
{ 80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95 }

reibisch's picture

My apologies, that's the standard patch data for the teapot. You'd need to tesselate that to get your triangle data.

I'm sure Google will turn up a version of the teapot that uses triangles :)

reibisch's picture

Tutorial 14 on this page has the triangle data encoded into a .c file. You should be able to extract the vertex/connectivity data from that easily enough.

Sorry about the mixup on the patch data.

the Fiddler's picture

OpenTK doesn't wrap GLUT but that doesn't mean you cannot DllImport glutSolidTeapot yourself from a native GLUT implementation (like freeglut).

erkisnotgod's picture

Almost there.
I was looking at the DllImport earlier, but for the life of me couldn't find the dll name to import.
Thanks for all the great help!

erkisnotgod's picture

Well that didn't work very well.
I get one of two things:
1) glControl window is white with a red frame and diagonals from each corner.
2) The form opens flickers a few times and then exits without errors. With this in mind, if only one call is performed to the teapot I get a solid black window.

I have done a few other simpleprograms with OpenTK to get the hange of it and those are working ok.
Is there a special interface of some sort I'm overlooking between the glControl and what the glutSolidTeapot is tring to do?

jrwatts's picture

IIRC, you need to initialize GLUT before you can use any of its functions, so you'll need to DllImport and call that function, too (I don't recall the exact name off the top of my head).

Edit: glutInit is the function you want.