index=0;
bool_index=$index
-gen_integral_type "bool" "GLSL_TYPE_BOOL" 0 0
+gen_integral_type "bool" "GLSL_TYPE_BOOL" 1 1
for i in 2 3 4; do
- gen_integral_type "bvec$i" "GLSL_TYPE_BOOL" $i 0
+ gen_integral_type "bvec$i" "GLSL_TYPE_BOOL" $i 1
done
int_index=$index
-gen_integral_type "int" "GLSL_TYPE_INT" 0 0
+gen_integral_type "int" "GLSL_TYPE_INT" 1 1
for i in 2 3 4; do
- gen_integral_type "ivec$i" "GLSL_TYPE_INT" $i 0
+ gen_integral_type "ivec$i" "GLSL_TYPE_INT" $i 1
done
float_index=$index
-gen_integral_type "float" "GLSL_TYPE_FLOAT" 0 0
+gen_integral_type "float" "GLSL_TYPE_FLOAT" 1 1
for i in 2 3 4; do
- gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 0
+ gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 1
done
matX_index=$index
gen_header "130"
index=0;
uint_index=$index
-gen_integral_type "uint" "GLSL_TYPE_UINT" 0 0
+gen_integral_type "uint" "GLSL_TYPE_UINT" 1 1
for i in 2 3 4; do
- gen_integral_type "uvec$i" "GLSL_TYPE_UINT" $i 0
+ gen_integral_type "uvec$i" "GLSL_TYPE_UINT" $i 1
done
echo
#define GLSL_TYPES_H
#include <cstring>
+#include <cassert>
#define GLSL_TYPE_UINT 0
#define GLSL_TYPE_INT 1
* and \c GLSL_TYPE_UINT are valid.
*/
- unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */
- unsigned matrix_columns:3; /**< 0, 2, 3, or 4 matrix columns. */
+ /**
+ * \name Vector and matrix element counts
+ *
+ * For scalars, each of these values will be 1. For non-numeric types
+ * these will be 0.
+ */
+ /*@{*/
+ unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
+ unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
+ /*@}*/
/**
* Name of the data type
name(name),
length(0)
{
+ /* Neither dimension is zero or both dimensions are zero.
+ */
+ assert((vector_elements == 0) == (matrix_columns == 0));
memset(& fields, 0, sizeof(fields));
}
*/
unsigned components() const
{
- return ((vector_elements == 0) ? 1 : vector_elements)
- * ((matrix_columns == 0) ? 1 : matrix_columns);
-
+ return vector_elements * matrix_columns;
}
/**
*/
bool is_scalar() const
{
- return (vector_elements == 0)
+ return (vector_elements == 1)
&& (base_type >= GLSL_TYPE_UINT)
&& (base_type <= GLSL_TYPE_BOOL);
}
*/
bool is_vector() const
{
- return (vector_elements > 0)
- && (matrix_columns == 0)
+ return (vector_elements > 1)
+ && (matrix_columns == 1)
&& (base_type >= GLSL_TYPE_UINT)
&& (base_type <= GLSL_TYPE_BOOL);
}
bool is_matrix() const
{
/* GLSL only has float matrices. */
- return (matrix_columns > 0) && (base_type == GLSL_TYPE_FLOAT);
+ return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT);
}
/**