flyx / OpenGLAda

Thick Ada binding for OpenGL and GLFW
flyx.github.io/OpenGLAda/
MIT License
95 stars 13 forks source link

Vector 5 arrays #68

Closed rogermc2 closed 7 years ago

rogermc2 commented 7 years ago

Some examples use arrays of vector 5 singles. 3 elements are for position and 2 for texture (UV). Can vector5 arrays be provided to support this?

flyx commented 7 years ago

That data type has no equivalent in GLSL. Therefore, I'd say it is application specific and should not be provided by OpenGLAda.

Definition is easy:

type Index_5 is (X, Y, Z, U, V);
type Vector5 is array (Index_5) of aliased Single;
pragma Convention (C, Vector5);
type Vector5_Array is array (Size range <>) of aliased Vector5;
pragma Convention (C, Vector5_Array);
package Vector5_Pointers is new Interfaces.C.Pointers
  (Index_5, Vector5, Vector5_Array, Vector5'(others => <>));
procedure Load_Vector5 is new GL.Objects.Buffers.Load_To_Buffer
 (Vector5_Pointers);

This should give you everything you need.

rogermc2 commented 7 years ago

Thanks. Would it be reasonable to put this in my maths.ads as its used in a number of examples?

flyx commented 7 years ago

Sure.