1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # OpenGL graphics rendering library for embedded systems, version 2.0
19 # This is a low-level wrapper, it can be useful for developers already familiar
20 # with the C API of OpenGL. Most developers will prefer to use higher level
21 # wrappers such as `mnit` and `gammit`.
23 # Defines the annotations `glsl_vertex_shader` and `glsl_fragment_shader`
24 # applicable on string literals to check shader code using `glslangValidator`.
25 # The tool must be in PATH. It can be downloaded from
26 # https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
28 # Most services of this module are a direct wrapper of the underlying
29 # C library. If a method or class is not documented in Nit, refer to
30 # the official documentation by the Khronos Group at:
31 # http://www.khronos.org/opengles/sdk/docs/man/
34 new_annotation glsl_vertex_shader
35 new_annotation glsl_fragment_shader
36 ldflags
("-lGLESv2")@android
43 #include <GLES2/gl2.h>
46 # OpenGL ES program to which we attach shaders
47 extern class GLProgram `{GLuint`}
48 # Create a new program
50 # The newly created instance should be checked using `is_ok
`.
51 new `{ return glCreateProgram(); `}
53 # Set the location for the attribute by `name`
54 fun bind_attrib_location
(index
: Int, name
: String) import String.to_cstring
`{
55 GLchar *c_name = String_to_cstring(name);
56 glBindAttribLocation(self, index, c_name);
59 # Get the location of the attribute by `name`
61 # Returns `-1` if there is no active attribute named `name`.
62 fun attrib_location
(name
: String): Int import String.to_cstring
`{
63 GLchar *c_name = String_to_cstring(name);
64 return glGetAttribLocation(self, c_name);
67 # Get the location of the uniform by `name`
69 # Returns `-1` if there is no active uniform named `name`.
70 fun uniform_location
(name
: String): Int import String.to_cstring
`{
71 GLchar *c_name = String_to_cstring(name);
72 return glGetUniformLocation(self, c_name);
75 # Is this program linked?
76 fun is_linked
: Bool do return glGetProgramiv
(self, gl_LINK_STATUS
) != 0
78 # Has this program been deleted?
79 fun is_deleted
: Bool do return glGetProgramiv
(self, gl_DELETE_STATUS
) != 0
81 # Boolean result of `validate`, must be called after `validate`
82 fun is_validated
: Bool do return glGetProgramiv
(self, gl_VALIDATE_STATUS
) != 0
84 # Number of active uniform in this program
86 # This should be the number of uniforms declared in all shader, except
87 # unused uniforms which may have been optimized out.
88 fun n_active_uniforms
: Int do return glGetProgramiv
(self, gl_ACTIVE_UNIFORMS
)
90 # Length of the longest uniform name in this program, including the null byte
91 fun active_uniform_max_length
: Int do return glGetProgramiv
(self, gl_ACTIVE_UNIFORM_MAX_LENGTH
)
93 # Number of active attributes in this program
95 # This should be the number of uniforms declared in all shader, except
96 # unused uniforms which may have been optimized out.
97 fun n_active_attributes
: Int do return glGetProgramiv
(self, gl_ACTIVE_ATTRIBUTES
)
99 # Length of the longest attribute name in this program, including the null byte
100 fun active_attribute_max_length
: Int do return glGetProgramiv
(self, gl_ACTIVE_ATTRIBUTE_MAX_LENGTH
)
102 # Number of shaders attached to this program
103 fun n_attached_shaders
: Int do return glGetProgramiv
(self, gl_ATTACHED_SHADERS
)
105 # Name of the active attribute at `index`
106 fun active_attrib_name
(index
: Int): String
108 var max_size
= active_attribute_max_length
109 return active_attrib_name_native
(index
, max_size
).to_s
111 private fun active_attrib_name_native
(index
, max_size
: Int): NativeString `{
112 // We get more values than we need, for compatibility. At least the
113 // NVidia driver tries to fill them even if NULL.
115 char *name = malloc(max_size);
118 glGetActiveAttrib(self, index, max_size, NULL, &size, &type, name);
122 # Size of the active attribute at `index`
123 fun active_attrib_size
(index
: Int): Int `{
126 glGetActiveAttrib(self, index, 0, NULL, &size, &type, NULL);
130 # Type of the active attribute at `index`
132 # May only be float related data types (single float, vectors and matrix).
133 fun active_attrib_type
(index
: Int): GLDataType `{
136 glGetActiveAttrib(self, index, 0, NULL, &size, &type, NULL);
140 # Name of the active uniform at `index`
141 fun active_uniform_name
(index
: Int): String
143 var max_size
= active_attribute_max_length
144 return active_uniform_name_native
(index
, max_size
).to_s
146 private fun active_uniform_name_native
(index
, max_size
: Int): NativeString `{
147 char *name = malloc(max_size);
150 glGetActiveUniform(self, index, max_size, NULL, &size, &type, name);
154 # Size of the active uniform at `index`
155 fun active_uniform_size
(index
: Int): Int `{
158 glGetActiveUniform(self, index, 0, NULL, &size, &type, NULL);
162 # Type of the active uniform at `index`
164 # May be any data type supported by OpenGL ES 2.0 shaders.
165 fun active_uniform_type
(index
: Int): GLDataType `{
168 glGetActiveUniform(self, index, 0, NULL, &size, &type, NULL);
173 # Create a program object
174 fun glCreateProgram
: GLProgram `{ return glCreateProgram(); `}
176 # Install the `program
` as part of current rendering state
177 fun glUseProgram(program: GLProgram) `{ glUseProgram(program); `}
179 # Link the `program` object
180 fun glLinkProgram
(program
: GLProgram) `{ glLinkProgram(program); `}
182 # Validate the `program
` object
183 fun glValidateProgram(program: GLProgram) `{ glValidateProgram(program); `}
185 # Delete the `program` object
186 fun glDeleteProgram
(program
: GLProgram) `{ glDeleteProgram(program); `}
188 # Determine if `name
` corresponds to a program object
189 fun glIsProgram(name: GLProgram): Bool `{ return glIsProgram(name); `}
191 # Attach a `shader` to `program`
192 fun glAttachShader
(program
: GLProgram, shader
: GLShader) `{ glAttachShader(program, shader); `}
194 # Detach `shader
` from `program
`
195 fun glDetachShader(program: GLProgram, shader: GLShader) `{ glDetachShader(program, shader); `}
197 # Parameter value from a `program` object
198 fun glGetProgramiv
(program
: GLProgram, pname
: GLGetParameterName): Int `{
200 glGetProgramiv(program, pname, &value);
204 # The information log for the `program` object
205 fun glGetProgramInfoLog
(program
: GLProgram): String
207 var size
= glGetProgramiv
(program
, gl_INFO_LOG_LENGTH
)
208 var buf
= new NativeString(size
)
209 native_glGetProgramInfoLog
(program
, size
, buf
)
210 return buf
.to_s_with_length
(size
)
213 # Return the program information log in `buf`
214 private fun native_glGetProgramInfoLog
(program
: GLProgram, buf_size
: Int, buf
: NativeString): Int `{
216 glGetProgramInfoLog(program, buf_size, &length, buf);
220 # Abstract OpenGL ES shader object, implemented by `GLFragmentShader` and `GLVertexShader`
221 extern class GLShader `{GLuint`}
223 # Source of the shader, if available
225 # Returns `null` if the source is not available, usually when the shader
226 # was created from a binary file.
227 fun source: nullable String
229 var size = glGetShaderiv(self, gl_SHADER_SOURCE_LENGTH)
230 if size == 0 then return null
231 return source_native(size).to_s
234 private fun source_native(size: Int): NativeString `{
235 GLchar *code
= malloc
(size
);
236 glGetShaderSource
(self, size
, NULL, code
);
240 # Has this shader been compiled?
241 fun is_compiled: Bool do return glGetShaderiv(self, gl_COMPILE_STATUS) != 0
243 # Has this shader been deleted?
244 fun is_deleted: Bool do return glGetShaderiv(self, gl_DELETE_STATUS) != 0
247 # Get a parameter value from a `shader
` object
248 fun glGetShaderiv(shader: GLShader, pname: GLGetParameterName): Int `{
250 glGetShaderiv
(shader
, pname
, &val
);
255 extern class GLGetParameterName
259 fun gl_INFO_LOG_LENGTH: GLGetParameterName `{ return GL_INFO_LOG_LENGTH; `}
260 fun gl_DELETE_STATUS
: GLGetParameterName `{ return GL_DELETE_STATUS; `}
262 fun gl_SHADER_TYPE: GLGetParameterName `{ return GL_SHADER_TYPE; `}
263 fun gl_COMPILE_STATUS
: GLGetParameterName `{ return GL_COMPILE_STATUS; `}
264 fun gl_SHADER_SOURCE_LENGTH: GLGetParameterName `{ return GL_SHADER_SOURCE_LENGTH; `}
266 fun gl_ACTIVE_ATTRIBUTES
: GLGetParameterName `{ return GL_ACTIVE_ATTRIBUTES; `}
267 fun gl_ACTIVE_ATTRIBUTE_MAX_LENGTH: GLGetParameterName `{ return GL_ACTIVE_ATTRIBUTE_MAX_LENGTH; `}
268 fun gl_ACTIVE_UNIFORMS
: GLGetParameterName `{ return GL_ACTIVE_UNIFORMS; `}
269 fun gl_ACTIVE_UNIFORM_MAX_LENGTH: GLGetParameterName `{ return GL_ACTIVE_UNIFORM_MAX_LENGTH; `}
270 fun gl_ATTACHED_SHADERS
: GLGetParameterName `{ return GL_ATTACHED_SHADERS; `}
271 fun gl_LINK_STATUS: GLGetParameterName `{ return GL_LINK_STATUS; `}
272 fun gl_VALIDATE_STATUS
: GLGetParameterName `{ return GL_VALIDATE_STATUS; `}
274 # The information log for the `shader
` object
275 fun glGetShaderInfoLog(shader: GLShader): String
277 var size = glGetShaderiv(shader, gl_INFO_LOG_LENGTH)
278 var buf = new NativeString(size)
279 native_glGetShaderInfoLog(shader, size, buf)
280 return buf.to_s_with_length(size)
283 private fun native_glGetShaderInfoLog(shader: GLShader, buf_size: Int, buffer: NativeString): Int `{
285 glGetShaderInfoLog
(shader
, buf_size
, &length
, buffer
);
290 extern class GLShaderType
294 fun gl_VERTEX_SHADER: GLShaderType `{ return GL_VERTEX_SHADER; `}
295 fun gl_FRAGMENT_SHADER
: GLShaderType `{ return GL_FRAGMENT_SHADER; `}
297 # Create a shader object of the `shader_type
`
298 fun glCreateShader(shader_type: GLShaderType): GLShader `{
299 return glCreateShader
(shader_type
);
302 # Replace the source code in the `shader
` object with `code
`
303 fun glShaderSource(shader: GLShader, code: NativeString) `{
304 glShaderSource
(shader
, 1, (GLchar const
**)&code
, NULL);
307 # Compile the `shader
` object
308 fun glCompileShader(shader: GLShader) `{ glCompileShader(shader); `}
310 # Delete the `shader` object
311 fun glDeleteShader
(shader
: GLShader) `{ glDeleteShader(shader); `}
313 # Determine if `name
` corresponds to a shader object
314 fun glIsShader(name: GLShader): Bool `{ return glIsShader(name); `}
316 # An OpenGL ES 2.0 fragment shader
317 extern class GLFragmentShader
320 # Create a new fragment shader
322 # The newly created instance should be checked using `is_ok`.
323 new `{ return glCreateShader(GL_FRAGMENT_SHADER); `}
326 # An OpenGL ES 2.0 vertex shader
327 extern class GLVertexShader
330 # Create a new fragment shader
332 # The newly created instance should be checked using `is_ok
`.
333 new `{ return glCreateShader(GL_VERTEX_SHADER); `}
336 # An array of `Float` associated to a program variable
340 # Number of data per vertex
343 protected var glfloat_array
: NativeGLfloatArray
345 init(index
, count
: Int, array
: Array[Float])
349 self.glfloat_array
= new NativeGLfloatArray(array
.length
)
350 for k
in [0..array
.length
[ do
351 glfloat_array
[k
] = array
[k
]
355 fun attrib_pointer
do attrib_pointer_intern
(index
, count
, glfloat_array
)
356 private fun attrib_pointer_intern
(index
, count
: Int, array
: NativeGLfloatArray) `{
357 glVertexAttribPointer(index, count, GL_FLOAT, GL_FALSE, 0, array);
360 # Enable this vertex attribute array
361 fun enable
do glEnableVertexAttribArray
(index
)
363 # Disable this vertex attribute array
364 fun disable
do glDisableVertexAttribArray
(index
)
367 # Enable the generic vertex attribute array at `index`
368 fun glEnableVertexAttribArray
(index
: Int) `{ glEnableVertexAttribArray(index); `}
370 # Disable the generic vertex attribute array at `index
`
371 fun glDisableVertexAttribArray(index: Int) `{ glDisableVertexAttribArray(index); `}
373 # Render primitives from array data
374 fun glDrawArrays
(mode
: GLDrawMode, from
, count
: Int) `{ glDrawArrays(mode, from, count); `}
376 # Define an array of generic vertex attribute data
377 fun glVertexAttribPointer(index, size: Int, typ: GLDataType, normalized: Bool, stride: Int, array: NativeGLfloatArray) `{
378 glVertexAttribPointer
(index
, size
, typ
, normalized
, stride
, array
);
381 # Specify the value of a generic vertex attribute
382 fun glVertexAttrib1f(index: Int, x: Float) `{ glVertexAttrib1f(index, x); `}
384 # Specify the value of a generic vertex attribute
385 fun glVertexAttrib2f
(index
: Int, x
, y
: Float) `{ glVertexAttrib2f(index, x, y); `}
387 # Specify the value of a generic vertex attribute
388 fun glVertexAttrib3f(index: Int, x, y, z: Float) `{ glVertexAttrib3f(index, x, y, z); `}
390 # Specify the value of a generic vertex attribute
391 fun glVertexAttrib4f
(index
: Int, x
, y
, z
, w
: Float) `{ glVertexAttrib4f(index, x, y, z, w); `}
393 # Specify the value of a uniform variable for the current program object
394 fun glUniform1i(index, x: Int) `{ glUniform1i(index, x); `}
396 # Specify the value of a uniform variable for the current program object
397 fun glUniform2i
(index
, x
, y
: Int) `{ glUniform2i(index, x, y); `}
399 # Specify the value of a uniform variable for the current program object
400 fun glUniform3i(index, x, y, z: Int) `{ glUniform3i(index, x, y, z); `}
402 # Specify the value of a uniform variable for the current program object
403 fun glUniform4i
(index
, x
, y
, z
, w
: Int) `{ glUniform4i(index, x, y, z, w); `}
407 # Low level array of `Float`
410 redef type NATIVE: NativeGLfloatArray
414 native_array = new NativeGLfloatArray(length)
417 # Create with the content of `array
`
418 new from(array: Array[Float])
420 var arr = new GLfloatArray(array.length)
425 # Fill with the content of `array
`
426 fun fill_from(array: Array[Float])
428 assert length >= array.length
429 for k in [0..array.length[ do
435 # An array of `GLfloat` in C (`GLfloat*`)
436 extern class NativeGLfloatArray `{ GLfloat* `}
440 new(size
: Int) `{ return calloc(size, sizeof(GLfloat)); `}
442 redef fun [](index) `{ return self[index]; `}
443 redef fun []=(index
, val
) `{ self[index] = val; `}
445 redef fun +(offset) `{ return self + offset; `}
448 # General type for OpenGL enumerations
449 extern class GLEnum `{ GLenum `}
451 redef fun hash `{ return self; `}
453 redef fun ==(o
) do return o
!= null and is_same_type
(o
) and o
.hash
== self.hash
457 fun glGetError
: GLError `{ return glGetError(); `}
459 # An OpenGL ES 2.0 error code
465 if self == gl_NO_ERROR then return "No error"
466 if self == gl_INVALID_ENUM then return "Invalid enum"
467 if self == gl_INVALID_VALUE then return "Invalid value"
468 if self == gl_INVALID_OPERATION then return "Invalid operation"
469 if self == gl_INVALID_FRAMEBUFFER_OPERATION then return "invalid framebuffer operation"
470 if self == gl_OUT_OF_MEMORY then return "Out of memory"
471 return "Unknown error"
475 fun gl_NO_ERROR: GLError `{ return GL_NO_ERROR; `}
476 fun gl_INVALID_ENUM
: GLError `{ return GL_INVALID_ENUM; `}
477 fun gl_INVALID_VALUE: GLError `{ return GL_INVALID_VALUE; `}
478 fun gl_INVALID_OPERATION
: GLError `{ return GL_INVALID_OPERATION; `}
479 fun gl_INVALID_FRAMEBUFFER_OPERATION: GLError `{ return GL_INVALID_FRAMEBUFFER_OPERATION; `}
480 fun gl_OUT_OF_MEMORY
: GLError `{ return GL_OUT_OF_MEMORY; `}
482 fun assert_no_gl_error
484 var error = glGetError
485 if not error == gl_NO_ERROR then
486 print "GL error: {error}"
491 # Texture unit, the number of texture units is implementation dependent
492 extern class GLTextureUnit
496 fun gl_TEXTURE0: GLTextureUnit `{ return GL_TEXTURE0; `}
497 fun gl_TEXTURE1
: GLTextureUnit `{ return GL_TEXTURE1; `}
498 fun gl_TEXTURE2: GLTextureUnit `{ return GL_TEXTURE2; `}
499 fun gl_TEXTURE3
: GLTextureUnit `{ return GL_TEXTURE3; `}
500 fun gl_TEXTURE4: GLTextureUnit `{ return GL_TEXTURE4; `}
501 fun gl_TEXTURE5
: GLTextureUnit `{ return GL_TEXTURE5; `}
502 fun gl_TEXTURE6: GLTextureUnit `{ return GL_TEXTURE6; `}
503 fun gl_TEXTURE7
: GLTextureUnit `{ return GL_TEXTURE7; `}
504 fun gl_TEXTURE8: GLTextureUnit `{ return GL_TEXTURE8; `}
505 fun gl_TEXTURE9
: GLTextureUnit `{ return GL_TEXTURE9; `}
506 fun gl_TEXTURE10: GLTextureUnit `{ return GL_TEXTURE10; `}
507 fun gl_TEXTURE11
: GLTextureUnit `{ return GL_TEXTURE11; `}
508 fun gl_TEXTURE12: GLTextureUnit `{ return GL_TEXTURE12; `}
509 fun gl_TEXTURE13
: GLTextureUnit `{ return GL_TEXTURE13; `}
510 fun gl_TEXTURE14: GLTextureUnit `{ return GL_TEXTURE14; `}
511 fun gl_TEXTURE15
: GLTextureUnit `{ return GL_TEXTURE15; `}
512 fun gl_TEXTURE16: GLTextureUnit `{ return GL_TEXTURE16; `}
513 fun gl_TEXTURE17
: GLTextureUnit `{ return GL_TEXTURE17; `}
514 fun gl_TEXTURE18: GLTextureUnit `{ return GL_TEXTURE18; `}
515 fun gl_TEXTURE19
: GLTextureUnit `{ return GL_TEXTURE19; `}
516 fun gl_TEXTURE20: GLTextureUnit `{ return GL_TEXTURE20; `}
517 fun gl_TEXTURE21
: GLTextureUnit `{ return GL_TEXTURE21; `}
518 fun gl_TEXTURE22: GLTextureUnit `{ return GL_TEXTURE22; `}
519 fun gl_TEXTURE23
: GLTextureUnit `{ return GL_TEXTURE23; `}
520 fun gl_TEXTURE24: GLTextureUnit `{ return GL_TEXTURE24; `}
521 fun gl_TEXTURE25
: GLTextureUnit `{ return GL_TEXTURE25; `}
522 fun gl_TEXTURE26: GLTextureUnit `{ return GL_TEXTURE26; `}
523 fun gl_TEXTURE27
: GLTextureUnit `{ return GL_TEXTURE27; `}
524 fun gl_TEXTURE28: GLTextureUnit `{ return GL_TEXTURE28; `}
525 fun gl_TEXTURE29
: GLTextureUnit `{ return GL_TEXTURE29; `}
526 fun gl_TEXTURE30: GLTextureUnit `{ return GL_TEXTURE30; `}
527 fun gl_TEXTURE31
: GLTextureUnit `{ return GL_TEXTURE31; `}
529 # Texture unit at `offset
` after `gl_TEXTURE0
`
530 fun gl_TEXTURE(offset: Int): GLTextureUnit `{ return GL_TEXTURE0 + offset; `}
532 # Generate `n` texture names
533 fun glGenTextures
(n
: Int): Array[Int]
535 var array
= new CIntArray(n
)
536 native_glGenTextures
(n
, array
.native_array
)
542 private fun native_glGenTextures
(n
: Int, textures
: NativeCIntArray) `{
543 glGenTextures(n, (GLuint*)textures);
546 # Select server-side active texture unit
547 fun glActiveTexture
(texture
: GLTextureUnit) `{ glActiveTexture(texture); `}
549 # Bind the named `texture
` to a `target
`
550 fun glBindTexture(target: GLTextureTarget, texture: Int) `{
551 glBindTexture
(target
, texture
);
554 # Delete named textures
555 fun glDeleteTextures(textures: SequenceRead[Int])
557 var n = textures.length
558 var array = new CIntArray.from(textures)
559 native_glDeleteTextures(n, array.native_array)
563 private fun native_glDeleteTextures(n: Int, textures: NativeCIntArray) `{
564 glDeleteTextures
(n
, (const
GLuint *)textures
);
567 # Does `name
` corresponds to a texture?
568 fun glIsTexture(name: Int): Bool `{ return glIsTexture(name); `}
570 # Set pixel storage modes
571 fun glPixelStorei
(parameter
: GLPack, val
: Int) `{ glPixelStorei(parameter, val); `}
573 # Symbolic name of the parameter to be set with `glPixelStorei
`
578 # Parameter to specify the alignment requirements for the start of each pixel row in memory
579 fun gl_PACK_ALIGNEMENT: GLPack `{ return GL_PACK_ALIGNMENT; `}
581 # Parameter to specify the alignment requirements for the start of each pixel row in memory
582 fun gl_UNPACK_ALIGNEMENT
: GLPack `{ return GL_UNPACK_ALIGNMENT; `}
584 # TODO GL_PACK_ROW_LENGTH, GL_PACK_IMAGE_HEIGHT, GL_PACK_SKIP_PIXELS, GL_PACK_SKIP_ROWS, GL_PACK_SKIP_IMAGES
585 # GL_UNPACK_ROW_LENGTH, GL_UNPACK_IMAGE_HEIGHT, GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, GL_UNPACK_SKIP_IMAGES
587 # Specify a two-dimensional texture image
588 fun glTexImage2D(target: GLTextureTarget, level: Int, internalformat: GLPixelFormat,
589 width, height, border: Int,
590 format: GLPixelFormat, typ: GLDataType, data: Pointer) `{
591 glTexImage2D
(target
, level
, internalformat
, width
, height
, border
, format
, typ
, data
);
594 # Specify a two-dimensional texture subimage
595 fun glTexSubImage2D(target: GLTextureTarget,
596 level, xoffset, yoffset, width, height, border: Int,
597 format: GLPixelFormat, typ: GLDataType, data: Pointer) `{
598 glTexSubImage2D
(target
, level
, xoffset
, yoffset
, width
, height
, format
, typ
, data
);
601 # Copy pixels into a 2D texture image
602 fun glCopyTexImage2D(target: GLTextureTarget, level: Int, internalformat: GLPixelFormat,
603 x, y, width, height, border: Int) `{
604 glCopyTexImage2D
(target
, level
, internalformat
, x
, y
, width
, height
, border
);
607 # Copy a two-dimensional texture subimage
608 fun glCopyTexSubImage2D(target: GLTextureTarget, level, xoffset, yoffset, x, y, width, height: Int) `{
609 glCopyTexSubImage2D
(target
, level
, xoffset
, yoffset
, x
, y
, width
, height
);
612 # Copy a block of pixels from the framebuffer of `fomat
` and `typ
` at `data
`
613 fun glReadPixels(x, y, width, height: Int, format: GLPixelFormat, typ: GLDataType, data: Pointer) `{
614 glReadPixels
(x
, y
, width
, height
, format
, typ
, data
);
617 # Texture minifying and magnifying function
618 extern class GLTexParameteri
622 fun gl_NEAREST: GLTexParameteri `{ return GL_NEAREST; `}
623 fun gl_LINEAR
: GLTexParameteri `{ return GL_LINEAR; `}
624 fun gl_NEAREST_MIPMAP_NEAREST: GLTexParameteri `{ return GL_NEAREST_MIPMAP_NEAREST; `}
625 fun gl_LINEAR_MIPMAP_NEAREST
: GLTexParameteri `{ return GL_LINEAR_MIPMAP_NEAREST; `}
626 fun gl_NEAREST_MIPMAP_NINEAR: GLTexParameteri `{ return GL_NEAREST_MIPMAP_LINEAR; `}
627 fun gl_LINEAR_MIPMAP_LINEAR
: GLTexParameteri `{ return GL_LINEAR_MIPMAP_LINEAR; `}
628 fun gl_CLAMP_TO_EDGE: GLTexParameteri `{ return GL_CLAMP_TO_EDGE; `}
629 fun gl_MIRRORED_REPEAT
: GLTexParameteri `{ return GL_MIRRORED_REPEAT; `}
630 fun gl_REPEAT: GLTexParameteri `{ return GL_REPEAT; `}
633 extern class GLTextureTarget
637 # Two-dimensional texture
638 fun gl_TEXTURE_2D
: GLTextureTarget `{ return GL_TEXTURE_2D; `}
641 fun gl_TEXTURE_CUBE_MAP: GLTextureTarget `{ return GL_TEXTURE_CUBE_MAP; `}
643 # TODO GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
644 # GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
646 # A server-side capability
651 # Internal OpenGL integer for this capability
654 # Enable this server-side capability
655 fun enable
do enable_native
(val
)
656 private fun enable_native
(cap
: Int) `{ glEnable(cap); `}
658 # Disable this server-side capability
659 fun disable do disable_native(val)
660 private fun disable_native(cap: Int) `{ glDisable(cap); `}
662 redef fun hash
do return val
663 redef fun ==(o
) do return o
!= null and is_same_type
(o
) and o
.hash
== self.hash
666 # Generate `n` renderbuffer object names
667 fun glGenRenderbuffers
(n
: Int): Array[Int]
669 var array
= new CIntArray(n
)
670 native_glGenRenderbuffers
(n
, array
.native_array
)
676 private fun native_glGenRenderbuffers
(n
: Int, renderbuffers
: NativeCIntArray) `{
677 glGenRenderbuffers(n, (GLuint *)renderbuffers);
680 # Determine if `name` corresponds to a renderbuffer object
681 fun glIsRenderbuffer
(name
: Int): Bool `{
682 return glIsRenderbuffer(name);
685 # Delete named renderbuffer objects
686 fun glDeleteRenderbuffers
(renderbuffers
: SequenceRead[Int])
688 var n
= renderbuffers
.length
689 var array
= new CIntArray.from
(renderbuffers
)
690 native_glDeleteRenderbuffers
(n
, array
.native_array
)
694 private fun native_glDeleteRenderbuffers
(n
: Int, renderbuffers
: NativeCIntArray) `{
695 return glDeleteRenderbuffers(n, (const GLuint *)renderbuffers);
698 # Attach a renderbuffer object to a framebuffer object
699 fun glFramebufferRenderbuffer
(target
: GLFramebufferTarget, attachment
: GLAttachment,
700 renderbuffertarget
: GLRenderbufferTarget, renderbuffer
: Int) `{
701 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
704 # Establish data storage, `format` and dimensions of the `target` renderbuffer object's image
705 fun glRenderbufferStorage
(target
: GLRenderbufferTarget, format
: GLRenderbufferFormat, width
, height
: Int) `{
706 glRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
709 # Format for a renderbuffer
710 extern class GLRenderbufferFormat
714 # 4 red, 4 green, 4 blue, 4 alpha bits format
715 fun gl_RGBA4
: GLRenderbufferFormat `{ return GL_RGBA4; `}
717 # 5 red, 6 green, 5 blue bits format
718 fun gl_RGB565: GLRenderbufferFormat `{ return GL_RGB565; `}
720 # 5 red, 5 green, 5 blue, 1 alpha bits format
721 fun gl_RGB_A1
: GLRenderbufferFormat `{ return GL_RGB5_A1; `}
723 # 16 depth bits format
724 fun gl_DEPTH_COMPNENT16: GLRenderbufferFormat `{ return GL_DEPTH_COMPONENT16; `}
726 # 8 stencil bits format
727 fun gl_STENCIL_INDEX8
: GLRenderbufferFormat `{ return GL_STENCIL_INDEX8; `}
729 # Renderbuffer attachment point to a framebuffer
730 extern class GLAttachment
734 # First color attachment point
735 fun gl_COLOR_ATTACHMENT0: GLAttachment `{ return GL_COLOR_ATTACHMENT0; `}
737 # Depth attachment point
738 fun gl_DEPTH_ATTACHMENT
: GLAttachment `{ return GL_DEPTH_ATTACHMENT; `}
741 fun gl_STENCIL_ATTACHMENT: GLAttachment `{ return GL_STENCIL_ATTACHMENT; `}
744 private var gles
= new GLES is lazy
747 # Entry points to OpenGL ES 2.0 services
748 fun gl
: GLES do return sys
.gles
750 # OpenGL ES 2.0 services
753 # Query the boolean value at `key`
754 private fun get_bool
(key
: Int): Bool `{
756 glGetBooleanv(key, &val);
757 return val == GL_TRUE;
760 # Query the floating point value at `key`
761 private fun get_float
(key
: Int): Float `{
763 glGetFloatv(key, &val);
767 # Query the integer value at `key`
768 private fun get_int
(key
: Int): Int `{
770 glGetIntegerv(key, &val);
774 # Does this driver support shader compilation?
776 # Should always return `true` in OpenGL ES 2.0 and 3.0.
777 fun shader_compiler
: Bool do return get_bool
(0x8DFA)
779 # OpenGL server-side capabilities
780 var capabilities
= new GLCapabilities is lazy
783 # Specify the clear values for the color buffer, default values are at 0.0
784 fun glClearColor
(red
, green
, blue
, alpha
: Float) `{
785 glClearColor(red, green, blue, alpha);
788 # Specify the clear `value` for the depth buffer, default at 1.0
789 fun glClearDepthf
(value
: Float) `{ glClearDepthf(value); `}
791 # Specify the clear `value
` for the stencil buffer, default at 0
792 fun glClearStencil(value: Int) `{ glClearStencil(value); `}
795 fun glClear
(buffer
: GLBuffer) `{ glClear(buffer); `}
797 # Enable and disable writing of frame buffer color components
798 fun glColorMask(red, green, blue, alpha: Bool) `{ glColorMask(red, green, blue, alpha); `}
801 fun glViewport
(x
, y
, width
, height
: Int) `{ glViewport(x, y, width, height); `}
803 # Block until all GL execution is complete
804 fun glFinish `{ glFinish(); `}
806 # Force execution of GL commands in finite time
807 fun glFlush
`{ glFlush(); `}
809 # Set texture parameters
810 fun glTexParameteri(target: GLTextureTarget, pname: GLTexParameteriName, param: GLTexParameteri) `{
811 glTexParameteri
(target
, pname
, param
);
814 # Name of parameters of textures
815 extern class GLTexParameteriName
819 fun gl_TEXTURE_MIN_FILTER: GLTexParameteriName `{ return GL_TEXTURE_MIN_FILTER; `}
820 fun gl_TEXTURE_MAG_FILTER
: GLTexParameteriName `{ return GL_TEXTURE_MAG_FILTER; `}
821 fun gl_TEXTURE_WRAP_S: GLTexParameteriName `{ return GL_TEXTURE_WRAP_S; `}
822 fun gl_TEXTURE_WRAP_T
: GLTexParameteriName `{ return GL_TEXTURE_WRAP_T; `}
824 # Bind `framebuffer
` to a framebuffer target
826 # In OpenGL ES 2.0, `target
` must be `gl_FRAMEBUFFER
`.
827 fun glBindFramebuffer(target: GLFramebufferTarget, framebuffer: Int) `{
828 glBindFramebuffer
(target
, framebuffer
);
831 # Target of `glBindFramebuffer
`
832 extern class GLFramebufferTarget
836 # Target both reading and writing on the framebuffer with `glBindFramebuffer
`
837 fun gl_FRAMEBUFFER: GLFramebufferTarget `{ return GL_FRAMEBUFFER; `}
839 # Bind `renderbuffer` to a renderbuffer target
841 # In OpenGL ES 2.0, `target` must be `gl_RENDERBUFFER`.
842 fun glBindRenderbuffer
(target
: GLRenderbufferTarget, renderbuffer
: Int) `{
843 glBindRenderbuffer(target, renderbuffer);
846 # Target of `glBindRenderbuffer`
847 extern class GLRenderbufferTarget
851 # Target a renderbuffer with `glBindRenderbuffer`
852 fun gl_RENDERBUFFER
: GLRenderbufferTarget `{ return GL_RENDERBUFFER; `}
854 # Specify implementation specific hints
855 fun glHint(target: GLHintTarget, mode: GLHintMode) `{
856 glHint
(target
, mode
);
859 # Generate and fill set of mipmaps for the texture object `target
`
860 fun glGenerateMipmap(target: GLTextureTarget) `{ glGenerateMipmap(target); `}
862 # Bind the named `buffer` object
863 fun glBindBuffer
(target
: GLArrayBuffer, buffer
: Int) `{ glBindBuffer(target, buffer); `}
865 # Target to which bind the buffer with `glBindBuffer
`
866 extern class GLArrayBuffer
870 # Array buffer target
871 fun gl_ARRAY_BUFFER: GLArrayBuffer `{ return GL_ARRAY_BUFFER; `}
873 # Element array buffer
874 fun gl_ELEMENT_ARRAY_BUFFER
: GLArrayBuffer `{ return GL_ELEMENT_ARRAY_BUFFER; `}
876 # Completeness status of a framebuffer object
877 fun glCheckFramebufferStatus(target: GLFramebufferTarget): GLFramebufferStatus `{
878 return glCheckFramebufferStatus
(target
);
881 # Return value of `glCheckFramebufferStatus
`
882 extern class GLFramebufferStatus
887 if self == gl_FRAMEBUFFER_COMPLETE then return "complete"
888 if self == gl_FRAMEBUFFER_INCOMPLETE_ATTACHMENT then return "incomplete attachment"
889 if self == gl_FRAMEBUFFER_INCOMPLETE_DIMENSIONS then return "incomplete dimension"
890 if self == gl_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT then return "incomplete missing attachment"
891 if self == gl_FRAMEBUFFER_UNSUPPORTED then return "unsupported"
896 # The framebuffer is complete
897 fun gl_FRAMEBUFFER_COMPLETE: GLFramebufferStatus `{
898 return GL_FRAMEBUFFER_COMPLETE;
901 # Not all framebuffer attachment points are framebuffer attachment complete
902 fun gl_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLFramebufferStatus `{
903 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
906 # Not all attached images have the same width and height
907 fun gl_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLFramebufferStatus `{
908 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
911 # No images are attached to the framebuffer
912 fun gl_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLFramebufferStatus `{
913 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
916 # The combination of internal formats of the attached images violates an implementation-dependent set of restrictions
917 fun gl_FRAMEBUFFER_UNSUPPORTED: GLFramebufferStatus `{
918 return GL_FRAMEBUFFER_UNSUPPORTED;
921 # Hint target for `glHint
`
922 extern class GLHintTarget
926 # Indicates the quality of filtering when generating mipmap images
927 fun gl_GENERATE_MIPMAP_HINT: GLHintTarget `{ return GL_GENERATE_MIPMAP_HINT; `}
929 # Hint mode for `glHint`
930 extern class GLHintMode
934 # The most efficient option should be chosen
935 fun gl_FASTEST
: GLHintMode `{ return GL_FASTEST; `}
937 # The most correct, or highest quality, option should be chosen
938 fun gl_NICEST: GLHintMode `{ return GL_NICEST; `}
941 fun gl_DONT_CARE
: GLHintMode `{ return GL_DONT_CARE; `}
943 # Generate `n
` framebuffer object names
944 fun glGenFramebuffers(n: Int): Array[Int]
946 var array = new CIntArray(n)
947 native_glGenFramebuffers(n, array.native_array)
953 private fun native_glGenFramebuffers(n: Int, textures: NativeCIntArray) `{
954 glGenFramebuffers
(n
, (GLuint *)textures
);
957 # Determine if `name
` corresponds to a framebuffer object
958 fun glIsFramebuffer(name: Int): Bool `{
959 return glIsFramebuffer
(name
);
962 # Delete named framebuffer objects
963 fun glDeleteFramebuffers(framebuffers: SequenceRead[Int])
965 var n = framebuffers.length
966 var array = new CIntArray.from(framebuffers)
967 native_glDeleteFramebuffers(n, array.native_array)
971 private fun native_glDeleteFramebuffers(n: Int, framebuffers: NativeCIntArray) `{
972 return glDeleteFramebuffers
(n
, (const
GLuint *)framebuffers
);
975 # Attach a level of a texture object as a logical buffer to the currently bound framebuffer object
976 fun glFramebufferTexture2D(target: GLFramebufferTarget, attachment: GLAttachment,
977 texture_target: GLTextureTarget, texture, level: Int) `{
978 glFramebufferTexture2D
(target
, attachment
, texture_target
, texture
, level
);
981 # Entry point to OpenGL server-side capabilities
984 # GL capability: blend the computed fragment color values
987 var blend: GLCap is lazy do return new GLCap(0x0BE2)
989 # GL capability: cull polygons based of their winding in window coordinates
991 # Foreign: GL_CULL_FACE
992 var cull_face: GLCap is lazy do return new GLCap(0x0B44)
994 # GL capability: do depth comparisons and update the depth buffer
996 # Foreign: GL_DEPTH_TEST
997 var depth_test: GLCap is lazy do return new GLCap(0x0B71)
999 # GL capability: dither color components or indices before they are written to the color buffer
1001 # Foreign: GL_DITHER
1002 var dither: GLCap is lazy do return new GLCap(0x0BE2)
1004 # GL capability: add an offset to depth values of a polygon fragment before depth test
1006 # Foreign: GL_POLYGON_OFFSET_FILL
1007 var polygon_offset_fill: GLCap is lazy do return new GLCap(0x8037)
1009 # GL capability: compute a temporary coverage value where each bit is determined by the alpha value at the corresponding location
1011 # Foreign: GL_SAMPLE_ALPHA_TO_COVERAGE
1012 var sample_alpha_to_coverage: GLCap is lazy do return new GLCap(0x809E)
1014 # GL capability: AND the fragment coverage with the temporary coverage value
1016 # Foreign: GL_SAMPLE_COVERAGE
1017 var sample_coverage: GLCap is lazy do return new GLCap(0x80A0)
1019 # GL capability: discard fragments that are outside the scissor rectangle
1021 # Foreign: GL_SCISSOR_TEST
1022 var scissor_test: GLCap is lazy do return new GLCap(0x0C11)
1024 # GL capability: do stencil testing and update the stencil buffer
1026 # Foreign: GL_STENCIL_TEST
1027 var stencil_test: GLCap is lazy do return new GLCap(0x0B90)
1030 # All data types of OpenGL ES 2.0 shaders
1032 # These types can be used by shader uniforms, as seen with
1033 # `GLProgram::active_uniform_type
`.
1034 extern class GLDataType
1038 fun gl_FLOAT: GLDataType `{ return GL_FLOAT; `}
1039 fun gl_FLOAT_VEC2
: GLDataType `{ return GL_FLOAT_VEC2; `}
1040 fun gl_FLOAT_VEC3: GLDataType `{ return GL_FLOAT_VEC3; `}
1041 fun gl_FLOAT_VEC4
: GLDataType `{ return GL_FLOAT_VEC4; `}
1042 fun gl_FLOAT_MAT2: GLDataType `{ return GL_FLOAT_MAT2; `}
1043 fun gl_FLOAT_MAT3
: GLDataType `{ return GL_FLOAT_MAT3; `}
1044 fun gl_FLOAT_MAT4: GLDataType `{ return GL_FLOAT_MAT4; `}
1046 fun gl_BYTE
: GLDataType `{ return GL_BYTE; `}
1047 fun gl_UNSIGNED_BYTE: GLDataType `{ return GL_UNSIGNED_BYTE; `}
1048 fun gl_SHORT
: GLDataType `{ return GL_SHORT; `}
1049 fun gl_UNSIGNED_SHORT: GLDataType `{ return GL_UNSIGNED_SHORT; `}
1050 fun gl_INT
: GLDataType `{ return GL_INT; `}
1051 fun gl_UNSIGNED_INT: GLDataType `{ return GL_UNSIGNED_INT; `}
1052 fun gl_FIXED
: GLDataType `{ return GL_FIXED; `}
1053 fun gl_INT_VEC2: GLDataType `{ return GL_INT_VEC2; `}
1054 fun gl_INT_VEC3
: GLDataType `{ return GL_INT_VEC3; `}
1055 fun gl_INT_VEC4: GLDataType `{ return GL_INT_VEC4; `}
1056 fun gl_BOOL
: GLDataType `{ return GL_BOOL; `}
1057 fun gl_BOOL_VEC2: GLDataType `{ return GL_BOOL_VEC2; `}
1058 fun gl_BOOL_VEC3
: GLDataType `{ return GL_BOOL_VEC3; `}
1059 fun gl_BOOL_VEC4: GLDataType `{ return GL_BOOL_VEC4; `}
1060 fun gl_SAMPLER_2D
: GLDataType `{ return GL_SAMPLER_2D; `}
1061 fun gl_SAMPLER_CUBE: GLDataType `{ return GL_SAMPLER_CUBE; `}
1063 fun gl_UNSIGNED_SHORT_5_6_5
: GLDataType `{ return GL_UNSIGNED_SHORT_5_6_5; `}
1064 fun gl_UNSIGNED_SHORT_4_4_4_4: GLDataType `{ return GL_UNSIGNED_SHORT_4_4_4_4; `}
1065 fun gl_UNSIGNED_SHORT_5_5_5_1
: GLDataType `{ return GL_UNSIGNED_SHORT_5_5_5_1; `}
1067 # Kind of primitives to render
1068 extern class GLDrawMode
1072 fun gl_POINTS: GLDrawMode `{ return GL_POINTS; `}
1073 fun gl_LINES
: GLDrawMode `{ return GL_LINES; `}
1074 fun gl_LINE_LOOP: GLDrawMode `{ return GL_LINE_LOOP; `}
1075 fun gl_LINE_STRIP
: GLDrawMode `{ return GL_LINE_STRIP; `}
1076 fun gl_TRIANGLES: GLDrawMode `{ return GL_TRIANGLES; `}
1077 fun gl_TRIANGLE_STRIP
: GLDrawMode `{ return GL_TRIANGLE_STRIP; `}
1078 fun gl_TRIANGLE_FAN: GLDrawMode `{ return GL_TRIANGLE_FAN; `}
1080 # Pixel arithmetic for blending operations
1081 extern class GLBlendFactor
1085 fun gl_ZERO
: GLBlendFactor `{ return GL_ZERO; `}
1086 fun gl_ONE: GLBlendFactor `{ return GL_ONE; `}
1087 fun gl_SRC_COLOR
: GLBlendFactor `{ return GL_SRC_COLOR; `}
1088 fun gl_ONE_MINUS_SRC_COLOR: GLBlendFactor `{ return GL_ONE_MINUS_SRC_COLOR; `}
1089 fun gl_SRC_ALPHA
: GLBlendFactor `{ return GL_SRC_ALPHA; `}
1090 fun gl_ONE_MINUS_SRC_ALPHA: GLBlendFactor `{ return GL_ONE_MINUS_SRC_ALPHA; `}
1091 fun gl_DST_ALPHA
: GLBlendFactor `{ return GL_DST_ALPHA; `}
1092 fun gl_ONE_MINUS_DST_ALPHA: GLBlendFactor `{ return GL_ONE_MINUS_DST_ALPHA; `}
1093 fun gl_DST_COLOR
: GLBlendFactor `{ return GL_DST_COLOR; `}
1094 fun gl_ONE_MINUS_DST_COLOR: GLBlendFactor `{ return GL_ONE_MINUS_DST_COLOR; `}
1095 fun gl_SRC_ALPHA_SATURATE
: GLBlendFactor `{ return GL_SRC_ALPHA_SATURATE; `}
1097 # Condition under which a pixel will be drawn
1098 extern class GLDepthFunc
1102 fun gl_NEVER: GLDepthFunc `{ return GL_NEVER; `}
1103 fun gl_LESS
: GLDepthFunc `{ return GL_LESS; `}
1104 fun gl_EQUAL: GLDepthFunc `{ return GL_EQUAL; `}
1105 fun gl_LEQUAL
: GLDepthFunc `{ return GL_LEQUAL; `}
1106 fun gl_GREATER: GLDepthFunc `{ return GL_GREATER; `}
1107 fun gl_NOTEQUAL
: GLDepthFunc `{ return GL_NOTEQUAL; `}
1108 fun gl_GEQUAL: GLDepthFunc `{ return GL_GEQUAL; `}
1109 fun gl_ALWAYS
: GLDepthFunc `{ return GL_ALWAYS; `}
1111 # Format of pixel data
1112 extern class GLPixelFormat
1116 fun gl_ALPHA: GLPixelFormat `{ return GL_ALPHA; `}
1117 fun gl_RGB
: GLPixelFormat `{ return GL_RGB; `}
1118 fun gl_RGBA: GLPixelFormat `{ return GL_RGBA; `}
1120 # Set of buffers as a bitwise OR mask
1121 extern class GLBuffer `{ GLbitfield `}
1122 # Bitwise OR with `other
`
1123 fun |(other: GLBuffer): GLBuffer `{ return self | other; `}
1126 fun gl_DEPTH_BUFFER_BIT
: GLBuffer `{ return GL_DEPTH_BUFFER_BIT; `}
1127 fun gl_STENCIL_BUFFER_BIT: GLBuffer `{ return GL_STENCIL_BUFFER_BIT; `}
1128 fun gl_COLOR_BUFFER_BIT
: GLBuffer `{ return GL_COLOR_BUFFER_BIT; `}
1130 # Define front- and back-facing polygons, `gc_CCW
` by default
1131 fun glFrontFace(mode: GLFrontFaceMode) `{ glFrontFace(mode); `}
1133 # Orientation of front-facing polygons
1134 extern class GLFrontFaceMode
1138 fun gl_CW
: GLFrontFaceMode `{ return GL_CW; `}
1139 fun gl_CCW: GLFrontFaceMode `{ return GL_CCW; `}
1141 # Specify whether front- or back-facing polygons can be culled, default is `back` only
1142 fun glCullFace
(mode
: GLCullFaceMode) `{ glCullFace(mode); `}
1144 # Candidates for culling
1145 extern class GLCullFaceMode
1149 fun gl_FRONT: GLCullFaceMode `{ return GL_FRONT; `}
1150 fun gl_BACK
: GLCullFaceMode `{ return GL_BACK; `}
1151 fun gl_FRONT_AND_BACK: GLCullFaceMode `{ return GL_FRONT_AND_BACK; `}
1153 # Specify mapping of depth values from normalized device coordinates to window coordinates
1155 # Default at 0.0, 1.0.
1156 fun glDepthRangef
(near
, far
: Float) `{ glDepthRangef(near, far); `}
1158 # Enable or disable writing into the depth buffer
1159 fun glDepthMask(value: Bool) `{ glDepthMask(value); `}
1161 # Specify the value used for depth buffer comparisons
1163 # Default value is `gl_LESS`
1164 fun glDepthFunc
(func
: GLDepthFunc) `{ glDepthFunc(func); `}
1166 # Set the pixel arithmetic for the blending operations
1169 # * `src_factor
`: `gl_ONE
`
1170 # * `dst_factor
`: `gl_ZERO
`
1171 fun glBlendFunc(src_factor, dst_factor: GLBlendFactor) `{
1172 glBlendFunc
(src_factor
, dst_factor
);
1175 # Set the scale and units used to calculate depth values
1176 fun glPolygonOffset(factor, units: Float) `{ glPolygonOffset(factor, units); `}
1178 # Specify the width of rasterized lines
1179 fun glLineWidth
(width
: Float) `{ glLineWidth(width); `}