From b98469d26a581d9b41c0677f6520d24bfba146cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 2 Jan 2015 15:35:23 -0500 Subject: [PATCH] lib/glesv2: intro GLEnum and subclass GLError and GLFloatDataType MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/glesv2/glesv2.nit | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/glesv2/glesv2.nit b/lib/glesv2/glesv2.nit index 477fc47..bd19380 100644 --- a/lib/glesv2/glesv2.nit +++ b/lib/glesv2/glesv2.nit @@ -317,8 +317,17 @@ extern class GLfloatArray `{GLfloat *`} `} end +# General type for OpenGL enumerations +extern class GLEnum `{ GLenum `} + + redef fun hash `{ return recv; `} + + redef fun ==(o) do return o != null and is_same_type(o) and o.hash == self.hash +end + # An OpenGL ES 2.0 error code -extern class GLError `{ GLenum `} +extern class GLError + super GLEnum fun is_ok: Bool do return is_no_error fun is_no_error: Bool `{ return recv == GL_NO_ERROR; `} fun is_invalid_enum: Bool `{ return recv == GL_INVALID_ENUM; `} @@ -397,7 +406,9 @@ fun gl_shader_compiler: Bool do return gl_get_bool(0x8DFA) # # Only data types supported by shader attributes, as seen with # `GLProgram::active_attrib_type`. -extern class GLFloatDataType `{ GLenum `} +extern class GLFloatDataType + super GLEnum + fun is_float: Bool `{ return recv == GL_FLOAT; `} fun is_float_vec2: Bool `{ return recv == GL_FLOAT_VEC2; `} fun is_float_vec3: Bool `{ return recv == GL_FLOAT_VEC3; `} @@ -405,6 +416,12 @@ extern class GLFloatDataType `{ GLenum `} fun is_float_mat2: Bool `{ return recv == GL_FLOAT_MAT2; `} fun is_float_mat3: Bool `{ return recv == GL_FLOAT_MAT3; `} fun is_float_mat4: Bool `{ return recv == GL_FLOAT_MAT4; `} + + # Instances of `GLFloatDataType` can be equal to instances of `GLDataType` + redef fun ==(o) + do + return o != null and o isa GLFloatDataType and o.hash == self.hash + end end # All data types of OpenGL ES 2.0 shaders -- 1.7.9.5