JeffM2501's picture

Really wierd problem with OpenTK.GLControl

Hello, I'm having a very strange problem with a simple app I'm trying to write.

I have gotten the GLControl to come up and draw things just fine (grid, gluSphere), camera with rotation etc...
I'm now at the point where I've written a simple Model class and an OBJ reader and am working on testing it out.
Basically, I keep a list of Vector3 objects as the list of indexed verts for the model and a list of faces that index them.

Here's the weird part.

If I attempt to grab one of the the Vector3 objects out of the list of verts, the GLControl goes POOF and gets a big red X in it.
I don't even have to use the values I get back, just as soon as I try to read from that list, I'm dead. It's making me pull my hair out.

Is there something about Vector3 that I can't use inside of a GL.Begin? Is something screwing up the context? Have I just gone insane?

The code can be found here, http://www.awesomelaser.com/3dspeeders/code/vector_list_problem_2009_04_...

Commenting out Form1.cs:159 will make it work. The obj file isn't even being used, the model class is being filled out with some sample data.

Thanks in advance for any light anyone can shed, I'm rather new to C# and it was all going fine until now :)


Comments

Comment viewing options

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

My guess is that this line throws either a NullReferenceException or an IndexOutOfRangeException.

Try inspecting the Output Window of Visual Studio - it should display any exception that occurs.

JeffM2501's picture

Yeah I thought about that, that's why I went with a static data set. The value it's asking for is in range and valid, asking for index 0 and the list has 3 elements. I don't get any exceptions at all in the debugger, just normal success messages.

-----------------
Using WGL_ARB_create_context...
success! (id: 131072)
Load extensions for OpenTK.Platform.Windows.Wgl... 60 extensions loaded in 1 ms.
Load extensions for OpenTK.Graphics.GL... 1084 extensions loaded in 282 ms.
Load extensions for OpenTK.Graphics.Glu... 58 extensions loaded in 6 ms.
-----------------

I guess I'll try it with my own structures to see if it really is the Vector3 class.

JeffM2501's picture

no I think your right now, it just wasn't where I was testing. Thanks for the pointer, I'll keep digging :)

*edit*
I found it, I am an idiot twice over, thank you for putting up with me :)

the Fiddler's picture

Hey no prob, glad you solved it! ;)