From e7c6a8762c93e9449ec400d2bc88f05150e36c13 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 10 Aug 2017 16:39:55 -0700 Subject: [PATCH] Add implementation of GL.drawBuffers on native --- lime/_backend/native/NativeCFFI.hx | 1 + lime/_backend/native/NativeGLRenderContext.hx | 3 +++ project/src/graphics/opengl/OpenGLBindings.cpp | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/lime/_backend/native/NativeCFFI.hx b/lime/_backend/native/NativeCFFI.hx index a5ac1c323..6d26ec81b 100644 --- a/lime/_backend/native/NativeCFFI.hx +++ b/lime/_backend/native/NativeCFFI.hx @@ -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; diff --git a/lime/_backend/native/NativeGLRenderContext.hx b/lime/_backend/native/NativeGLRenderContext.hx index e3b9b36e4..a5d8ac6e6 100644 --- a/lime/_backend/native/NativeGLRenderContext.hx +++ b/lime/_backend/native/NativeGLRenderContext.hx @@ -1378,6 +1378,9 @@ class NativeGLRenderContext { public inline function drawBuffers (buffers:Array):Void { + #if (lime_cffi && lime_opengl && !macro) + NativeCFFI.lime_gl_draw_buffers (buffers); + #end } diff --git a/project/src/graphics/opengl/OpenGLBindings.cpp b/project/src/graphics/opengl/OpenGLBindings.cpp index 5c79e5084..83f0d5b15 100644 --- a/project/src/graphics/opengl/OpenGLBindings.cpp +++ b/project/src/graphics/opengl/OpenGLBindings.cpp @@ -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);