conworlds

annotate src/unistate.h @ 14:423d4e6728cb

removed data from hg
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 24 Aug 2014 09:43:58 +0300
parents
children
rev   line source
nuclear@13 1 #ifndef UNISTATE_H_
nuclear@13 2 #define UNISTATE_H_
nuclear@13 3
nuclear@13 4 #include "vmath/vmath.h"
nuclear@13 5
nuclear@13 6 class ShaderProg;
nuclear@13 7
nuclear@13 8 enum StType {
nuclear@13 9 ST_UNKNOWN,
nuclear@13 10 ST_INT, ST_INT2, ST_INT3, ST_INT4,
nuclear@13 11 ST_FLOAT, ST_FLOAT2, ST_FLOAT3, ST_FLOAT4,
nuclear@13 12 ST_MATRIX3, ST_MATRIX4
nuclear@13 13 };
nuclear@13 14
nuclear@13 15 int add_unistate(const char *name, StType type);
nuclear@13 16 int get_unistate_index(const char *name);
nuclear@13 17
nuclear@13 18 /** set the uniform state identified by \param sidx by copying
nuclear@13 19 * a number of elements from \param val. If \param count is 0
nuclear@13 20 * then it's automatically set based on the type of this state item.
nuclear@13 21 * @{ */
nuclear@13 22 void set_unistate(int sidx, const int *val, int count = 0);
nuclear@13 23 void set_unistate(int sidx, const float *val, int count = 0);
nuclear@13 24 /// @}
nuclear@13 25
nuclear@13 26 /** get the uniform state identified by \param sidx by copying
nuclear@13 27 * a number of elements into \param val. If \param count is 0
nuclear@13 28 * then it's automatically set based on the type of this state item.
nuclear@13 29 * @{ */
nuclear@13 30 void get_unistate(int sidx, int *val, int count = 0);
nuclear@13 31 void get_unistate(int sidx, float *val, int count = 0);
nuclear@13 32 /// @}
nuclear@13 33
nuclear@13 34 /// convenience versions of set_unistate @{
nuclear@13 35 void set_unistate(int sidx, int val);
nuclear@13 36 void set_unistate(int sidx, float val);
nuclear@13 37 void set_unistate(int sidx, const Vector2 &vec);
nuclear@13 38 void set_unistate(int sidx, const Vector3 &vec);
nuclear@13 39 void set_unistate(int sidx, const Vector4 &vec);
nuclear@13 40 void set_unistate(int sidx, const Matrix3x3 &mat);
nuclear@13 41 void set_unistate(int sidx, const Matrix4x4 &mat);
nuclear@13 42 /// @}
nuclear@13 43
nuclear@13 44 /** convenience functions for setting the uniform state by name.
nuclear@13 45 * if the name cannot be found in the current set of uniform state
nuclear@13 46 * items, a new one is created with a type derived from the variant
nuclear@13 47 * of the function that was called (which might not be what you want).
nuclear@13 48 * The index of the state item is returned.
nuclear@13 49 * @{ */
nuclear@13 50 int set_unistate(const char *name, int *val, int count = 0);
nuclear@13 51 int set_unistate(const char *name, float *val, int count = 0);
nuclear@13 52 int set_unistate(const char *name, int val);
nuclear@13 53 int set_unistate(const char *name, float val);
nuclear@13 54 int set_unistate(const char *name, const Vector2 &vec);
nuclear@13 55 int set_unistate(const char *name, const Vector3 &vec);
nuclear@13 56 int set_unistate(const char *name, const Vector4 &vec);
nuclear@13 57 int set_unistate(const char *name, const Matrix3x3 &mat);
nuclear@13 58 int set_unistate(const char *name, const Matrix4x4 &mat);
nuclear@13 59 /// @}
nuclear@13 60
nuclear@13 61 /// convenience versions of get_unistate @{
nuclear@13 62 int get_unistate_int(int sidx);
nuclear@13 63 float get_unistate_float(int sidx);
nuclear@13 64 Vector2 get_unistate_vec2(int sidx);
nuclear@13 65 Vector3 get_unistate_vec3(int sidx);
nuclear@13 66 Vector4 get_unistate_vec4(int sidx);
nuclear@13 67 Matrix3x3 get_unistate_mat3(int sidx);
nuclear@13 68 Matrix4x4 get_unistate_mat4(int sidx);
nuclear@13 69 /// @}
nuclear@13 70
nuclear@13 71 /// convenience versions of get_unistate for getting the uniform state by name @{
nuclear@13 72 int get_unistate_int(const char *name);
nuclear@13 73 float get_unistate_float(const char *name);
nuclear@13 74 Vector2 get_unistate_vec2(const char *name);
nuclear@13 75 Vector3 get_unistate_vec3(const char *name);
nuclear@13 76 Vector4 get_unistate_vec4(const char *name);
nuclear@13 77 Matrix3x3 get_unistate_mat3(const char *name);
nuclear@13 78 Matrix4x4 get_unistate_mat4(const char *name);
nuclear@13 79 /// @}
nuclear@13 80
nuclear@13 81 /** Prepare for rendering by setting up all the state uniforms in the shader sdr.
nuclear@13 82 * If sdr is null, then use the "current" shader as per ShaderProg::current
nuclear@13 83 */
nuclear@13 84 void setup_unistate(const ShaderProg *sdr = 0);
nuclear@13 85
nuclear@13 86 bool setup_unistate(int sidx, const ShaderProg *sdr, int loc);
nuclear@13 87 bool setup_unistate(const char *name, const ShaderProg *sdr);
nuclear@13 88
nuclear@13 89 // special functions for setting the rendering pipeline matrices
nuclear@13 90 void set_world_matrix(const Matrix4x4 &mat);
nuclear@13 91 void set_view_matrix(const Matrix4x4 &mat);
nuclear@13 92 void set_projection_matrix(const Matrix4x4 &mat);
nuclear@13 93 void set_texture_matrix(const Matrix4x4 &mat);
nuclear@13 94
nuclear@13 95 Matrix4x4 get_world_matrix();
nuclear@13 96 Matrix4x4 get_view_matrix();
nuclear@13 97 Matrix4x4 get_projection_matrix();
nuclear@13 98 Matrix4x4 get_texture_matrix();
nuclear@13 99
nuclear@13 100 void setup_gl_matrices(); // this shouldn't be needed in the final code
nuclear@13 101
nuclear@13 102 // TODO should do a matrix stack at some point ...
nuclear@13 103
nuclear@13 104 #endif // UNISTATE_H_