diff --git a/lime/app/Application.hx b/lime/app/Application.hx index 6eeee0a8d..8f510b9f7 100644 --- a/lime/app/Application.hx +++ b/lime/app/Application.hx @@ -36,7 +36,7 @@ class Application implements IKeyEventListener implements IMouseEventListener im } - public function create (config:Config) { + public function create (config:Config):Void { #if (cpp || neko) handle = lime_application_create (null); @@ -62,7 +62,7 @@ class Application implements IKeyEventListener implements IMouseEventListener im } - public function exec () { + public function exec ():Int { #if (cpp || neko) return lime_application_exec (handle); diff --git a/lime/graphics/opengl/GL.hx b/lime/graphics/opengl/GL.hx index 62e4bd49b..c101e939b 100644 --- a/lime/graphics/opengl/GL.hx +++ b/lime/graphics/opengl/GL.hx @@ -9,106 +9,6 @@ import lime.utils.Int32Array; import lime.system.System; - -typedef GLActiveInfo = { - - size : Int, - type : Int, - name : String - -} //GLActiveInfo - - -class GLBuffer extends GLObject { - - override function getType ():String { - return "Buffer"; - } - -} //GLBuffer - - -typedef GLContextAttributes = { - - alpha:Bool, - depth:Bool, - stencil:Bool, - antialias:Bool, - premultipliedAlpha:Bool, - preserveDrawingBuffer:Bool - -} //GLContextAttributes - - -class GLFramebuffer extends GLObject { - - override function getType () : String { - return "Framebuffer"; - } - -} //GLFramebuffer - - -typedef GLUniformLocation = Int; - - -class GLProgram extends GLObject { - - public var shaders:Array; - - public function new( version:Int, id:Dynamic ) { - - super (version, id); - shaders = new Array (); - - } //new - - public function attach( shader:GLShader ) : Void { - shaders.push(shader); - } //attach - - public function getShaders() : Array { - return shaders.copy(); - } //getShaders - - override function getType ():String { - return "Program"; - } //getType - -} //GLProgram - - -class GLRenderbuffer extends GLObject { - - override function getType ():String { - return "Renderbuffer"; - } - -} //GLRenderbuffer - - -class GLShader extends GLObject { - - override function getType ():String { - return "Shader"; - } - -} //GLShader - - -class GLTexture extends GLObject { - - override function getType ():String { - return "Texture"; - } - -} //GLTexture - - - - - - class GL { /* ClearBufferMask */ @@ -829,7 +729,7 @@ class GL { return lime_gl_get_attrib_location(program.id, name); } - public static function getBufferParameter(target:Int, pname:Int):Dynamic + public static function getBufferParameter(target:Int, pname:Int):Int /*Dynamic*/ { return lime_gl_get_buffer_paramerter(target, pname); } @@ -854,7 +754,7 @@ class GL { // return lime_gl_get_extension(name); } - public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic + public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Int /*Dynamic*/ { return lime_gl_get_framebuffer_attachment_parameter(target, attachment, pname); } @@ -874,7 +774,7 @@ class GL { return lime_gl_get_program_parameter(program.id, pname); } - public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic + public static function getRenderbufferParameter(target:Int, pname:Int):Int /*Dynamic*/ { return lime_gl_get_render_buffer_parameter(target, pname); } @@ -906,7 +806,7 @@ class GL { return result; } - public static function getTexParameter(target:Int, pname:Int):Dynamic + public static function getTexParameter(target:Int, pname:Int):Int /*Dynamic*/ { return lime_gl_get_tex_parameter(target, pname); } @@ -916,12 +816,12 @@ class GL { return lime_gl_get_uniform(program.id, location); } - public static function getUniformLocation(program:GLProgram, name:String):Dynamic + public static function getUniformLocation(program:GLProgram, name:String):GLUniformLocation { return lime_gl_get_uniform_location(program.id, name); } - public static function getVertexAttrib(index:Int, pname:Int):Dynamic + public static function getVertexAttrib(index:Int, pname:Int):Int /*Dynamic*/ { return lime_gl_get_vertex_attrib(index, pname); } @@ -1406,52 +1306,3 @@ typedef ShaderPrecisionFormat = }; -class GLObject { - - /** The native GL handle/id. read only */ - public var id (default, null) : Dynamic; - /** The invalidated state. read only */ - public var invalidated (get, null) : Bool; - /** The valid state. read only */ - public var valid (get, null) : Bool; - - var version:Int; - - public function new (version:Int, id:Dynamic) { - - this.version = version; - this.id = id; - - } //new - - function getType() : String { - return "GLObject"; - } //getType - - public function invalidate() : Void { - id = null; - } //invalidate - - public function isValid() : Bool { - return id != null && version == GL.version; - } //isValid - - public function isInvalid() : Bool { - return !isValid (); - } //isInvalid - - public function toString() : String { - return getType() + "(" + id + ")"; - } //toString - -// Getters & Setters - - function get_invalidated() : Bool { - return isInvalid (); - } //get_invalidated - - function get_valid() : Bool { - return isValid (); - } //get_valid - -} \ No newline at end of file diff --git a/lime/graphics/opengl/GLActiveInfo.hx b/lime/graphics/opengl/GLActiveInfo.hx new file mode 100644 index 000000000..30f57cf83 --- /dev/null +++ b/lime/graphics/opengl/GLActiveInfo.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +typedef GLActiveInfo = { + + size : Int, + type : Int, + name : String + +} //GLActiveInfo \ No newline at end of file diff --git a/lime/graphics/opengl/GLBuffer.hx b/lime/graphics/opengl/GLBuffer.hx new file mode 100644 index 000000000..272583e90 --- /dev/null +++ b/lime/graphics/opengl/GLBuffer.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +class GLBuffer extends GLObject { + + override function getType ():String { + return "Buffer"; + } + +} //GLBuffer \ No newline at end of file diff --git a/lime/graphics/opengl/GLContextAttributes.hx b/lime/graphics/opengl/GLContextAttributes.hx new file mode 100644 index 000000000..2dadbb6f8 --- /dev/null +++ b/lime/graphics/opengl/GLContextAttributes.hx @@ -0,0 +1,13 @@ +package lime.graphics.opengl; + + +typedef GLContextAttributes = { + + alpha:Bool, + depth:Bool, + stencil:Bool, + antialias:Bool, + premultipliedAlpha:Bool, + preserveDrawingBuffer:Bool + +} //GLContextAttributes \ No newline at end of file diff --git a/lime/graphics/opengl/GLFramebuffer.hx b/lime/graphics/opengl/GLFramebuffer.hx new file mode 100644 index 000000000..0a1b1bc55 --- /dev/null +++ b/lime/graphics/opengl/GLFramebuffer.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +class GLFramebuffer extends GLObject { + + override function getType () : String { + return "Framebuffer"; + } + +} //GLFramebuffer \ No newline at end of file diff --git a/lime/graphics/opengl/GLObject.hx b/lime/graphics/opengl/GLObject.hx new file mode 100644 index 000000000..c25c7088a --- /dev/null +++ b/lime/graphics/opengl/GLObject.hx @@ -0,0 +1,52 @@ +package lime.graphics.opengl; + + +class GLObject { + + /** The native GL handle/id. read only */ + public var id (default, null) : Dynamic; + /** The invalidated state. read only */ + public var invalidated (get, null) : Bool; + /** The valid state. read only */ + public var valid (get, null) : Bool; + + var version:Int; + + public function new (version:Int, id:Dynamic) { + + this.version = version; + this.id = id; + + } //new + + function getType() : String { + return "GLObject"; + } //getType + + public function invalidate() : Void { + id = null; + } //invalidate + + public function isValid() : Bool { + return id != null && version == GL.version; + } //isValid + + public function isInvalid() : Bool { + return !isValid (); + } //isInvalid + + public function toString() : String { + return getType() + "(" + id + ")"; + } //toString + +// Getters & Setters + + function get_invalidated() : Bool { + return isInvalid (); + } //get_invalidated + + function get_valid() : Bool { + return isValid (); + } //get_valid + +} \ No newline at end of file diff --git a/lime/graphics/opengl/GLProgram.hx b/lime/graphics/opengl/GLProgram.hx new file mode 100644 index 000000000..a4ed0305e --- /dev/null +++ b/lime/graphics/opengl/GLProgram.hx @@ -0,0 +1,27 @@ +package lime.graphics.opengl; + + +class GLProgram extends GLObject { + + public var shaders:Array; + + public function new( version:Int, id:Dynamic ) { + + super (version, id); + shaders = new Array (); + + } //new + + public function attach( shader:GLShader ) : Void { + shaders.push(shader); + } //attach + + public function getShaders() : Array { + return shaders.copy(); + } //getShaders + + override function getType ():String { + return "Program"; + } //getType + +} //GLProgram \ No newline at end of file diff --git a/lime/graphics/opengl/GLRenderbuffer.hx b/lime/graphics/opengl/GLRenderbuffer.hx new file mode 100644 index 000000000..27ae3d8ef --- /dev/null +++ b/lime/graphics/opengl/GLRenderbuffer.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +class GLRenderbuffer extends GLObject { + + override function getType ():String { + return "Renderbuffer"; + } + +} //GLRenderbuffer \ No newline at end of file diff --git a/lime/graphics/opengl/GLShader.hx b/lime/graphics/opengl/GLShader.hx new file mode 100644 index 000000000..ddddbf7b3 --- /dev/null +++ b/lime/graphics/opengl/GLShader.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +class GLShader extends GLObject { + + override function getType ():String { + return "Shader"; + } + +} //GLShader \ No newline at end of file diff --git a/lime/graphics/opengl/GLTexture.hx b/lime/graphics/opengl/GLTexture.hx new file mode 100644 index 000000000..0a123b20e --- /dev/null +++ b/lime/graphics/opengl/GLTexture.hx @@ -0,0 +1,10 @@ +package lime.graphics.opengl; + + +class GLTexture extends GLObject { + + override function getType ():String { + return "Texture"; + } + +} //GLTexture \ No newline at end of file diff --git a/lime/graphics/opengl/GLUniformLocation.hx b/lime/graphics/opengl/GLUniformLocation.hx new file mode 100644 index 000000000..22a7fef0b --- /dev/null +++ b/lime/graphics/opengl/GLUniformLocation.hx @@ -0,0 +1,4 @@ +package lime.graphics.opengl; + + +typedef GLUniformLocation = Int; \ No newline at end of file diff --git a/project/src/graphics/RenderEvent.cpp b/project/src/graphics/RenderEvent.cpp new file mode 100644 index 000000000..7c69b1c0f --- /dev/null +++ b/project/src/graphics/RenderEvent.cpp @@ -0,0 +1,43 @@ +#include +#include + + +namespace lime { + + + AutoGCRoot* RenderEvent::callback = 0; + AutoGCRoot* RenderEvent::eventObject = 0; + + //static int id_type; + //static bool init = false; + + + RenderEvent::RenderEvent () { + + type = RENDER; + + } + + + void RenderEvent::Dispatch (RenderEvent* event) { + + if (RenderEvent::callback) { + + //if (!init) { + + //id_type = val_id ("type"); + + //} + + value object = (RenderEvent::eventObject ? RenderEvent::eventObject->get () : alloc_empty_object ()); + + //alloc_field (object, id_type, alloc_int (event->type)); + + val_call1 (RenderEvent::callback->get (), object); + + } + + } + + +} \ No newline at end of file