Add implementation of GL.drawBuffers on native

This commit is contained in:
Joshua Granick
2017-08-10 16:39:55 -07:00
parent 4a98633d76
commit e7c6a8762c
3 changed files with 21 additions and 0 deletions

View File

@@ -464,6 +464,7 @@ class NativeCFFI {
@:cffi private static function lime_gl_disable (cap:Int):Void;
@:cffi private static function lime_gl_disable_vertex_attrib_array (index:Int):Void;
@:cffi private static function lime_gl_draw_arrays (mode:Int, first:Int, count:Int):Void;
@:cffi private static function lime_gl_draw_buffers (buffers:Dynamic):Void;
@:cffi private static function lime_gl_draw_elements (mode:Int, count:Int, type:Int, offset:DataPointer):Void;
@:cffi private static function lime_gl_enable (cap:Int):Void;
@:cffi private static function lime_gl_enable_vertex_attrib_array (index:Int):Void;

View File

@@ -1378,6 +1378,9 @@ class NativeGLRenderContext {
public inline function drawBuffers (buffers:Array<Int>):Void {
#if (lime_cffi && lime_opengl && !macro)
NativeCFFI.lime_gl_draw_buffers (buffers);
#end
}

View File

@@ -470,6 +470,22 @@ namespace lime {
}
void lime_gl_draw_buffers (value buffers) {
GLsizei size = val_array_size (buffers);
GLenum *_buffers = (GLenum*)alloca (size);
for (int i = 0; i < size; i++) {
_buffers[i] = val_int (val_array_i (buffers, i));
}
glDrawBuffers (size, _buffers);
}
void lime_gl_draw_elements (int mode, int count, int type, double offset) {
glDrawElements (mode, count, type, (void*)(uintptr_t)offset);
@@ -1545,6 +1561,7 @@ namespace lime {
DEFINE_PRIME1v (lime_gl_disable);
DEFINE_PRIME1v (lime_gl_disable_vertex_attrib_array);
DEFINE_PRIME3v (lime_gl_draw_arrays);
DEFINE_PRIME1v (lime_gl_draw_buffers);
DEFINE_PRIME4v (lime_gl_draw_elements);
DEFINE_PRIME1v (lime_gl_enable);
DEFINE_PRIME1v (lime_gl_enable_vertex_attrib_array);