ssarangi's picture

Problem with Custom class for VBO's

Hi all,
I am trying to use a custom Vertex and Triangle class for the Vertex buffer objects however I get the error message that "The type 'GLUtils.MathUtils.Vector3f' must be a non-nullable value type in order to use it as parameter 'T2' in the generic type".
I think I am missing something simple but Vertex3f has been defined as a class and not a struct explicitly so as to allow me to extend it later by writing extension methods which I really miss with the original Vector implementation.

So assuming that I do need to use a custom class instead of the Vector3 of OpenTK, is there a way to make my class forced to be a non-nullable type ?

Thanks,

Satyajit


Comments

Comment viewing options

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

Classes contain extra information for internal use by the .Net runtime, which would cause corruption in OpenGL. This is why OpenTK asks for a value (non-nullable) type.

What you can do is make Vector3f a struct and extend it with extension methods. Take a look for Mono.SIMD for a concrete example of Vector3f implemented this way.

Who's online

There are currently 0 users and 11 guests online.