X-Git-Url: http://nitlanguage.org diff --git a/lib/egl.nit b/lib/egl.nit index 4965c31..e349a0d 100644 --- a/lib/egl.nit +++ b/lib/egl.nit @@ -21,7 +21,7 @@ # C library. If a method or class is not documented in Nit, refer to # the official documentation by the Khronos Group at: # http://www.khronos.org/registry/egl/sdk/docs/man/xhtml/ -module egl is pkgconfig("egl") +module egl is pkgconfig in "C Header" `{ #include @@ -62,7 +62,7 @@ extern class EGLDisplay `{ EGLDisplay `} #fun get_configs: nullable Array[EGLConfig] import Array[EGLConfig].with_native `{ # Returns some configs compatible with the specified `attributes` - fun choose_configs(attribs: Array[Int]): nullable Array[EGLConfig] import Array[Int].length, Array[Int].[], Array[EGLConfig], Array[EGLConfig].add, Array[EGLConfig] as nullable, report_egl_error `{ + fun choose_configs(attribs: Array[Int]): nullable Array[EGLConfig] import Array[Int].length, Array[Int].[], Array[EGLConfig], Array[EGLConfig].add, Array[EGLConfig].as nullable, report_egl_error `{ EGLConfig *configs; int n_configs; int n_attribs = Array_of_Int_length(attribs); @@ -208,13 +208,24 @@ class EGLConfigAttribs var display: EGLDisplay var config: EGLConfig + fun buffer_size: Int do return display.config_attrib(config, "3020".to_hex) fun alpha_size: Int do return display.config_attrib(config, "3021".to_hex) + fun blue_size: Int do return display.config_attrib(config, "3022".to_hex) + fun green_size: Int do return display.config_attrib(config, "3023".to_hex) + fun red_size: Int do return display.config_attrib(config, "3024".to_hex) + fun depth_size: Int do return display.config_attrib(config, "3025".to_hex) + fun stencil_size: Int do return display.config_attrib(config, "3026".to_hex) + fun native_visual_id: Int do return display.config_attrib(config, "302E".to_hex) fun native_visual_type: Int do return display.config_attrib(config, "302F".to_hex) fun caveat: EGLConfigCaveat do return new EGLConfigCaveat.from_i(display.config_attrib(config, "3027".to_hex)) end + + fun conformant: EGLConformant do + return new EGLConformant.from_i(display.config_attrib(config, "3042".to_hex)) + end end extern class EGLConfigCaveat `{ EGLint `} @@ -244,6 +255,36 @@ extern class EGLConfigCaveat `{ EGLint `} end end +extern class EGLConformant `{ EGLint `} + new `{ return (EGLint)0; `} + new from_i(val: Int) `{ return (EGLint)val; `} + fun to_i: Int `{ return recv; `} + + fun opengl: Bool `{ return recv & EGL_OPENGL_BIT; `} + fun with_opengl: EGLConformant `{ return recv | EGL_OPENGL_BIT; `} + + fun opengl_es: Bool `{ return recv & EGL_OPENGL_ES_BIT; `} + fun with_opengl_es: EGLConformant `{ return recv | EGL_OPENGL_ES_BIT; `} + + fun opengl_es2: Bool `{ return recv & EGL_OPENGL_ES2_BIT; `} + fun with_opengl_es2: EGLConformant `{ return recv | EGL_OPENGL_ES2_BIT; `} + + fun openvg: Bool `{ return recv & EGL_OPENVG_BIT; `} + fun with_openvg: EGLConformant `{ return recv | EGL_OPENVG_BIT; `} + + fun to_a: Array[String] + do + var features = new Array[String] + if opengl then features.add("OpenGL") + if opengl_es then features.add("OpenGL ES") + if opengl_es2 then features.add("OpenGL ES2") + if openvg then features.add("OpenVG") + return features + end + + redef fun to_s do return to_a.join(", ") +end + # Attributes of a surface for a given EGL display class EGLSurfaceAttribs var display: EGLDisplay @@ -375,6 +416,7 @@ class EGLConfigChooser fun green_size=(size: Int) do insert_attrib_with_val("3023".to_hex, size) fun red_size=(size: Int) do insert_attrib_with_val("3024".to_hex, size) + fun buffer_size=(size: Int) do insert_attrib_with_val("3020".to_hex, size) fun alpha_size=(size: Int) do insert_attrib_with_val("3021".to_hex, size) fun depth_size=(size: Int) do insert_attrib_with_val("3025".to_hex, size) fun stencil_size=(size: Int) do insert_attrib_with_val("3026".to_hex, size) @@ -382,6 +424,8 @@ class EGLConfigChooser fun caveat=(caveat: EGLConfigCaveat) do insert_attrib_with_val("3050".to_hex, caveat.to_i) + fun conformant=(conformant: EGLConformant) do insert_attrib_with_val("3042".to_hex, conformant.to_i) + fun choose(display: EGLDisplay): nullable Array[EGLConfig] do assert closed else print "EGLConfigChooser not closed."