lid6j86's picture

Correct operations to use?

There has been a lot that's depreciated. It's sort of confusing as to what's suppossed to be used. Here's my question:

Are there any functions in OpenTK that are forward compatible that I can use for matrix manipulation, or do I have to make my own to be forward compatible? Also, one more question to that: If I remember correctly, OpenTK holds matricies in Row-Major format, and OpenGL is column-major, correct? So I should adjust for this in making my functions?

What I mean is I see examples for using Vector4.Translate , Matrix4.CreateTranslation,. and that also includes for rotation, etc... I know that the GL.Translate says in the notes 'depreciated', Matrix4.Translation says 'depreciated', but what about the ones that don't say that? are any of those now depreciated? which is a better route to take?

Thanks


Comments

Comment viewing options

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

Good question, lid6j86. Just yesterday I was wondering a bit about this.

It does seem like there's a plan for intended use of the Matrix4 classes, but I'm not 100% sure what it is. These are a few things I've gleaned:

http://www.opentk.com/doc/chapter/2/rules_of_thumb
This document suggests using the static methods for operations- specifically here pass by reference. So for Matrix4, there's Matrix4.Mult().

Rather than Matrix4.Translation, create two matricies and multiply them together. ( http://www.opentk.com/node/2003 )

OpenTK.Matrix4 r = OpenTK.Matrix4.CreateRotationY(angle);
OpenTK.Matrix4 t = OpenTK.Matrix4.CreateTranslation(1, 0, 0);
Matrix4.Mult(ref r, ref 5);

One plus of this approach is that it helps you understand matrix math pretty easily. Basically, you can apply multiple transformations in order by multiplying two transformation matrices together. So I think that's a good call in terms of the API.

Regarding GL.Translate and the other GL matrix manipulation functions... They were deprecated in the opengl spec: "The function glTranslatef was marked as deprecated in OpenGL version 3.0 and was removed from OpenGL at version 3.1.
It is recommended to avoid using deprecated functions, as their compatibility with future OpenGL versions is not assured." and perhaps more importantly, they aren't included in OpenGL ES 2.0. Fortunately, we have support for matrices in openTK, so we aren't on our own here.

Regarding row vs. column major matrices... I guess stick to what is being done with the existing Matrix classes. I think there was someone somewhere (looked for 15 minutes but couldn't find it) who switched the matrix classes row/column major. But I personally wouldn't mess with it. OpenTK makes sure everything is correct when it sends it to openGL.