Seperate out GL classes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<GLShader>;
|
||||
|
||||
public function new( version:Int, id:Dynamic ) {
|
||||
|
||||
super (version, id);
|
||||
shaders = new Array<GLShader> ();
|
||||
|
||||
} //new
|
||||
|
||||
public function attach( shader:GLShader ) : Void {
|
||||
shaders.push(shader);
|
||||
} //attach
|
||||
|
||||
public function getShaders() : Array<GLShader> {
|
||||
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
|
||||
|
||||
}
|
||||
10
lime/graphics/opengl/GLActiveInfo.hx
Normal file
10
lime/graphics/opengl/GLActiveInfo.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
typedef GLActiveInfo = {
|
||||
|
||||
size : Int,
|
||||
type : Int,
|
||||
name : String
|
||||
|
||||
} //GLActiveInfo
|
||||
10
lime/graphics/opengl/GLBuffer.hx
Normal file
10
lime/graphics/opengl/GLBuffer.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLBuffer extends GLObject {
|
||||
|
||||
override function getType ():String {
|
||||
return "Buffer";
|
||||
}
|
||||
|
||||
} //GLBuffer
|
||||
13
lime/graphics/opengl/GLContextAttributes.hx
Normal file
13
lime/graphics/opengl/GLContextAttributes.hx
Normal file
@@ -0,0 +1,13 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
typedef GLContextAttributes = {
|
||||
|
||||
alpha:Bool,
|
||||
depth:Bool,
|
||||
stencil:Bool,
|
||||
antialias:Bool,
|
||||
premultipliedAlpha:Bool,
|
||||
preserveDrawingBuffer:Bool
|
||||
|
||||
} //GLContextAttributes
|
||||
10
lime/graphics/opengl/GLFramebuffer.hx
Normal file
10
lime/graphics/opengl/GLFramebuffer.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLFramebuffer extends GLObject {
|
||||
|
||||
override function getType () : String {
|
||||
return "Framebuffer";
|
||||
}
|
||||
|
||||
} //GLFramebuffer
|
||||
52
lime/graphics/opengl/GLObject.hx
Normal file
52
lime/graphics/opengl/GLObject.hx
Normal file
@@ -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
|
||||
|
||||
}
|
||||
27
lime/graphics/opengl/GLProgram.hx
Normal file
27
lime/graphics/opengl/GLProgram.hx
Normal file
@@ -0,0 +1,27 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLProgram extends GLObject {
|
||||
|
||||
public var shaders:Array<GLShader>;
|
||||
|
||||
public function new( version:Int, id:Dynamic ) {
|
||||
|
||||
super (version, id);
|
||||
shaders = new Array<GLShader> ();
|
||||
|
||||
} //new
|
||||
|
||||
public function attach( shader:GLShader ) : Void {
|
||||
shaders.push(shader);
|
||||
} //attach
|
||||
|
||||
public function getShaders() : Array<GLShader> {
|
||||
return shaders.copy();
|
||||
} //getShaders
|
||||
|
||||
override function getType ():String {
|
||||
return "Program";
|
||||
} //getType
|
||||
|
||||
} //GLProgram
|
||||
10
lime/graphics/opengl/GLRenderbuffer.hx
Normal file
10
lime/graphics/opengl/GLRenderbuffer.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLRenderbuffer extends GLObject {
|
||||
|
||||
override function getType ():String {
|
||||
return "Renderbuffer";
|
||||
}
|
||||
|
||||
} //GLRenderbuffer
|
||||
10
lime/graphics/opengl/GLShader.hx
Normal file
10
lime/graphics/opengl/GLShader.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLShader extends GLObject {
|
||||
|
||||
override function getType ():String {
|
||||
return "Shader";
|
||||
}
|
||||
|
||||
} //GLShader
|
||||
10
lime/graphics/opengl/GLTexture.hx
Normal file
10
lime/graphics/opengl/GLTexture.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
class GLTexture extends GLObject {
|
||||
|
||||
override function getType ():String {
|
||||
return "Texture";
|
||||
}
|
||||
|
||||
} //GLTexture
|
||||
4
lime/graphics/opengl/GLUniformLocation.hx
Normal file
4
lime/graphics/opengl/GLUniformLocation.hx
Normal file
@@ -0,0 +1,4 @@
|
||||
package lime.graphics.opengl;
|
||||
|
||||
|
||||
typedef GLUniformLocation = Int;
|
||||
43
project/src/graphics/RenderEvent.cpp
Normal file
43
project/src/graphics/RenderEvent.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <hx/CFFI.h>
|
||||
#include <graphics/RenderEvent.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user