sharoz's picture

Vector[234]i

I would like to request an integer version of the vector struct: OpenTK.Math.Vector[234]i

This class would create a more safe way to store int[234] shader variables compared with using an array.

Here are the replacements to make in the vector struct
Vector2 -> Vector2i
Vector3 -> Vector3i
Vector4 -> Vector4i
float -> int;
f (match whole word) -> i (be careful here because divide, length, and normalize need to be changed)

A related request is to add versions of GL.Uniform that take a vector[234]? and know how many dimensions are present. For example, GL.Uniform(int location, Vector2) would call GL.Uniform2(int location, float v0, float v1). At least make GL.Uniform2 accept a Vector2.

If these features are agreed to, I don't mind implementing them.

-sharoz


Comments

Comment viewing options

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

GL.Uniform[234] already provide overloads for Vector[234] (maybe you are using an old OpenTK version?)

While I don't feel comfortable adding full-fledged integer types to OpenTK.Math, I wouldn't object to structs that mimic Vector[234]h. The latter provides storage and conversion operators only, without any math functions - ideal for passing vertex data.

If you are interested in implementing this, please open an issue report ('feature request', '0.9.x-dev') and create a patch against the latest SVN trunk (you can use TortoiseSVN to create patches). Because trunk is a moving target and may change at any time, consider creating two separate patches: one to add Vector[234]i structs to OpenTK/Math and one to add overloads to OpenTK/Graphics/GL/GLHelper.cs.

sharoz's picture

You're right about GL.Uniform. I only checked the new version for a Vector[234]i.

I agree with your point about not implementing all the math for the integer vector. I really just a want a consistent way to store and pass the integer and float uniforms. I didn't realize that Vector[234]h was a minimal implementation.

Here's the issue request - #1001: Add Vector[234]i structs