diff --git a/buildfiles/html5/haxe/ApplicationMain.hx b/buildfiles/html5/haxe/ApplicationMain.hx
new file mode 100755
index 000000000..546bb9604
--- /dev/null
+++ b/buildfiles/html5/haxe/ApplicationMain.hx
@@ -0,0 +1,204 @@
+#if (!lime && !flambe)
+
+
+import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::;
+import nme.display.Bitmap;
+import nme.display.Loader;
+import nme.events.Event;
+import nme.media.Sound;
+import nme.net.URLLoader;
+import nme.net.URLRequest;
+import nme.net.URLLoaderDataFormat;
+import nme.Assets;
+import nme.Lib;
+
+
+class ApplicationMain {
+
+
+ private static var completed:Int;
+ private static var preloader:NMEPreloader;
+ private static var total:Int;
+
+ public static var loaders:Hash ;
+ public static var urlLoaders:Hash ;
+
+
+ public static function main () {
+
+ completed = 0;
+ loaders = new Hash ();
+ urlLoaders = new Hash ();
+ total = 0;
+
+ ::if (WIN_WIDTH == "0")::::if (WIN_HEIGHT == "0")::
+ browser.Lib.preventDefaultTouchMove ();
+ ::end::::end::
+
+ ::if (PRELOADER_NAME!="")::
+ preloader = new ::PRELOADER_NAME:: ();
+ ::else::
+ preloader = new NMEPreloader ();
+ ::end::
+ Lib.current.addChild (preloader);
+ preloader.onInit ();
+
+ ::foreach assets::
+ ::if (type=="image")::
+ var loader:Loader = new Loader ();
+ loaders.set ("::resourceName::", loader);
+ total ++;
+ ::elseif (type == "binary")::
+ var urlLoader:URLLoader = new URLLoader ();
+ urlLoader.dataFormat = BINARY;
+ urlLoaders.set ("::resourceName::", urlLoader);
+ total ++;
+ ::elseif (type == "text")::
+ var urlLoader:URLLoader = new URLLoader ();
+ urlLoader.dataFormat = TEXT;
+ urlLoaders.set ("::resourceName::", urlLoader);
+ total ++;
+ ::end::::end::
+
+ if (total == 0) {
+
+ begin ();
+
+ } else {
+
+ for (path in loaders.keys ()) {
+
+ var loader:Loader = loaders.get (path);
+ loader.contentLoaderInfo.addEventListener ("complete", loader_onComplete);
+ loader.load (new URLRequest (path));
+
+ }
+
+ for (path in urlLoaders.keys ()) {
+
+ var urlLoader:URLLoader = urlLoaders.get (path);
+ urlLoader.addEventListener ("complete", loader_onComplete);
+ urlLoader.load (new URLRequest (path));
+
+ }
+
+ }
+
+ }
+
+
+ private static function begin ():Void {
+
+ preloader.addEventListener (Event.COMPLETE, preloader_onComplete);
+ preloader.onLoaded ();
+
+ }
+
+
+ public static function getAsset(inName:String):Dynamic {
+
+ ::foreach assets::
+ if (inName=="::id::") {
+ ::if (type == "image")::
+ return Assets.getBitmapData ("::id::");
+ ::elseif (type=="sound")::
+ return Assets.getSound ("::id::");
+ ::elseif (type=="music")::
+ return Assets.getSound ("::id::");
+ ::elseif (type== "font")::
+ return Assets.getFont ("::id::");
+ ::elseif (type== "text")::
+ return Assets.getText ("::id::");
+ ::else::
+ return Assets.getBytes ("::id::");
+ ::end::
+ }
+ ::end::
+ return null;
+
+ }
+
+
+
+
+ // Event Handlers
+
+
+
+
+ private static function loader_onComplete (event:Event):Void {
+
+ completed ++;
+
+ preloader.onUpdate (completed, total);
+
+ if (completed == total) {
+
+ begin ();
+
+ }
+
+ }
+
+
+ private static function preloader_onComplete (event:Event):Void {
+
+ preloader.removeEventListener (Event.COMPLETE, preloader_onComplete);
+
+ Lib.current.removeChild(preloader);
+ preloader = null;
+
+ if (Reflect.field(::APP_MAIN::, "main") == null)
+ {
+ var mainDisplayObj = new ::APP_MAIN::();
+ if (Std.is(mainDisplayObj, browser.display.DisplayObject))
+ nme.Lib.current.addChild(cast mainDisplayObj);
+ }
+ else
+ {
+ Reflect.callMethod (::APP_MAIN::, Reflect.field (::APP_MAIN::, "main"), []);
+ }
+
+ }
+
+
+}
+
+
+::foreach assets::
+ ::if (type=="font")::
+ class NME_::flatName:: extends nme.text.Font { }
+ ::end::
+::end::
+
+
+#else
+
+
+import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::;
+import lime.LiME;
+
+class ApplicationMain {
+
+ public static function main () {
+
+ //Create the game class, give it the runtime
+ var _main_ = Type.createInstance (::APP_MAIN::, []);
+ //Create an instance of lime
+ var _lime = new LiME();
+
+ //Create the config from the project.nmml info
+ var config = {
+ width : ::WIN_WIDTH::,
+ height : ::WIN_HEIGHT::,
+ title : "::APP_TITLE::"
+ };
+
+ //Start up
+ _lime.init( _main_, config );
+
+ } //main
+} //ApplicationMain
+
+
+#end
\ No newline at end of file
diff --git a/buildfiles/html5/haxe/nme/AssetData.hx b/buildfiles/html5/haxe/nme/AssetData.hx
new file mode 100644
index 000000000..cbbbd2c16
--- /dev/null
+++ b/buildfiles/html5/haxe/nme/AssetData.hx
@@ -0,0 +1,38 @@
+package nme;
+
+
+import lime.utils.Assets;
+
+
+class AssetData {
+
+
+ public static var className = new Map ();
+ public static var library = new Map ();
+ public static var path = new Map ();
+ public static var type = new Map ();
+
+ private static var initialized:Bool = false;
+
+
+ public static function initialize ():Void {
+
+ if (!initialized) {
+
+ ::if (assets != null)::::foreach assets::::if (type == "font")::className.set ("::id::", nme.NME_::flatName::);::else::path.set ("::id::", "::resourceName::");::end::
+ type.set ("::id::", Reflect.field (AssetType, "::type::".toUpperCase ()));
+ ::end::::end::
+ ::if (libraries != null)::::foreach libraries::library.set ("::name::", Reflect.field (LibraryType, "::type::".toUpperCase ()));
+ ::end::::end::
+ initialized = true;
+
+ }
+
+ }
+
+
+}
+
+
+::foreach assets::::if (type == "font")::class NME_::flatName:: extends flash.text.Font { }::end::
+::end::
\ No newline at end of file
diff --git a/buildfiles/html5/haxe/nme/installer/Assets.hx b/buildfiles/html5/haxe/nme/installer/Assets.hx
new file mode 100755
index 000000000..e2417b0b8
--- /dev/null
+++ b/buildfiles/html5/haxe/nme/installer/Assets.hx
@@ -0,0 +1,324 @@
+package nme.installer;
+
+
+import format.display.MovieClip;
+import haxe.Unserializer;
+import nme.display.Bitmap;
+import nme.display.BitmapData;
+import nme.media.Sound;
+import nme.net.URLRequest;
+import nme.text.Font;
+import nme.utils.ByteArray;
+import ApplicationMain;
+
+#if swfdev
+import format.swf.lite.SWFLite;
+#end
+
+#if xfl
+import format.XFL;
+#end
+
+
+/**
+ * ...
+ * @author Joshua Granick
+ */
+
+class Assets {
+
+
+ public static var cachedBitmapData:Hash = new Hash();
+ #if swfdev private static var cachedSWFLibraries:Hash = new Hash (); #end
+ #if xfl private static var cachedXFLLibraries:Hash = new Hash (); #end
+
+ private static var initialized:Bool = false;
+ private static var libraryTypes:Hash = new Hash ();
+ private static var resourceClasses:Hash = new Hash ();
+ private static var resourceNames:Hash = new Hash ();
+ private static var resourceTypes:Hash = new Hash ();
+
+
+ private static function initialize ():Void {
+
+ if (!initialized) {
+
+ ::foreach assets::
+ ::if (type == "font")::resourceClasses.set ("::id::", NME_::flatName::);::end::
+ resourceNames.set ("::id::", "::resourceName::");
+ resourceTypes.set ("::id::", "::type::");
+ ::end::
+ ::foreach libraries::libraryTypes.set ("::name::", "::type::");::end::
+ initialized = true;
+
+ }
+
+ }
+
+
+ public static function getBitmapData (id:String, useCache:Bool = true):BitmapData {
+
+ initialize ();
+
+ if (resourceNames.exists(id) && resourceTypes.exists (id) && resourceTypes.get (id).toLowerCase () == "image") {
+
+ if (useCache && cachedBitmapData.exists (id)) {
+
+ return cachedBitmapData.get (id);
+
+ } else {
+
+ // Should be bitmapData.clone (), but stopped working in recent Jeash builds
+ // Without clone, BitmapData is already cached, so ignoring the hash table for now
+
+ var data = cast (ApplicationMain.loaders.get (resourceNames.get(id)).contentLoaderInfo.content, Bitmap).bitmapData;
+
+ if (useCache) {
+
+ cachedBitmapData.set (id, data);
+
+ }
+
+ return data;
+
+ }
+
+ } else if (id.indexOf (":") > -1) {
+
+ var libraryName = id.substr (0, id.indexOf (":"));
+ var symbolName = id.substr (id.indexOf (":") + 1);
+
+ if (libraryTypes.exists (libraryName)) {
+
+ #if swfdev
+
+ if (libraryTypes.get (libraryName) == "swf") {
+
+ if (!cachedSWFLibraries.exists (libraryName)) {
+
+ var unserializer = new Unserializer (getText ("libraries/" + libraryName + ".dat"));
+ unserializer.setResolver (cast { resolveEnum: resolveEnum, resolveClass: resolveClass });
+ cachedSWFLibraries.set (libraryName, unserializer.unserialize());
+
+ }
+
+ return cachedSWFLibraries.get (libraryName).getBitmapData (symbolName);
+
+ }
+
+ #end
+
+ #if xfl
+
+ if (libraryTypes.get (libraryName) == "xfl") {
+
+ if (!cachedXFLLibraries.exists (libraryName)) {
+
+ cachedXFLLibraries.set (libraryName, Unserializer.run (getText ("libraries/" + libraryName + "/" + libraryName + ".dat")));
+
+ }
+
+ return cachedXFLLibraries.get (libraryName).getBitmapData (symbolName);
+
+ }
+
+ #end
+
+ } else {
+
+ trace ("[nme.Assets] There is no asset library named \"" + libraryName + "\"");
+
+ }
+
+ } else {
+
+ trace ("[nme.Assets] There is no BitmapData asset with an ID of \"" + id + "\"");
+
+ }
+
+ return null;
+
+ }
+
+
+ public static function getBytes (id:String):ByteArray {
+
+ initialize ();
+
+ if (resourceNames.exists (id)) {
+
+ return cast ApplicationMain.urlLoaders.get (getResourceName(id)).data;
+
+ }
+
+ trace ("[nme.Assets] There is no String or ByteArray asset with an ID of \"" + id + "\"");
+
+ return null;
+
+ }
+
+
+ public static function getFont (id:String):Font {
+
+ initialize ();
+
+ if (resourceNames.exists(id) && resourceTypes.exists (id)) {
+
+ if (resourceTypes.get (id).toLowerCase () == "font") {
+
+ return cast (Type.createInstance (resourceClasses.get (id), []), Font);
+
+ }
+
+ }
+
+ trace ("[nme.Assets] There is no Font asset with an ID of \"" + id + "\"");
+
+ return null;
+
+ }
+
+
+ public static function getMovieClip (id:String):MovieClip {
+
+ initialize ();
+
+ var libraryName = id.substr (0, id.indexOf (":"));
+ var symbolName = id.substr (id.indexOf (":") + 1);
+
+ if (libraryTypes.exists (libraryName)) {
+
+ #if swfdev
+
+ if (libraryTypes.get (libraryName) == "swf") {
+
+ if (!cachedSWFLibraries.exists (libraryName)) {
+
+ var unserializer = new Unserializer (getText ("libraries/" + libraryName + ".dat"));
+ unserializer.setResolver (cast { resolveEnum: resolveEnum, resolveClass: resolveClass });
+ cachedSWFLibraries.set (libraryName, unserializer.unserialize());
+
+ }
+
+ return cachedSWFLibraries.get (libraryName).createMovieClip (symbolName);
+
+ }
+
+ #end
+
+ #if xfl
+
+ if (libraryTypes.get (libraryName) == "xfl") {
+
+ if (!cachedXFLLibraries.exists (libraryName)) {
+
+ cachedXFLLibraries.set (libraryName, Unserializer.run (getText ("libraries/" + libraryName + "/" + libraryName + ".dat")));
+
+ }
+
+ return cachedXFLLibraries.get (libraryName).createMovieClip (symbolName);
+
+ }
+
+ #end
+
+ } else {
+
+ trace ("[nme.Assets] There is no asset library named \"" + libraryName + "\"");
+
+ }
+
+ return null;
+
+ }
+
+
+ public static function getResourceName (id:String):String {
+
+ initialize ();
+
+ return resourceNames.get (id);
+
+ }
+
+
+ public static function getSound (id:String):Sound {
+
+ initialize ();
+
+ if (resourceNames.exists(id) && resourceTypes.exists (id)) {
+
+ if (resourceTypes.get (id).toLowerCase () == "sound") {
+
+ return new Sound (new URLRequest (resourceNames.get(id)));
+
+ } else if (resourceTypes.get (id).toLowerCase () == "music") {
+
+ return new Sound (new URLRequest (resourceNames.get(id)));
+
+ }
+
+ }
+
+ trace ("[nme.Assets] There is no Sound asset with an ID of \"" + id + "\"");
+
+ return null;
+
+ }
+
+
+ public static function getText (id:String):String {
+
+ initialize ();
+
+ if (resourceNames.exists(id) && resourceTypes.exists (id)) {
+
+ if (resourceTypes.get (id).toLowerCase () == "text") {
+
+ return ApplicationMain.urlLoaders.get (resourceNames.get(id)).data;
+
+ }
+
+ }
+
+ var bytes = getBytes (id);
+ return null;
+
+ }
+
+
+ //public static function loadBitmapData(id:String, handler:BitmapData -> Void, useCache:Bool = true):BitmapData
+ //{
+ //return null;
+ //}
+ //
+ //
+ //public static function loadBytes(id:String, handler:ByteArray -> Void):ByteArray
+ //{
+ //return null;
+ //}
+ //
+ //
+ //public static function loadText(id:String, handler:String -> Void):String
+ //{
+ //return null;
+ //}
+
+
+ private static function resolveClass (name:String):Class {
+
+ name = StringTools.replace (name, "native.", "browser.");
+ return Type.resolveClass (name);
+
+ }
+
+
+ private static function resolveEnum (name:String):Enum {
+
+ name = StringTools.replace (name, "native.", "browser.");
+ return Type.resolveEnum (name);
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/buildfiles/html5/hxml/debug.hxml b/buildfiles/html5/hxml/debug.hxml
new file mode 100755
index 000000000..dac45f5cf
--- /dev/null
+++ b/buildfiles/html5/hxml/debug.hxml
@@ -0,0 +1,9 @@
+-main ApplicationMain ::HAXE_FLAGS::
+-js ::OUTPUT_FILE::
+-cp ::OUTPUT_DIR::/haxe
+-D html5
+-D html
+--remap flash:lime
+--remap native:lime
+-debug
+#--js-modern
\ No newline at end of file
diff --git a/buildfiles/html5/hxml/release.hxml b/buildfiles/html5/hxml/release.hxml
new file mode 100755
index 000000000..c1f6ccc7b
--- /dev/null
+++ b/buildfiles/html5/hxml/release.hxml
@@ -0,0 +1,8 @@
+-main ApplicationMain ::HAXE_FLAGS::
+-js ::OUTPUT_FILE::
+-cp ::OUTPUT_DIR::/haxe
+-D html5
+-D html
+--remap flash:lime
+--remap native:lime
+#--js-modern
\ No newline at end of file
diff --git a/buildfiles/html5/hxswfml.n b/buildfiles/html5/hxswfml.n
new file mode 100755
index 000000000..08b25cd86
Binary files /dev/null and b/buildfiles/html5/hxswfml.n differ
diff --git a/buildfiles/html5/template/index.html b/buildfiles/html5/template/index.html
new file mode 100755
index 000000000..1ad943b34
--- /dev/null
+++ b/buildfiles/html5/template/index.html
@@ -0,0 +1,31 @@
+
+
+
+
+ ::APP_TITLE::
+
+
+
+
+
+ ::if (LIB_NME)::
+
+
+
+ ::if DEBUG::::end::
+
+
+
+
+ ::else::
+
+
+
+ ::end::
+
+ ::if DEBUG::::end::
+
+
+
+
\ No newline at end of file
diff --git a/buildfiles/html5/template/webgl-debug.js b/buildfiles/html5/template/webgl-debug.js
new file mode 100755
index 000000000..e2422761d
--- /dev/null
+++ b/buildfiles/html5/template/webgl-debug.js
@@ -0,0 +1,798 @@
+//Copyright (c) 2009 The Chromium Authors. All rights reserved.
+//Use of this source code is governed by a BSD-style license that can be
+//found in the LICENSE file.
+
+// Various functions for helping debug WebGL apps.
+
+WebGLDebugUtils = function() {
+
+/**
+ * Wrapped logging function.
+ * @param {string} msg Message to log.
+ */
+var log = function(msg) {
+ if (window.console && window.console.log) {
+ window.console.log(msg);
+ }
+};
+
+/**
+ * Which arguements are enums.
+ * @type {!Object.}
+ */
+var glValidEnumContexts = {
+
+ // Generic setters and getters
+
+ 'enable': { 0:true },
+ 'disable': { 0:true },
+ 'getParameter': { 0:true },
+
+ // Rendering
+
+ 'drawArrays': { 0:true },
+ 'drawElements': { 0:true, 2:true },
+
+ // Shaders
+
+ 'createShader': { 0:true },
+ 'getShaderParameter': { 1:true },
+ 'getProgramParameter': { 1:true },
+
+ // Vertex attributes
+
+ 'getVertexAttrib': { 1:true },
+ 'vertexAttribPointer': { 2:true },
+
+ // Textures
+
+ 'bindTexture': { 0:true },
+ 'activeTexture': { 0:true },
+ 'getTexParameter': { 0:true, 1:true },
+ 'texParameterf': { 0:true, 1:true },
+ 'texParameteri': { 0:true, 1:true, 2:true },
+ 'texImage2D': { 0:true, 2:true, 6:true, 7:true },
+ 'texSubImage2D': { 0:true, 6:true, 7:true },
+ 'copyTexImage2D': { 0:true, 2:true },
+ 'copyTexSubImage2D': { 0:true },
+ 'generateMipmap': { 0:true },
+
+ // Buffer objects
+
+ 'bindBuffer': { 0:true },
+ 'bufferData': { 0:true, 2:true },
+ 'bufferSubData': { 0:true },
+ 'getBufferParameter': { 0:true, 1:true },
+
+ // Renderbuffers and framebuffers
+
+ 'pixelStorei': { 0:true, 1:true },
+ 'readPixels': { 4:true, 5:true },
+ 'bindRenderbuffer': { 0:true },
+ 'bindFramebuffer': { 0:true },
+ 'checkFramebufferStatus': { 0:true },
+ 'framebufferRenderbuffer': { 0:true, 1:true, 2:true },
+ 'framebufferTexture2D': { 0:true, 1:true, 2:true },
+ 'getFramebufferAttachmentParameter': { 0:true, 1:true, 2:true },
+ 'getRenderbufferParameter': { 0:true, 1:true },
+ 'renderbufferStorage': { 0:true, 1:true },
+
+ // Frame buffer operations (clear, blend, depth test, stencil)
+
+ 'clear': { 0:true },
+ 'depthFunc': { 0:true },
+ 'blendFunc': { 0:true, 1:true },
+ 'blendFuncSeparate': { 0:true, 1:true, 2:true, 3:true },
+ 'blendEquation': { 0:true },
+ 'blendEquationSeparate': { 0:true, 1:true },
+ 'stencilFunc': { 0:true },
+ 'stencilFuncSeparate': { 0:true, 1:true },
+ 'stencilMaskSeparate': { 0:true },
+ 'stencilOp': { 0:true, 1:true, 2:true },
+ 'stencilOpSeparate': { 0:true, 1:true, 2:true, 3:true },
+
+ // Culling
+
+ 'cullFace': { 0:true },
+ 'frontFace': { 0:true },
+};
+
+/**
+ * Map of numbers to names.
+ * @type {Object}
+ */
+var glEnums = null;
+
+/**
+ * Initializes this module. Safe to call more than once.
+ * @param {!WebGLRenderingContext} ctx A WebGL context. If
+ * you have more than one context it doesn't matter which one
+ * you pass in, it is only used to pull out constants.
+ */
+function init(ctx) {
+ if (glEnums == null) {
+ glEnums = { };
+ for (var propertyName in ctx) {
+ if (typeof ctx[propertyName] == 'number') {
+ glEnums[ctx[propertyName]] = propertyName;
+ }
+ }
+ }
+}
+
+/**
+ * Checks the utils have been initialized.
+ */
+function checkInit() {
+ if (glEnums == null) {
+ throw 'WebGLDebugUtils.init(ctx) not called';
+ }
+}
+
+/**
+ * Returns true or false if value matches any WebGL enum
+ * @param {*} value Value to check if it might be an enum.
+ * @return {boolean} True if value matches one of the WebGL defined enums
+ */
+function mightBeEnum(value) {
+ checkInit();
+ return (glEnums[value] !== undefined);
+}
+
+/**
+ * Gets an string version of an WebGL enum.
+ *
+ * Example:
+ * var str = WebGLDebugUtil.glEnumToString(ctx.getError());
+ *
+ * @param {number} value Value to return an enum for
+ * @return {string} The string version of the enum.
+ */
+function glEnumToString(value) {
+ checkInit();
+ var name = glEnums[value];
+ return (name !== undefined) ? name :
+ ("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
+}
+
+/**
+ * Returns the string version of a WebGL argument.
+ * Attempts to convert enum arguments to strings.
+ * @param {string} functionName the name of the WebGL function.
+ * @param {number} argumentIndx the index of the argument.
+ * @param {*} value The value of the argument.
+ * @return {string} The value as a string.
+ */
+function glFunctionArgToString(functionName, argumentIndex, value) {
+ var funcInfo = glValidEnumContexts[functionName];
+ if (funcInfo !== undefined) {
+ if (funcInfo[argumentIndex]) {
+ return glEnumToString(value);
+ }
+ }
+ return value.toString();
+}
+
+function makePropertyWrapper(wrapper, original, propertyName) {
+ //log("wrap prop: " + propertyName);
+ wrapper.__defineGetter__(propertyName, function() {
+ return original[propertyName];
+ });
+ // TODO(gmane): this needs to handle properties that take more than
+ // one value?
+ wrapper.__defineSetter__(propertyName, function(value) {
+ //log("set: " + propertyName);
+ original[propertyName] = value;
+ });
+}
+
+// Makes a function that calls a function on another object.
+function makeFunctionWrapper(original, functionName) {
+ //log("wrap fn: " + functionName);
+ var f = original[functionName];
+ return function() {
+ //log("call: " + functionName);
+ var result = f.apply(original, arguments);
+ return result;
+ };
+}
+
+/**
+ * Given a WebGL context returns a wrapped context that calls
+ * gl.getError after every command and calls a function if the
+ * result is not gl.NO_ERROR.
+ *
+ * @param {!WebGLRenderingContext} ctx The webgl context to
+ * wrap.
+ * @param {!function(err, funcName, args): void} opt_onErrorFunc
+ * The function to call when gl.getError returns an
+ * error. If not specified the default function calls
+ * console.log with a message.
+ */
+function makeDebugContext(ctx, opt_onErrorFunc) {
+ init(ctx);
+ opt_onErrorFunc = opt_onErrorFunc || function(err, functionName, args) {
+ // apparently we can't do args.join(",");
+ var argStr = "";
+ for (var ii = 0; ii < args.length; ++ii) {
+ argStr += ((ii == 0) ? '' : ', ') +
+ glFunctionArgToString(functionName, ii, args[ii]);
+ }
+ log("WebGL error "+ glEnumToString(err) + " in "+ functionName +
+ "(" + argStr + ")");
+ };
+
+ // Holds booleans for each GL error so after we get the error ourselves
+ // we can still return it to the client app.
+ var glErrorShadow = { };
+
+ // Makes a function that calls a WebGL function and then calls getError.
+ function makeErrorWrapper(ctx, functionName) {
+ return function() {
+ var result = ctx[functionName].apply(ctx, arguments);
+ var err = ctx.getError();
+ if (err != 0) {
+ glErrorShadow[err] = true;
+ opt_onErrorFunc(err, functionName, arguments);
+ }
+ return result;
+ };
+ }
+
+ // Make a an object that has a copy of every property of the WebGL context
+ // but wraps all functions.
+ var wrapper = {};
+ for (var propertyName in ctx) {
+ if (typeof ctx[propertyName] == 'function') {
+ wrapper[propertyName] = makeErrorWrapper(ctx, propertyName);
+ } else {
+ makePropertyWrapper(wrapper, ctx, propertyName);
+ }
+ }
+
+ // Override the getError function with one that returns our saved results.
+ wrapper.getError = function() {
+ for (var err in glErrorShadow) {
+ if (glErrorShadow[err]) {
+ glErrorShadow[err] = false;
+ return err;
+ }
+ }
+ return ctx.NO_ERROR;
+ };
+
+ return wrapper;
+}
+
+function resetToInitialState(ctx) {
+ var numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS);
+ var tmp = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, tmp);
+ for (var ii = 0; ii < numAttribs; ++ii) {
+ ctx.disableVertexAttribArray(ii);
+ ctx.vertexAttribPointer(ii, 4, ctx.FLOAT, false, 0, 0);
+ ctx.vertexAttrib1f(ii, 0);
+ }
+ ctx.deleteBuffer(tmp);
+
+ var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);
+ for (var ii = 0; ii < numTextureUnits; ++ii) {
+ ctx.activeTexture(ctx.TEXTURE0 + ii);
+ ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);
+ ctx.bindTexture(ctx.TEXTURE_2D, null);
+ }
+
+ ctx.activeTexture(ctx.TEXTURE0);
+ ctx.useProgram(null);
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, null);
+ ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);
+ ctx.bindFramebuffer(ctx.FRAMEBUFFER, null);
+ ctx.bindRenderbuffer(ctx.RENDERBUFFER, null);
+ ctx.disable(ctx.BLEND);
+ ctx.disable(ctx.CULL_FACE);
+ ctx.disable(ctx.DEPTH_TEST);
+ ctx.disable(ctx.DITHER);
+ ctx.disable(ctx.SCISSOR_TEST);
+ ctx.blendColor(0, 0, 0, 0);
+ ctx.blendEquation(ctx.FUNC_ADD);
+ ctx.blendFunc(ctx.ONE, ctx.ZERO);
+ ctx.clearColor(0, 0, 0, 0);
+ ctx.clearDepth(1);
+ ctx.clearStencil(-1);
+ ctx.colorMask(true, true, true, true);
+ ctx.cullFace(ctx.BACK);
+ ctx.depthFunc(ctx.LESS);
+ ctx.depthMask(true);
+ ctx.depthRange(0, 1);
+ ctx.frontFace(ctx.CCW);
+ ctx.hint(ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE);
+ ctx.lineWidth(1);
+ ctx.pixelStorei(ctx.PACK_ALIGNMENT, 4);
+ ctx.pixelStorei(ctx.UNPACK_ALIGNMENT, 4);
+ ctx.pixelStorei(ctx.UNPACK_FLIP_Y_WEBGL, false);
+ ctx.pixelStorei(ctx.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ // TODO: Delete this IF.
+ if (ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL) {
+ ctx.pixelStorei(ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL, ctx.BROWSER_DEFAULT_WEBGL);
+ }
+ ctx.polygonOffset(0, 0);
+ ctx.sampleCoverage(1, false);
+ ctx.scissor(0, 0, ctx.canvas.width, ctx.canvas.height);
+ ctx.stencilFunc(ctx.ALWAYS, 0, 0xFFFFFFFF);
+ ctx.stencilMask(0xFFFFFFFF);
+ ctx.stencilOp(ctx.KEEP, ctx.KEEP, ctx.KEEP);
+ ctx.viewport(0, 0, ctx.canvas.width, ctx.canvas.height);
+ ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT | ctx.STENCIL_BUFFER_BIT);
+
+ // TODO: This should NOT be needed but Firefox fails with 'hint'
+ while(ctx.getError());
+}
+
+function makeLostContextSimulatingCanvas(canvas) {
+ var unwrappedContext_;
+ var wrappedContext_;
+ var onLost_ = [];
+ var onRestored_ = [];
+ var wrappedContext_ = {};
+ var contextId_ = 1;
+ var contextLost_ = false;
+ var resourceId_ = 0;
+ var resourceDb_ = [];
+ var numCallsToLoseContext_ = 0;
+ var numCalls_ = 0;
+ var canRestore_ = false;
+ var restoreTimeout_ = 0;
+
+ // Holds booleans for each GL error so can simulate errors.
+ var glErrorShadow_ = { };
+
+ canvas.getContext = function(f) {
+ return function() {
+ var ctx = f.apply(canvas, arguments);
+ // Did we get a context and is it a WebGL context?
+ if (ctx instanceof WebGLRenderingContext) {
+ if (ctx != unwrappedContext_) {
+ if (unwrappedContext_) {
+ throw "got different context"
+ }
+ unwrappedContext_ = ctx;
+ wrappedContext_ = makeLostContextSimulatingContext(unwrappedContext_);
+ }
+ return wrappedContext_;
+ }
+ return ctx;
+ }
+ }(canvas.getContext);
+
+ function wrapEvent(listener) {
+ if (typeof(listener) == "function") {
+ return listener;
+ } else {
+ return function(info) {
+ listener.handleEvent(info);
+ }
+ }
+ }
+
+ var addOnContextLostListener = function(listener) {
+ onLost_.push(wrapEvent(listener));
+ };
+
+ var addOnContextRestoredListener = function(listener) {
+ onRestored_.push(wrapEvent(listener));
+ };
+
+
+ function wrapAddEventListener(canvas) {
+ var f = canvas.addEventListener;
+ canvas.addEventListener = function(type, listener, bubble) {
+ switch (type) {
+ case 'webglcontextlost':
+ addOnContextLostListener(listener);
+ break;
+ case 'webglcontextrestored':
+ addOnContextRestoredListener(listener);
+ break;
+ default:
+ f.apply(canvas, arguments);
+ }
+ };
+ }
+
+ wrapAddEventListener(canvas);
+
+ canvas.loseContext = function() {
+ if (!contextLost_) {
+ contextLost_ = true;
+ numCallsToLoseContext_ = 0;
+ ++contextId_;
+ while (unwrappedContext_.getError());
+ clearErrors();
+ glErrorShadow_[unwrappedContext_.CONTEXT_LOST_WEBGL] = true;
+ var event = makeWebGLContextEvent("context lost");
+ var callbacks = onLost_.slice();
+ setTimeout(function() {
+ //log("numCallbacks:" + callbacks.length);
+ for (var ii = 0; ii < callbacks.length; ++ii) {
+ //log("calling callback:" + ii);
+ callbacks[ii](event);
+ }
+ if (restoreTimeout_ >= 0) {
+ setTimeout(function() {
+ canvas.restoreContext();
+ }, restoreTimeout_);
+ }
+ }, 0);
+ }
+ };
+
+ canvas.restoreContext = function() {
+ if (contextLost_) {
+ if (onRestored_.length) {
+ setTimeout(function() {
+ if (!canRestore_) {
+ throw "can not restore. webglcontestlost listener did not call event.preventDefault";
+ }
+ freeResources();
+ resetToInitialState(unwrappedContext_);
+ contextLost_ = false;
+ numCalls_ = 0;
+ canRestore_ = false;
+ var callbacks = onRestored_.slice();
+ var event = makeWebGLContextEvent("context restored");
+ for (var ii = 0; ii < callbacks.length; ++ii) {
+ callbacks[ii](event);
+ }
+ }, 0);
+ }
+ }
+ };
+
+ canvas.loseContextInNCalls = function(numCalls) {
+ if (contextLost_) {
+ throw "You can not ask a lost contet to be lost";
+ }
+ numCallsToLoseContext_ = numCalls_ + numCalls;
+ };
+
+ canvas.getNumCalls = function() {
+ return numCalls_;
+ };
+
+ canvas.setRestoreTimeout = function(timeout) {
+ restoreTimeout_ = timeout;
+ };
+
+ function isWebGLObject(obj) {
+ //return false;
+ return (obj instanceof WebGLBuffer ||
+ obj instanceof WebGLFramebuffer ||
+ obj instanceof WebGLProgram ||
+ obj instanceof WebGLRenderbuffer ||
+ obj instanceof WebGLShader ||
+ obj instanceof WebGLTexture);
+ }
+
+ function checkResources(args) {
+ for (var ii = 0; ii < args.length; ++ii) {
+ var arg = args[ii];
+ if (isWebGLObject(arg)) {
+ return arg.__webglDebugContextLostId__ == contextId_;
+ }
+ }
+ return true;
+ }
+
+ function clearErrors() {
+ var k = Object.keys(glErrorShadow_);
+ for (var ii = 0; ii < k.length; ++ii) {
+ delete glErrorShadow_[k];
+ }
+ }
+
+ function loseContextIfTime() {
+ ++numCalls_;
+ if (!contextLost_) {
+ if (numCallsToLoseContext_ == numCalls_) {
+ canvas.loseContext();
+ }
+ }
+ }
+
+ // Makes a function that simulates WebGL when out of context.
+ function makeLostContextFunctionWrapper(ctx, functionName) {
+ var f = ctx[functionName];
+ return function() {
+ // log("calling:" + functionName);
+ // Only call the functions if the context is not lost.
+ loseContextIfTime();
+ if (!contextLost_) {
+ //if (!checkResources(arguments)) {
+ // glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;
+ // return;
+ //}
+ var result = f.apply(ctx, arguments);
+ return result;
+ }
+ };
+ }
+
+ function freeResources() {
+ for (var ii = 0; ii < resourceDb_.length; ++ii) {
+ var resource = resourceDb_[ii];
+ if (resource instanceof WebGLBuffer) {
+ unwrappedContext_.deleteBuffer(resource);
+ } else if (resource instanceof WebGLFramebuffer) {
+ unwrappedContext_.deleteFramebuffer(resource);
+ } else if (resource instanceof WebGLProgram) {
+ unwrappedContext_.deleteProgram(resource);
+ } else if (resource instanceof WebGLRenderbuffer) {
+ unwrappedContext_.deleteRenderbuffer(resource);
+ } else if (resource instanceof WebGLShader) {
+ unwrappedContext_.deleteShader(resource);
+ } else if (resource instanceof WebGLTexture) {
+ unwrappedContext_.deleteTexture(resource);
+ }
+ }
+ }
+
+ function makeWebGLContextEvent(statusMessage) {
+ return {
+ statusMessage: statusMessage,
+ preventDefault: function() {
+ canRestore_ = true;
+ }
+ };
+ }
+
+ return canvas;
+
+ function makeLostContextSimulatingContext(ctx) {
+ // copy all functions and properties to wrapper
+ for (var propertyName in ctx) {
+ if (typeof ctx[propertyName] == 'function') {
+ wrappedContext_[propertyName] = makeLostContextFunctionWrapper(
+ ctx, propertyName);
+ } else {
+ makePropertyWrapper(wrappedContext_, ctx, propertyName);
+ }
+ }
+
+ // Wrap a few functions specially.
+ wrappedContext_.getError = function() {
+ loseContextIfTime();
+ if (!contextLost_) {
+ var err;
+ while (err = unwrappedContext_.getError()) {
+ glErrorShadow_[err] = true;
+ }
+ }
+ for (var err in glErrorShadow_) {
+ if (glErrorShadow_[err]) {
+ delete glErrorShadow_[err];
+ return err;
+ }
+ }
+ return wrappedContext_.NO_ERROR;
+ };
+
+ var creationFunctions = [
+ "createBuffer",
+ "createFramebuffer",
+ "createProgram",
+ "createRenderbuffer",
+ "createShader",
+ "createTexture"
+ ];
+ for (var ii = 0; ii < creationFunctions.length; ++ii) {
+ var functionName = creationFunctions[ii];
+ wrappedContext_[functionName] = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return null;
+ }
+ var obj = f.apply(ctx, arguments);
+ obj.__webglDebugContextLostId__ = contextId_;
+ resourceDb_.push(obj);
+ return obj;
+ };
+ }(ctx[functionName]);
+ }
+
+ var functionsThatShouldReturnNull = [
+ "getActiveAttrib",
+ "getActiveUniform",
+ "getBufferParameter",
+ "getContextAttributes",
+ "getAttachedShaders",
+ "getFramebufferAttachmentParameter",
+ "getParameter",
+ "getProgramParameter",
+ "getProgramInfoLog",
+ "getRenderbufferParameter",
+ "getShaderParameter",
+ "getShaderInfoLog",
+ "getShaderSource",
+ "getTexParameter",
+ "getUniform",
+ "getUniformLocation",
+ "getVertexAttrib"
+ ];
+ for (var ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {
+ var functionName = functionsThatShouldReturnNull[ii];
+ wrappedContext_[functionName] = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return null;
+ }
+ return f.apply(ctx, arguments);
+ }
+ }(wrappedContext_[functionName]);
+ }
+
+ var isFunctions = [
+ "isBuffer",
+ "isEnabled",
+ "isFramebuffer",
+ "isProgram",
+ "isRenderbuffer",
+ "isShader",
+ "isTexture"
+ ];
+ for (var ii = 0; ii < isFunctions.length; ++ii) {
+ var functionName = isFunctions[ii];
+ wrappedContext_[functionName] = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return false;
+ }
+ return f.apply(ctx, arguments);
+ }
+ }(wrappedContext_[functionName]);
+ }
+
+ wrappedContext_.checkFramebufferStatus = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return wrappedContext_.FRAMEBUFFER_UNSUPPORTED;
+ }
+ return f.apply(ctx, arguments);
+ };
+ }(wrappedContext_.checkFramebufferStatus);
+
+ wrappedContext_.getAttribLocation = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return -1;
+ }
+ return f.apply(ctx, arguments);
+ };
+ }(wrappedContext_.getAttribLocation);
+
+ wrappedContext_.getVertexAttribOffset = function(f) {
+ return function() {
+ loseContextIfTime();
+ if (contextLost_) {
+ return 0;
+ }
+ return f.apply(ctx, arguments);
+ };
+ }(wrappedContext_.getVertexAttribOffset);
+
+ wrappedContext_.isContextLost = function() {
+ return contextLost_;
+ };
+
+ return wrappedContext_;
+ }
+}
+
+return {
+ /**
+ * Initializes this module. Safe to call more than once.
+ * @param {!WebGLRenderingContext} ctx A WebGL context. If
+ }
+ * you have more than one context it doesn't matter which one
+ * you pass in, it is only used to pull out constants.
+ */
+ 'init': init,
+
+ /**
+ * Returns true or false if value matches any WebGL enum
+ * @param {*} value Value to check if it might be an enum.
+ * @return {boolean} True if value matches one of the WebGL defined enums
+ */
+ 'mightBeEnum': mightBeEnum,
+
+ /**
+ * Gets an string version of an WebGL enum.
+ *
+ * Example:
+ * WebGLDebugUtil.init(ctx);
+ * var str = WebGLDebugUtil.glEnumToString(ctx.getError());
+ *
+ * @param {number} value Value to return an enum for
+ * @return {string} The string version of the enum.
+ */
+ 'glEnumToString': glEnumToString,
+
+ /**
+ * Converts the argument of a WebGL function to a string.
+ * Attempts to convert enum arguments to strings.
+ *
+ * Example:
+ * WebGLDebugUtil.init(ctx);
+ * var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 0, gl.TEXTURE_2D);
+ *
+ * would return 'TEXTURE_2D'
+ *
+ * @param {string} functionName the name of the WebGL function.
+ * @param {number} argumentIndx the index of the argument.
+ * @param {*} value The value of the argument.
+ * @return {string} The value as a string.
+ */
+ 'glFunctionArgToString': glFunctionArgToString,
+
+ /**
+ * Given a WebGL context returns a wrapped context that calls
+ * gl.getError after every command and calls a function if the
+ * result is not NO_ERROR.
+ *
+ * You can supply your own function if you want. For example, if you'd like
+ * an exception thrown on any GL error you could do this
+ *
+ * function throwOnGLError(err, funcName, args) {
+ * throw WebGLDebugUtils.glEnumToString(err) + " was caused by call to" +
+ * funcName;
+ * };
+ *
+ * ctx = WebGLDebugUtils.makeDebugContext(
+ * canvas.getContext("webgl"), throwOnGLError);
+ *
+ * @param {!WebGLRenderingContext} ctx The webgl context to wrap.
+ * @param {!function(err, funcName, args): void} opt_onErrorFunc The function
+ * to call when gl.getError returns an error. If not specified the default
+ * function calls console.log with a message.
+ */
+ 'makeDebugContext': makeDebugContext,
+
+ /**
+ * Given a canvas element returns a wrapped canvas element that will
+ * simulate lost context. The canvas returned adds the following functions.
+ *
+ * loseContext:
+ * simulates a lost context event.
+ *
+ * restoreContext:
+ * simulates the context being restored.
+ *
+ * lostContextInNCalls:
+ * loses the context after N gl calls.
+ *
+ * getNumCalls:
+ * tells you how many gl calls there have been so far.
+ *
+ * setRestoreTimeout:
+ * sets the number of milliseconds until the context is restored
+ * after it has been lost. Defaults to 0. Pass -1 to prevent
+ * automatic restoring.
+ *
+ * @param {!Canvas} canvas The canvas element to wrap.
+ */
+ 'makeLostContextSimulatingCanvas': makeLostContextSimulatingCanvas,
+
+ /**
+ * Resets a context to the initial state.
+ * @param {!WebGLRenderingContext} ctx The webgl context to
+ * reset.
+ */
+ 'resetToInitialState': resetToInitialState
+};
+
+}();
+
diff --git a/examples/SimpleOpenGL/src/Main.hx b/examples/SimpleOpenGL/src/Main.hx
index ce990a4d2..e4b21fc29 100644
--- a/examples/SimpleOpenGL/src/Main.hx
+++ b/examples/SimpleOpenGL/src/Main.hx
@@ -25,7 +25,6 @@ class Main {
//Some value to mess with the clear color
private var red_value : Float = 1.0;
private var red_direction : Int = 1;
-
public function new() { }
@@ -98,19 +97,19 @@ class Main {
createProgram();
//Create a set of vertices
- var vertices = [
+ var vertices : Float32Array = new Float32Array([
100, 100, 0,
-100, 100, 0,
100, -100, 0,
-100, -100, 0
- ];
+ ]);
//Create a buffer from OpenGL
vertexBuffer = GL.createBuffer ();
//Bind it
GL.bindBuffer (GL.ARRAY_BUFFER, vertexBuffer);
//Point it to the vertex array!
- GL.bufferData (GL.ARRAY_BUFFER, new Float32Array (vertices), GL.STATIC_DRAW);
+ GL.bufferData (GL.ARRAY_BUFFER, vertices, GL.STATIC_DRAW);
}
diff --git a/include.xml b/include.xml
index 1b344dfc8..03cc1914d 100644
--- a/include.xml
+++ b/include.xml
@@ -1,7 +1,13 @@
+
+
+
+
+
+
diff --git a/lime/LiME.hx b/lime/LiME.hx
index 9a1d7e6ae..96c4a1308 100644
--- a/lime/LiME.hx
+++ b/lime/LiME.hx
@@ -46,23 +46,39 @@ class LiME {
_debug(':: lime :: initializing -');
_debug(':: lime :: Creating window at ' + config.width + 'x' + config.height);
- nme_create_main_frame(
- on_main_frame_created,
- config.width, //width
- config.height, //height
- Window.RESIZABLE |
- Window.HARDWARE |
- Window.VSYNC |
- Window.HW_AA |
- Window.HW_AA_HIRES |
- Window.ALLOW_SHADERS |
- Window.REQUIRE_SHADERS |
- Window.DEPTH_BUFFER |
- Window.STENCIL_BUFFER , //flags
- config.title, //title
- null //icon
+ #if lime_native
+ nme_create_main_frame(
+ on_main_frame_created,
+ config.width, //width
+ config.height, //height
+ Window.RESIZABLE |
+ Window.HARDWARE |
+ Window.VSYNC |
+ Window.HW_AA |
+ Window.HW_AA_HIRES |
+ Window.ALLOW_SHADERS |
+ Window.REQUIRE_SHADERS |
+ Window.DEPTH_BUFFER |
+ Window.STENCIL_BUFFER , //flags
+ config.title, //title
+ null //icon
- ); //nme_create_main_frame
+ ); //nme_create_main_frame
+ #end
+
+
+ #if lime_html5
+
+ var handle = null;
+
+ untyped {
+ js.Browser.document.body.onload = function (_) {
+ var handle = js.Browser.document.getElementById('lime_canvas');
+ on_main_frame_created( handle );
+ }
+ }
+
+ #end //lime_html5
} //init
@@ -73,10 +89,14 @@ class LiME {
//Store a reference to the handle
mainframe_handle = handle;
- stage_handle = nme_get_frame_stage( mainframe_handle );
- //Set the stage handler for NME to send us events
- nme_set_stage_handler(stage_handle, on_stage_event, config.width, config.height);
+ #if lime_native
+ stage_handle = nme_get_frame_stage( mainframe_handle );
+
+ //Set the stage handler for NME to send us events
+ nme_set_stage_handler(stage_handle, on_stage_event, config.width, config.height);
+ #end
+
//Create our input message handler class
input = new InputHandler( this );
@@ -100,6 +120,11 @@ class LiME {
host.ready(this);
}
+ #if lime_html5
+ //start the run loop
+ js.Browser.window.requestAnimationFrame(on_update);
+ #end
+
} //on_main_frame_created
public function shutdown() {
@@ -123,7 +148,9 @@ class LiME {
//Ok kill it!
//Order matters for events coming
//when things below are set to null.
- nme_close();
+ #if lime_native
+ nme_close();
+ #end
//Flag it
has_shutdown = true;
@@ -258,7 +285,11 @@ class LiME {
//Called when updated by the nme/sdl runtime
- public function on_update(_event:Dynamic) {
+ public function on_update(_event) {
+
+ #if lime_html5
+ js.Browser.window.requestAnimationFrame(on_update);
+ #end
_debug('on_update ' + Timer.stamp(), true, true);
@@ -271,6 +302,9 @@ class LiME {
do_render(_event);
}
+ #if lime_html5
+ return true;
+ #end
} //on_update
//Render the window
@@ -288,13 +322,17 @@ class LiME {
render.on_render();
+#if lime_native
nme_render_stage( stage_handle );
+#end //lime_native
} //do_render
//Noisy stuff
+#if lime_native
+
//import nme_library functions
private static var nme_render_stage = Libs.load("nme","nme_render_stage", 1);
private static var nme_set_stage_handler = Libs.load("nme","nme_set_stage_handler", 4);
@@ -303,9 +341,11 @@ class LiME {
private static var nme_create_main_frame = Libs.load("nme","nme_create_main_frame", -1);
+#end //lime_native
+
//temporary debugging with verbosity options
- public var log : Bool = false;
+ public var log : Bool = true;
public var verbose : Bool = false;
public var more_verbose : Bool = false;
public function _debug(value:Dynamic, _verbose:Bool = false, _more_verbose:Bool = false) {
diff --git a/lime/RenderHandler.hx b/lime/RenderHandler.hx
index 6e0206f0c..2a7e1e6fe 100644
--- a/lime/RenderHandler.hx
+++ b/lime/RenderHandler.hx
@@ -14,24 +14,44 @@ import lime.utils.Float32Array;
//geometry
import lime.geometry.Matrix3D;
+
+#if lime_html5
+
+ import js.Browser;
+ import js.html.CanvasElement;
+
+#end //lime_html5
+
+
class RenderHandler {
public var lib : LiME;
public function new( _lib:LiME ) { lib = _lib; }
- //direct_renderer_handle for NME
+ //direct_renderer_handle for drawing
public var direct_renderer_handle : Dynamic;
public function startup() {
- //Set up the OpenGL View
- direct_renderer_handle = nme_direct_renderer_create();
+ #if lime_native
- //Add this to the main stage, so it will render
- nme_doc_add_child( lib.stage_handle, direct_renderer_handle );
+ //Set up the OpenGL View
+ direct_renderer_handle = nme_direct_renderer_create();
- //Set this handle to the real view with a render function
- nme_direct_renderer_set( direct_renderer_handle, on_render );
+ //Add this to the main stage, so it will render
+ nme_doc_add_child( lib.stage_handle, direct_renderer_handle );
+
+ //Set this handle to the real view with a render function
+ nme_direct_renderer_set( direct_renderer_handle, on_render );
+
+ #end //lime_native
+
+ #if lime_html5
+
+ direct_renderer_handle = lib.mainframe_handle.getContext('webgl');
+ lime.gl.GL.nmeContext = direct_renderer_handle;
+
+ #end //lime_html5
//Done.
lib._debug(':: lime :: \t RenderHandler Initialized.');
@@ -48,10 +68,14 @@ class RenderHandler {
}
//nme functions
+#if lime_native
+
private static var nme_doc_add_child = Libs.load("nme","nme_doc_add_child", 2);
private static var nme_direct_renderer_create = Libs.load("nme","nme_direct_renderer_create", 0);
private static var nme_direct_renderer_set = Libs.load("nme","nme_direct_renderer_set", 2);
+#end //lime_native
+
}
\ No newline at end of file
diff --git a/lime/WindowHandler.hx b/lime/WindowHandler.hx
index 6d9b87edf..4c9e8bad6 100644
--- a/lime/WindowHandler.hx
+++ b/lime/WindowHandler.hx
@@ -35,10 +35,15 @@ class WindowHandler {
active = _active;
if(_active == false) {
+
+ //A window deactivate event comes through after we shut
+ //down the window, so if that is the case handle it by cleaning
+ //up the remaining values that we have reference to
if(lib.has_shutdown) {
lib.cleanup();
- }
- }
+ } //has_shutdown
+
+ } //if _active == false
} //set_active
diff --git a/lime/geometry/Matrix3D.hx b/lime/geometry/Matrix3D.hx
index 3069ca29d..faaa9a69b 100644
--- a/lime/geometry/Matrix3D.hx
+++ b/lime/geometry/Matrix3D.hx
@@ -1,6 +1,7 @@
package lime.geometry;
-#if (cpp || neko)
+// #if (cpp || neko)
+#if (lime_native || lime_html5)
import lime.utils.Vector;
diff --git a/lime/geometry/Vector3D.hx b/lime/geometry/Vector3D.hx
index 0ed5bf5bb..3bc8adf93 100644
--- a/lime/geometry/Vector3D.hx
+++ b/lime/geometry/Vector3D.hx
@@ -1,5 +1,6 @@
package lime.geometry;
-#if (cpp || neko)
+// #if (cpp || neko)
+#if (lime_native || lime_html5)
class Vector3D
{
diff --git a/lime/gl/GL.hx b/lime/gl/GL.hx
index c139a52e1..c6afed355 100644
--- a/lime/gl/GL.hx
+++ b/lime/gl/GL.hx
@@ -1,1303 +1,15 @@
-package lime.gl;
-
-import lime.utils.Libs;
-
-// import flash.display.BitmapData;
-import lime.geometry.Matrix3D;
-// import flash.utils.ByteArray;
-
-import lime.utils.ArrayBuffer;
-import lime.utils.ArrayBufferView;
-import lime.utils.Float32Array;
-import lime.utils.IMemoryRange;
-
-
-class GL {
-
-
- /* ClearBufferMask */
- public static inline var DEPTH_BUFFER_BIT = 0x00000100;
- public static inline var STENCIL_BUFFER_BIT = 0x00000400;
- public static inline var COLOR_BUFFER_BIT = 0x00004000;
-
- /* BeginMode */
- public static inline var POINTS = 0x0000;
- public static inline var LINES = 0x0001;
- public static inline var LINE_LOOP = 0x0002;
- public static inline var LINE_STRIP = 0x0003;
- public static inline var TRIANGLES = 0x0004;
- public static inline var TRIANGLE_STRIP = 0x0005;
- public static inline var TRIANGLE_FAN = 0x0006;
-
- /* AlphaFunction(not supported in ES20) */
- /* NEVER */
- /* LESS */
- /* EQUAL */
- /* LEQUAL */
- /* GREATER */
- /* NOTEQUAL */
- /* GEQUAL */
- /* ALWAYS */
- /* BlendingFactorDest */
- public static inline var ZERO = 0;
- public static inline var ONE = 1;
- public static inline var SRC_COLOR = 0x0300;
- public static inline var ONE_MINUS_SRC_COLOR = 0x0301;
- public static inline var SRC_ALPHA = 0x0302;
- public static inline var ONE_MINUS_SRC_ALPHA = 0x0303;
- public static inline var DST_ALPHA = 0x0304;
- public static inline var ONE_MINUS_DST_ALPHA = 0x0305;
-
- /* BlendingFactorSrc */
- /* ZERO */
- /* ONE */
- public static inline var DST_COLOR = 0x0306;
- public static inline var ONE_MINUS_DST_COLOR = 0x0307;
- public static inline var SRC_ALPHA_SATURATE = 0x0308;
- /* SRC_ALPHA */
- /* ONE_MINUS_SRC_ALPHA */
- /* DST_ALPHA */
- /* ONE_MINUS_DST_ALPHA */
- /* BlendEquationSeparate */
- public static inline var FUNC_ADD = 0x8006;
- public static inline var BLEND_EQUATION = 0x8009;
- public static inline var BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */
- public static inline var BLEND_EQUATION_ALPHA = 0x883D;
-
- /* BlendSubtract */
- public static inline var FUNC_SUBTRACT = 0x800A;
- public static inline var FUNC_REVERSE_SUBTRACT = 0x800B;
-
- /* Separate Blend Functions */
- public static inline var BLEND_DST_RGB = 0x80C8;
- public static inline var BLEND_SRC_RGB = 0x80C9;
- public static inline var BLEND_DST_ALPHA = 0x80CA;
- public static inline var BLEND_SRC_ALPHA = 0x80CB;
- public static inline var CONSTANT_COLOR = 0x8001;
- public static inline var ONE_MINUS_CONSTANT_COLOR = 0x8002;
- public static inline var CONSTANT_ALPHA = 0x8003;
- public static inline var ONE_MINUS_CONSTANT_ALPHA = 0x8004;
- public static inline var BLEND_COLOR = 0x8005;
-
- /* GLBuffer Objects */
- public static inline var ARRAY_BUFFER = 0x8892;
- public static inline var ELEMENT_ARRAY_BUFFER = 0x8893;
- public static inline var ARRAY_BUFFER_BINDING = 0x8894;
- public static inline var ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
-
- public static inline var STREAM_DRAW = 0x88E0;
- public static inline var STATIC_DRAW = 0x88E4;
- public static inline var DYNAMIC_DRAW = 0x88E8;
-
- public static inline var BUFFER_SIZE = 0x8764;
- public static inline var BUFFER_USAGE = 0x8765;
-
- public static inline var CURRENT_VERTEX_ATTRIB = 0x8626;
-
- /* CullFaceMode */
- public static inline var FRONT = 0x0404;
- public static inline var BACK = 0x0405;
- public static inline var FRONT_AND_BACK = 0x0408;
-
- /* DepthFunction */
- /* NEVER */
- /* LESS */
- /* EQUAL */
- /* LEQUAL */
- /* GREATER */
- /* NOTEQUAL */
- /* GEQUAL */
- /* ALWAYS */
- /* EnableCap */
- /* TEXTURE_2D */
- public static inline var CULL_FACE = 0x0B44;
- public static inline var BLEND = 0x0BE2;
- public static inline var DITHER = 0x0BD0;
- public static inline var STENCIL_TEST = 0x0B90;
- public static inline var DEPTH_TEST = 0x0B71;
- public static inline var SCISSOR_TEST = 0x0C11;
- public static inline var POLYGON_OFFSET_FILL = 0x8037;
- public static inline var SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
- public static inline var SAMPLE_COVERAGE = 0x80A0;
-
- /* ErrorCode */
- public static inline var NO_ERROR = 0;
- public static inline var INVALID_ENUM = 0x0500;
- public static inline var INVALID_VALUE = 0x0501;
- public static inline var INVALID_OPERATION = 0x0502;
- public static inline var OUT_OF_MEMORY = 0x0505;
-
- /* FrontFaceDirection */
- public static inline var CW = 0x0900;
- public static inline var CCW = 0x0901;
-
- /* GetPName */
- public static inline var LINE_WIDTH = 0x0B21;
- public static inline var ALIASED_POINT_SIZE_RANGE = 0x846D;
- public static inline var ALIASED_LINE_WIDTH_RANGE = 0x846E;
- public static inline var CULL_FACE_MODE = 0x0B45;
- public static inline var FRONT_FACE = 0x0B46;
- public static inline var DEPTH_RANGE = 0x0B70;
- public static inline var DEPTH_WRITEMASK = 0x0B72;
- public static inline var DEPTH_CLEAR_VALUE = 0x0B73;
- public static inline var DEPTH_FUNC = 0x0B74;
- public static inline var STENCIL_CLEAR_VALUE = 0x0B91;
- public static inline var STENCIL_FUNC = 0x0B92;
- public static inline var STENCIL_FAIL = 0x0B94;
- public static inline var STENCIL_PASS_DEPTH_FAIL = 0x0B95;
- public static inline var STENCIL_PASS_DEPTH_PASS = 0x0B96;
- public static inline var STENCIL_REF = 0x0B97;
- public static inline var STENCIL_VALUE_MASK = 0x0B93;
- public static inline var STENCIL_WRITEMASK = 0x0B98;
- public static inline var STENCIL_BACK_FUNC = 0x8800;
- public static inline var STENCIL_BACK_FAIL = 0x8801;
- public static inline var STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
- public static inline var STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
- public static inline var STENCIL_BACK_REF = 0x8CA3;
- public static inline var STENCIL_BACK_VALUE_MASK = 0x8CA4;
- public static inline var STENCIL_BACK_WRITEMASK = 0x8CA5;
- public static inline var VIEWPORT = 0x0BA2;
- public static inline var SCISSOR_BOX = 0x0C10;
- /* SCISSOR_TEST */
- public static inline var COLOR_CLEAR_VALUE = 0x0C22;
- public static inline var COLOR_WRITEMASK = 0x0C23;
- public static inline var UNPACK_ALIGNMENT = 0x0CF5;
- public static inline var PACK_ALIGNMENT = 0x0D05;
- public static inline var MAX_TEXTURE_SIZE = 0x0D33;
- public static inline var MAX_VIEWPORT_DIMS = 0x0D3A;
- public static inline var SUBPIXEL_BITS = 0x0D50;
- public static inline var RED_BITS = 0x0D52;
- public static inline var GREEN_BITS = 0x0D53;
- public static inline var BLUE_BITS = 0x0D54;
- public static inline var ALPHA_BITS = 0x0D55;
- public static inline var DEPTH_BITS = 0x0D56;
- public static inline var STENCIL_BITS = 0x0D57;
- public static inline var POLYGON_OFFSET_UNITS = 0x2A00;
- /* POLYGON_OFFSET_FILL */
- public static inline var POLYGON_OFFSET_FACTOR = 0x8038;
- public static inline var TEXTURE_BINDING_2D = 0x8069;
- public static inline var SAMPLE_BUFFERS = 0x80A8;
- public static inline var SAMPLES = 0x80A9;
- public static inline var SAMPLE_COVERAGE_VALUE = 0x80AA;
- public static inline var SAMPLE_COVERAGE_INVERT = 0x80AB;
-
- /* GetTextureParameter */
- /* TEXTURE_MAG_FILTER */
- /* TEXTURE_MIN_FILTER */
- /* TEXTURE_WRAP_S */
- /* TEXTURE_WRAP_T */
- public static inline var COMPRESSED_TEXTURE_FORMATS = 0x86A3;
-
- /* HintMode */
- public static inline var DONT_CARE = 0x1100;
- public static inline var FASTEST = 0x1101;
- public static inline var NICEST = 0x1102;
-
- /* HintTarget */
- public static inline var GENERATE_MIPMAP_HINT = 0x8192;
-
- /* DataType */
- public static inline var BYTE = 0x1400;
- public static inline var UNSIGNED_BYTE = 0x1401;
- public static inline var SHORT = 0x1402;
- public static inline var UNSIGNED_SHORT = 0x1403;
- public static inline var INT = 0x1404;
- public static inline var UNSIGNED_INT = 0x1405;
- public static inline var FLOAT = 0x1406;
-
- /* PixelFormat */
- public static inline var DEPTH_COMPONENT = 0x1902;
- public static inline var ALPHA = 0x1906;
- public static inline var RGB = 0x1907;
- public static inline var RGBA = 0x1908;
- public static inline var LUMINANCE = 0x1909;
- public static inline var LUMINANCE_ALPHA = 0x190A;
-
- /* PixelType */
- /* UNSIGNED_BYTE */
- public static inline var UNSIGNED_SHORT_4_4_4_4 = 0x8033;
- public static inline var UNSIGNED_SHORT_5_5_5_1 = 0x8034;
- public static inline var UNSIGNED_SHORT_5_6_5 = 0x8363;
-
- /* Shaders */
- public static inline var FRAGMENT_SHADER = 0x8B30;
- public static inline var VERTEX_SHADER = 0x8B31;
- public static inline var MAX_VERTEX_ATTRIBS = 0x8869;
- public static inline var MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
- public static inline var MAX_VARYING_VECTORS = 0x8DFC;
- public static inline var MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
- public static inline var MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
- public static inline var MAX_TEXTURE_IMAGE_UNITS = 0x8872;
- public static inline var MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
- public static inline var SHADER_TYPE = 0x8B4F;
- public static inline var DELETE_STATUS = 0x8B80;
- public static inline var LINK_STATUS = 0x8B82;
- public static inline var VALIDATE_STATUS = 0x8B83;
- public static inline var ATTACHED_SHADERS = 0x8B85;
- public static inline var ACTIVE_UNIFORMS = 0x8B86;
- public static inline var ACTIVE_ATTRIBUTES = 0x8B89;
- public static inline var SHADING_LANGUAGE_VERSION = 0x8B8C;
- public static inline var CURRENT_PROGRAM = 0x8B8D;
-
- /* StencilFunction */
- public static inline var NEVER = 0x0200;
- public static inline var LESS = 0x0201;
- public static inline var EQUAL = 0x0202;
- public static inline var LEQUAL = 0x0203;
- public static inline var GREATER = 0x0204;
- public static inline var NOTEQUAL = 0x0205;
- public static inline var GEQUAL = 0x0206;
- public static inline var ALWAYS = 0x0207;
-
- /* StencilOp */
- /* ZERO */
- public static inline var KEEP = 0x1E00;
- public static inline var REPLACE = 0x1E01;
- public static inline var INCR = 0x1E02;
- public static inline var DECR = 0x1E03;
- public static inline var INVERT = 0x150A;
- public static inline var INCR_WRAP = 0x8507;
- public static inline var DECR_WRAP = 0x8508;
-
- /* StringName */
- public static inline var VENDOR = 0x1F00;
- public static inline var RENDERER = 0x1F01;
- public static inline var VERSION = 0x1F02;
-
- /* TextureMagFilter */
- public static inline var NEAREST = 0x2600;
- public static inline var LINEAR = 0x2601;
-
- /* TextureMinFilter */
- /* NEAREST */
- /* LINEAR */
- public static inline var NEAREST_MIPMAP_NEAREST = 0x2700;
- public static inline var LINEAR_MIPMAP_NEAREST = 0x2701;
- public static inline var NEAREST_MIPMAP_LINEAR = 0x2702;
- public static inline var LINEAR_MIPMAP_LINEAR = 0x2703;
-
- /* TextureParameterName */
- public static inline var TEXTURE_MAG_FILTER = 0x2800;
- public static inline var TEXTURE_MIN_FILTER = 0x2801;
- public static inline var TEXTURE_WRAP_S = 0x2802;
- public static inline var TEXTURE_WRAP_T = 0x2803;
-
- /* TextureTarget */
- public static inline var TEXTURE_2D = 0x0DE1;
- public static inline var TEXTURE = 0x1702;
-
- public static inline var TEXTURE_CUBE_MAP = 0x8513;
- public static inline var TEXTURE_BINDING_CUBE_MAP = 0x8514;
- public static inline var TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
- public static inline var TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
- public static inline var TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
- public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
- public static inline var TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
- public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
- public static inline var MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
-
- /* TextureUnit */
- public static inline var TEXTURE0 = 0x84C0;
- public static inline var TEXTURE1 = 0x84C1;
- public static inline var TEXTURE2 = 0x84C2;
- public static inline var TEXTURE3 = 0x84C3;
- public static inline var TEXTURE4 = 0x84C4;
- public static inline var TEXTURE5 = 0x84C5;
- public static inline var TEXTURE6 = 0x84C6;
- public static inline var TEXTURE7 = 0x84C7;
- public static inline var TEXTURE8 = 0x84C8;
- public static inline var TEXTURE9 = 0x84C9;
- public static inline var TEXTURE10 = 0x84CA;
- public static inline var TEXTURE11 = 0x84CB;
- public static inline var TEXTURE12 = 0x84CC;
- public static inline var TEXTURE13 = 0x84CD;
- public static inline var TEXTURE14 = 0x84CE;
- public static inline var TEXTURE15 = 0x84CF;
- public static inline var TEXTURE16 = 0x84D0;
- public static inline var TEXTURE17 = 0x84D1;
- public static inline var TEXTURE18 = 0x84D2;
- public static inline var TEXTURE19 = 0x84D3;
- public static inline var TEXTURE20 = 0x84D4;
- public static inline var TEXTURE21 = 0x84D5;
- public static inline var TEXTURE22 = 0x84D6;
- public static inline var TEXTURE23 = 0x84D7;
- public static inline var TEXTURE24 = 0x84D8;
- public static inline var TEXTURE25 = 0x84D9;
- public static inline var TEXTURE26 = 0x84DA;
- public static inline var TEXTURE27 = 0x84DB;
- public static inline var TEXTURE28 = 0x84DC;
- public static inline var TEXTURE29 = 0x84DD;
- public static inline var TEXTURE30 = 0x84DE;
- public static inline var TEXTURE31 = 0x84DF;
- public static inline var ACTIVE_TEXTURE = 0x84E0;
-
- /* TextureWrapMode */
- public static inline var REPEAT = 0x2901;
- public static inline var CLAMP_TO_EDGE = 0x812F;
- public static inline var MIRRORED_REPEAT = 0x8370;
-
- /* Uniform Types */
- public static inline var FLOAT_VEC2 = 0x8B50;
- public static inline var FLOAT_VEC3 = 0x8B51;
- public static inline var FLOAT_VEC4 = 0x8B52;
- public static inline var INT_VEC2 = 0x8B53;
- public static inline var INT_VEC3 = 0x8B54;
- public static inline var INT_VEC4 = 0x8B55;
- public static inline var BOOL = 0x8B56;
- public static inline var BOOL_VEC2 = 0x8B57;
- public static inline var BOOL_VEC3 = 0x8B58;
- public static inline var BOOL_VEC4 = 0x8B59;
- public static inline var FLOAT_MAT2 = 0x8B5A;
- public static inline var FLOAT_MAT3 = 0x8B5B;
- public static inline var FLOAT_MAT4 = 0x8B5C;
- public static inline var SAMPLER_2D = 0x8B5E;
- public static inline var SAMPLER_CUBE = 0x8B60;
-
- /* Vertex Arrays */
- public static inline var VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
- public static inline var VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
- public static inline var VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
- public static inline var VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
- public static inline var VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
- public static inline var VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
- public static inline var VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
-
- /* Point Size */
- public static inline var VERTEX_PROGRAM_POINT_SIZE = 0x8642;
- public static inline var POINT_SPRITE = 0x8861;
-
- /* GLShader Source */
- public static inline var COMPILE_STATUS = 0x8B81;
-
- /* GLShader Precision-Specified Types */
- public static inline var LOW_FLOAT = 0x8DF0;
- public static inline var MEDIUM_FLOAT = 0x8DF1;
- public static inline var HIGH_FLOAT = 0x8DF2;
- public static inline var LOW_INT = 0x8DF3;
- public static inline var MEDIUM_INT = 0x8DF4;
- public static inline var HIGH_INT = 0x8DF5;
-
- /* GLFramebuffer Object. */
- public static inline var FRAMEBUFFER = 0x8D40;
- public static inline var RENDERBUFFER = 0x8D41;
-
- public static inline var RGBA4 = 0x8056;
- public static inline var RGB5_A1 = 0x8057;
- public static inline var RGB565 = 0x8D62;
- public static inline var DEPTH_COMPONENT16 = 0x81A5;
- public static inline var STENCIL_INDEX = 0x1901;
- public static inline var STENCIL_INDEX8 = 0x8D48;
- public static inline var DEPTH_STENCIL = 0x84F9;
-
- public static inline var RENDERBUFFER_WIDTH = 0x8D42;
- public static inline var RENDERBUFFER_HEIGHT = 0x8D43;
- public static inline var RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
- public static inline var RENDERBUFFER_RED_SIZE = 0x8D50;
- public static inline var RENDERBUFFER_GREEN_SIZE = 0x8D51;
- public static inline var RENDERBUFFER_BLUE_SIZE = 0x8D52;
- public static inline var RENDERBUFFER_ALPHA_SIZE = 0x8D53;
- public static inline var RENDERBUFFER_DEPTH_SIZE = 0x8D54;
- public static inline var RENDERBUFFER_STENCIL_SIZE = 0x8D55;
-
- public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
- public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
- public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
- public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
-
- public static inline var COLOR_ATTACHMENT0 = 0x8CE0;
- public static inline var DEPTH_ATTACHMENT = 0x8D00;
- public static inline var STENCIL_ATTACHMENT = 0x8D20;
- public static inline var DEPTH_STENCIL_ATTACHMENT = 0x821A;
-
- public static inline var NONE = 0;
-
- public static inline var FRAMEBUFFER_COMPLETE = 0x8CD5;
- public static inline var FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
- public static inline var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
- public static inline var FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
- public static inline var FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
-
- public static inline var FRAMEBUFFER_BINDING = 0x8CA6;
- public static inline var RENDERBUFFER_BINDING = 0x8CA7;
- public static inline var MAX_RENDERBUFFER_SIZE = 0x84E8;
-
- public static inline var INVALID_FRAMEBUFFER_OPERATION = 0x0506;
-
- /* WebGL-specific enums */
- public static inline var UNPACK_FLIP_Y_WEBGL = 0x9240;
- public static inline var UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
- public static inline var CONTEXT_LOST_WEBGL = 0x9242;
- public static inline var UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
- public static inline var BROWSER_DEFAULT_WEBGL = 0x9244;
-
- public static var drawingBufferHeight(get_drawingBufferHeight, null):Int;
- public static var drawingBufferWidth(get_drawingBufferWidth, null):Int;
- public static var version(get_version, null):Int;
-
- public static function activeTexture(texture:Int):Void { nme_gl_active_texture(texture); }
-
- public static function attachShader(program:GLProgram, shader:GLShader):Void
- {
- program.attach(shader);
- nme_gl_attach_shader(program.id, shader.id);
- }
-
- public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void
- {
- nme_gl_bind_attrib_location(program.id, index, name);
- }
-
- //todo sven
- // public static function bindBitmapDataTexture(texture:BitmapData):Void
- // {
- // nme_gl_bind_bitmap_data_texture(texture.__handle);
- // }
-
- public static function bindBuffer(target:Int, buffer:GLBuffer):Void
- {
- nme_gl_bind_buffer(target, buffer == null ? 0 : buffer.id);
- }
-
- public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void
- {
- nme_gl_bind_framebuffer(target, framebuffer == null ? 0 : framebuffer.id);
- }
-
- public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void
- {
- nme_gl_bind_renderbuffer(target, renderbuffer == null ? 0 : renderbuffer.id);
- }
-
- public static function bindTexture(target:Int, texture:GLTexture):Void
- {
- nme_gl_bind_texture(target, texture == null ? 0 : texture.id);
- }
-
- public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void
- {
- nme_gl_blend_color(red, green, blue, alpha);
- }
-
- public static function blendEquation(mode:Int):Void
- {
- nme_gl_blend_equation(mode);
- }
-
- public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void
- {
- nme_gl_blend_equation_separate(modeRGB, modeAlpha);
- }
-
- public static function blendFunc(sfactor:Int, dfactor:Int):Void
- {
- nme_gl_blend_func(sfactor, dfactor);
- }
-
- public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void
- {
- nme_gl_blend_func_separate(srcRGB, dstRGB, srcAlpha, dstAlpha);
- }
-
- public static function bufferData(target:Int, data:IMemoryRange, usage:Int):Void
- {
- nme_gl_buffer_data(target, data.getByteBuffer(), data.getStart(), data.getLength(), usage);
- }
-
- public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange):Void
- {
- nme_gl_buffer_sub_data(target, offset, data.getByteBuffer(), data.getStart(), data.getLength());
- }
-
- public static function checkFramebufferStatus(target:Int):Int
- {
- return nme_gl_check_framebuffer_status(target);
- }
-
- public static function clear(mask:Int):Void
- {
- nme_gl_clear(mask);
- }
-
- public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void
- {
- nme_gl_clear_color(red, green, blue, alpha);
- }
-
- public static function clearDepth(depth:Float):Void
- {
- nme_gl_clear_depth(depth);
- }
-
- public static function clearStencil(s:Int):Void
- {
- nme_gl_clear_stencil(s);
- }
-
- public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void
- {
- nme_gl_color_mask(red, green, blue, alpha);
- }
-
- public static function compileShader(shader:GLShader):Void
- {
- nme_gl_compile_shader(shader.id);
- }
-
- public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:IMemoryRange):Void
- {
- nme_gl_compressed_tex_image_2d(target, level, internalformat, width, height, border, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart());
- }
-
- public static function compressedTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:IMemoryRange):Void
- {
- nme_gl_compressed_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart());
- }
-
- public static function copyTexImage2D(target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void
- {
- nme_gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border);
- }
-
- public static function copyTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void
- {
- nme_gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height);
- }
-
- public static function createBuffer():GLBuffer
- {
- return new GLBuffer(version, nme_gl_create_buffer());
- }
-
- public static function createFramebuffer():GLFramebuffer
- {
- return new GLFramebuffer(version, nme_gl_create_framebuffer());
- }
-
- public static function createProgram():GLProgram
- {
- return new GLProgram(version, nme_gl_create_program());
- }
-
- public static function createRenderbuffer():GLRenderbuffer
- {
- return new GLRenderbuffer(version, nme_gl_create_render_buffer());
- }
-
- public static function createShader(type:Int):GLShader
- {
- return new GLShader(version, nme_gl_create_shader(type));
- }
-
- public static function createTexture():GLTexture
- {
- return new GLTexture(version, nme_gl_create_texture());
- }
-
- public static function cullFace(mode:Int):Void
- {
- }
-
- public static function deleteBuffer(buffer:GLBuffer):Void
- {
- nme_gl_delete_buffer(buffer.id);
- buffer.invalidate();
- }
-
- public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void
- {
- }
-
- public static function deleteProgram(program:GLProgram):Void
- {
- nme_gl_delete_program(program.id);
- program.invalidate();
- }
-
- public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void
- {
- }
-
- public static function deleteShader(shader:GLShader):Void
- {
- nme_gl_delete_shader(shader.id);
- shader.invalidate();
- }
-
- public static function deleteTexture(texture:GLTexture):Void
- {
- nme_gl_delete_texture(texture.id);
- texture.invalidate();
- }
-
- public static function depthFunc(func:Int):Void
- {
- nme_gl_depth_func(func);
- }
-
- public static function depthMask(flag:Bool):Void
- {
- nme_gl_depth_mask(flag);
- }
-
- public static function depthRange(zNear:Float, zFar:Float):Void
- {
- nme_gl_depth_range(zNear, zFar);
- }
-
- public static function detachShader(program:GLProgram, shader:GLShader):Void
- {
- nme_gl_detach_shader(program.id, shader.id);
- }
-
- public static function disable(cap:Int):Void
- {
- nme_gl_disable(cap);
- }
-
- public static function disableVertexAttribArray(index:Int):Void
- {
- nme_gl_disable_vertex_attrib_array(index);
- }
-
- public static function drawArrays(mode:Int, first:Int, count:Int):Void
- {
- nme_gl_draw_arrays(mode, first, count);
- }
-
- public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void
- {
- nme_gl_draw_elements(mode, count, type, offset);
- }
-
- public static function enable(cap:Int):Void
- {
- nme_gl_enable(cap);
- }
-
- public static function enableVertexAttribArray(index:Int):Void
- {
- nme_gl_enable_vertex_attrib_array(index);
- }
-
- public static function finish():Void
- {
- nme_gl_finish();
- }
-
- public static function flush():Void
- {
- nme_gl_flush();
- }
-
- public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void
- {
- nme_gl_framebuffer_renderbuffer(target, attachment, renderbuffertarget, renderbuffer.id);
- }
-
- public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void
- {
- nme_gl_framebuffer_texture2D(target, attachment, textarget, texture.id, level);
- }
-
- public static function frontFace(mode:Int):Void
- {
- nme_gl_front_face(mode);
- }
-
- public static function generateMipmap(target:Int):Void
- {
- nme_gl_generate_mipmap(target);
- }
-
- public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo
- {
- return nme_gl_get_active_attrib(program.id, index);
- }
-
- public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo
- {
- return nme_gl_get_active_uniform(program.id, index);
- }
-
- public static function getAttachedShaders(program:GLProgram):Array
- {
- return program.getShaders();
- }
-
- public static function getAttribLocation(program:GLProgram, name:String):Int
- {
- return nme_gl_get_attrib_location(program.id, name);
- }
-
- public static function getBufferParameter(target:Int, pname:Int):Dynamic
- {
- return nme_gl_get_buffer_paramerter(target, pname);
- }
-
- public static function getContextAttributes():GLContextAttributes
- {
- var base = nme_gl_get_context_attributes();
- base.premultipliedAlpha = false;
- base.preserveDrawingBuffer = false;
- return base;
- }
-
- public static function getError():Int
- {
- return nme_gl_get_error();
- }
-
- public static function getExtension(name:String):Dynamic
- {
- // Hmmm
- return null;
- }
-
- public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic
- {
- return nme_gl_get_framebuffer_attachment_parameter(target, attachment, pname);
- }
-
- public static function getParameter(pname:Int):Dynamic
- {
- return nme_gl_get_parameter(pname);
- }
-
- public static function getProgramInfoLog(program:GLProgram):String
- {
- return nme_gl_get_program_info_log(program.id);
- }
-
- public static function getProgramParameter(program:GLProgram, pname:Int):Int
- {
- return nme_gl_get_program_parameter(program.id, pname);
- }
-
- public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic
- {
- return nme_gl_get_render_buffer_parameter(target, pname);
- }
-
- public static function getShaderInfoLog(shader:GLShader):String
- {
- return nme_gl_get_shader_info_log(shader.id);
- }
-
- public static function getShaderParameter(shader:GLShader, pname:Int):Int
- {
- return nme_gl_get_shader_parameter(shader.id, pname);
- }
-
- public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat
- {
- return nme_gl_get_shader_precision_format(shadertype, precisiontype);
- }
-
- public static function getShaderSource(shader:GLShader):String
- {
- return nme_gl_get_shader_source(shader.id);
- }
-
- public static function getSupportedExtensions():Array
- {
- var result = new Array();
- nme_gl_get_supported_extensions(result);
- return result;
- }
-
- public static function getTexParameter(target:Int, pname:Int):Dynamic
- {
- return nme_gl_get_tex_parameter(target, pname);
- }
-
- public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic
- {
- return nme_gl_get_uniform(program.id, location);
- }
-
- public static function getUniformLocation(program:GLProgram, name:String):Dynamic
- {
- return nme_gl_get_uniform_location(program.id, name);
- }
-
- public static function getVertexAttrib(index:Int, pname:Int):Dynamic
- {
- return nme_gl_get_vertex_attrib(index, pname);
- }
-
- public static function getVertexAttribOffset(index:Int, pname:Int):Int
- {
- return nme_gl_get_vertex_attrib_offset(index, pname);
- }
-
- public static function hint(target:Int, mode:Int):Void
- {
- nme_gl_hint(target, mode);
- }
-
- public static function isBuffer(buffer:GLBuffer):Bool
- {
- return buffer != null && buffer.id > 0 && nme_gl_is_buffer(buffer.id);
- }
-
- // This is non-static
- // public function isContextLost():Bool { return false; }
- public static function isEnabled(cap:Int):Bool
- {
- return nme_gl_is_enabled(cap);
- }
-
- public static function isFramebuffer(framebuffer:GLFramebuffer):Bool
- {
- return framebuffer != null && framebuffer.id > 0 && nme_gl_is_framebuffer(framebuffer.id);
- }
-
- public static function isProgram(program:GLProgram):Bool
- {
- return program != null && program.id > 0 && nme_gl_is_program(program.id);
- }
-
- public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool
- {
- return renderbuffer != null && renderbuffer.id > 0 && nme_gl_is_renderbuffer(renderbuffer.id);
- }
-
- public static function isShader(shader:GLShader):Bool
- {
- return shader != null && shader.id > 0 && nme_gl_is_shader(shader.id);
- }
-
- public static function isTexture(texture:GLTexture):Bool
- {
- return texture != null && texture.id > 0 && nme_gl_is_texture(texture.id);
- }
-
- public static function lineWidth(width:Float):Void
- {
- nme_gl_line_width(width);
- }
-
- public static function linkProgram(program:GLProgram):Void
- {
- nme_gl_link_program(program.id);
- }
-
- private static function load(inName:String, inArgCount:Int):Dynamic
- {
- try
- {
- return Libs.load("nme", inName, inArgCount);
-
- } catch(e:Dynamic)
- {
- trace(e);
- return null;
- }
- }
-
- public static function pixelStorei(pname:Int, param:Int):Void
- {
- nme_gl_pixel_storei(pname, param);
- }
-
- public static function polygonOffset(factor:Float, units:Float):Void
- {
- nme_gl_polygon_offset(factor, units);
- }
-
- //todo sven
- // public static function readPixels(x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ByteArray):Void
- // {
- // }
-
- public static function renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void
- {
- nme_gl_renderbuffer_storage(target, internalformat, width, height);
- }
-
- public static function sampleCoverage(value:Float, invert:Bool):Void
- {
- nme_gl_sample_coverage(value, invert);
- }
-
- public static function scissor(x:Int, y:Int, width:Int, height:Int):Void
- {
- nme_gl_scissor(x, y, width, height);
- }
-
- public static function shaderSource(shader:GLShader, source:String):Void
- {
- nme_gl_shader_source(shader.id, source);
- }
-
- public static function stencilFunc(func:Int, ref:Int, mask:Int):Void
- {
- nme_gl_stencil_func(func, ref, mask);
- }
-
- public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void
- {
- nme_gl_stencil_func_separate(face, func, ref, mask);
- }
-
- public static function stencilMask(mask:Int):Void
- {
- nme_gl_stencil_mask(mask);
- }
-
- public static function stencilMaskSeparate(face:Int, mask:Int):Void
- {
- nme_gl_stencil_mask_separate(face, mask);
- }
-
- public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void
- {
- nme_gl_stencil_op(fail, zfail, zpass);
- }
-
- public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void
- {
- nme_gl_stencil_op_separate(face, fail, zfail, zpass);
- }
-
- public static function texImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
- {
- nme_gl_tex_image_2d(target, level, internalformat, width, height, border, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart());
- }
-
- public static function texParameterf(target:Int, pname:Int, param:Float):Void
- {
- nme_gl_tex_parameterf(target, pname, param);
- }
-
- public static function texParameteri(target:Int, pname:Int, param:Int):Void
- {
- nme_gl_tex_parameteri(target, pname, param);
- }
-
- public static function texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
- {
- nme_gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart());
- }
-
- public static function uniform1f(location:GLUniformLocation, x:Float):Void
- {
- nme_gl_uniform1f(location, x);
- }
-
- public static function uniform1fv(location:GLUniformLocation, x:Array):Void
- {
- nme_gl_uniform1fv(location, x);
- }
-
- public static function uniform1i(location:GLUniformLocation, x:Int):Void
- {
- nme_gl_uniform1i(location, x);
- }
-
- public static function uniform1iv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform1iv(location, v);
- }
-
- public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void
- {
- nme_gl_uniform2f(location, x, y);
- }
-
- public static function uniform2fv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform2fv(location, v);
- }
-
- public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void
- {
- nme_gl_uniform2i(location, x, y);
- }
-
- public static function uniform2iv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform2iv(location, v);
- }
-
- public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void
- {
- nme_gl_uniform3f(location, x, y, z);
- }
-
- public static function uniform3fv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform3fv(location, v);
- }
-
- public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void
- {
- nme_gl_uniform3i(location, x, y, z);
- }
-
- public static function uniform3iv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform3iv(location, v);
- }
-
- public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void
- {
- nme_gl_uniform4f(location, x, y, z, w);
- }
-
- public static function uniform4fv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform4fv(location, v);
- }
-
- public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void
- {
- nme_gl_uniform4i(location, x, y, z, w);
- }
-
- public static function uniform4iv(location:GLUniformLocation, v:Array):Void
- {
- nme_gl_uniform4iv(location, v);
- }
-
- public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
- {
- nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 2);
- }
-
- public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
- {
- nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 3);
- }
-
- public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
- {
- nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 4);
- }
-
- public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void
- {
- nme_gl_uniform_matrix(location, transpose, Float32Array.fromMatrix(matrix).getByteBuffer() , 4);
- }
-
- public static function useProgram(program:GLProgram):Void
- {
- nme_gl_use_program(program == null ? 0 : program.id);
- }
-
- public static function validateProgram(program:GLProgram):Void
- {
- nme_gl_validate_program(program.id);
- }
-
- public static function vertexAttrib1f(indx:Int, x:Float):Void
- {
- nme_gl_vertex_attrib1f(indx, x);
- }
-
- public static function vertexAttrib1fv(indx:Int, values:Array):Void
- {
- nme_gl_vertex_attrib1fv(indx, values);
- }
-
- public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void
- {
- nme_gl_vertex_attrib2f(indx, x, y);
- }
-
- public static function vertexAttrib2fv(indx:Int, values:Array):Void
- {
- nme_gl_vertex_attrib2fv(indx, values);
- }
-
- public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void
- {
- nme_gl_vertex_attrib3f(indx, x, y, z);
- }
-
- public static function vertexAttrib3fv(indx:Int, values:Array):Void
- {
- nme_gl_vertex_attrib3fv(indx, values);
- }
-
- public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void
- {
- nme_gl_vertex_attrib4f(indx, x, y, z, w);
- }
-
- public static function vertexAttrib4fv(indx:Int, values:Array):Void
- {
- nme_gl_vertex_attrib4fv(indx, values);
- }
-
- public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void
- {
- nme_gl_vertex_attrib_pointer(indx, size, type, normalized, stride, offset);
- }
-
- public static function viewport(x:Int, y:Int, width:Int, height:Int):Void
- {
- nme_gl_viewport(x, y, width, height);
- }
-
-
-
-
- // Getters & Setters
-
-
-
-
- private static function get_drawingBufferHeight() { return 640; }//Lib.current.stage.stageHeight; }
- private static function get_drawingBufferWidth() { return 960; } //Lib.current.stage.stageWidth; }
- private static function get_version():Int { return nme_gl_version(); }
-
-
-
-
- // Native Methods
-
-
-
-
- private static var nme_gl_active_texture = load("nme_gl_active_texture", 1);
- private static var nme_gl_attach_shader = load("nme_gl_attach_shader", 2);
- private static var nme_gl_bind_attrib_location = load("nme_gl_bind_attrib_location", 3);
- private static var nme_gl_bind_bitmap_data_texture = load("nme_gl_bind_bitmap_data_texture", 1);
- private static var nme_gl_bind_buffer = load("nme_gl_bind_buffer", 2);
- private static var nme_gl_bind_framebuffer = load("nme_gl_bind_framebuffer", 2);
- private static var nme_gl_bind_renderbuffer = load("nme_gl_bind_renderbuffer", 2);
- private static var nme_gl_bind_texture = load("nme_gl_bind_texture", 2);
- private static var nme_gl_blend_color = load("nme_gl_blend_color", 4);
- private static var nme_gl_blend_equation = load("nme_gl_blend_equation", 1);
- private static var nme_gl_blend_equation_separate = load("nme_gl_blend_equation_separate", 2);
- private static var nme_gl_blend_func = load("nme_gl_blend_func", 2);
- private static var nme_gl_blend_func_separate = load("nme_gl_blend_func_separate", 4);
- private static var nme_gl_buffer_data = load("nme_gl_buffer_data", 5);
- private static var nme_gl_buffer_sub_data = load("nme_gl_buffer_sub_data", 5);
- private static var nme_gl_check_framebuffer_status = load("nme_gl_check_framebuffer_status", 1);
- private static var nme_gl_clear = load("nme_gl_clear", 1);
- private static var nme_gl_clear_color = load("nme_gl_clear_color", 4);
- private static var nme_gl_clear_depth = load("nme_gl_clear_depth", 1);
- private static var nme_gl_clear_stencil = load("nme_gl_clear_stencil", 1);
- private static var nme_gl_color_mask = load("nme_gl_color_mask", 4);
- private static var nme_gl_compile_shader = load("nme_gl_compile_shader", 1);
- private static var nme_gl_compressed_tex_image_2d = load("nme_gl_compressed_tex_image_2d", -1);
- private static var nme_gl_compressed_tex_sub_image_2d = load("nme_gl_compressed_tex_sub_image_2d", -1);
- private static var nme_gl_copy_tex_image_2d = load("nme_gl_copy_tex_image_2d", -1);
- private static var nme_gl_copy_tex_sub_image_2d = load("nme_gl_copy_tex_sub_image_2d", -1);
- private static var nme_gl_create_buffer = load("nme_gl_create_buffer", 0);
- private static var nme_gl_create_framebuffer = load("nme_gl_create_framebuffer", 0);
- private static var nme_gl_create_program = load("nme_gl_create_program", 0);
- private static var nme_gl_create_render_buffer = load("nme_gl_create_render_buffer", 0);
- private static var nme_gl_create_shader = load("nme_gl_create_shader", 1);
- private static var nme_gl_create_texture = load("nme_gl_create_texture", 0);
- private static var nme_gl_delete_buffer = load("nme_gl_delete_buffer", 1);
- private static var nme_gl_delete_program = load("nme_gl_delete_program", 1);
- private static var nme_gl_delete_shader = load("nme_gl_delete_shader", 1);
- private static var nme_gl_delete_texture = load("nme_gl_delete_texture", 1);
- private static var nme_gl_depth_func = load("nme_gl_depth_func", 1);
- private static var nme_gl_depth_mask = load("nme_gl_depth_mask", 1);
- private static var nme_gl_depth_range = load("nme_gl_depth_range", 2);
- private static var nme_gl_detach_shader = load("nme_gl_detach_shader", 2);
- private static var nme_gl_disable = load("nme_gl_disable", 1);
- private static var nme_gl_disable_vertex_attrib_array = load("nme_gl_disable_vertex_attrib_array", 1);
- private static var nme_gl_draw_arrays = load("nme_gl_draw_arrays", 3);
- private static var nme_gl_draw_elements = load("nme_gl_draw_elements", 4);
- private static var nme_gl_enable = load("nme_gl_enable", 1);
- private static var nme_gl_enable_vertex_attrib_array = load("nme_gl_enable_vertex_attrib_array", 1);
- private static var nme_gl_finish = load("nme_gl_finish", 0);
- private static var nme_gl_flush = load("nme_gl_flush", 0);
- private static var nme_gl_framebuffer_renderbuffer = load("nme_gl_framebuffer_renderbuffer", 4);
- private static var nme_gl_framebuffer_texture2D = load("nme_gl_framebuffer_texture2D", 5);
- private static var nme_gl_front_face = load("nme_gl_front_face", 1);
- private static var nme_gl_generate_mipmap = load("nme_gl_generate_mipmap", 1);
- private static var nme_gl_get_active_attrib = load("nme_gl_get_active_attrib", 2);
- private static var nme_gl_get_active_uniform = load("nme_gl_get_active_uniform", 2);
- private static var nme_gl_get_attrib_location = load("nme_gl_get_attrib_location", 2);
- private static var nme_gl_get_buffer_paramerter = load("nme_gl_get_buffer_paramerter", 2);
- private static var nme_gl_get_context_attributes = load("nme_gl_get_context_attributes", 0);
- private static var nme_gl_get_error = load("nme_gl_get_error", 0);
- private static var nme_gl_get_framebuffer_attachment_parameter = load("nme_gl_get_framebuffer_attachment_parameter", 3);
- private static var nme_gl_get_parameter = load("nme_gl_get_parameter", 1);
- private static var nme_gl_get_program_info_log = load("nme_gl_get_program_info_log", 1);
- private static var nme_gl_get_program_parameter = load("nme_gl_get_program_parameter", 2);
- private static var nme_gl_get_render_buffer_parameter = load("nme_gl_get_render_buffer_parameter", 2);
- private static var nme_gl_get_shader_info_log = load("nme_gl_get_shader_info_log", 1);
- private static var nme_gl_get_shader_parameter = load("nme_gl_get_shader_parameter", 2);
- private static var nme_gl_get_shader_precision_format = load("nme_gl_get_shader_precision_format", 2);
- private static var nme_gl_get_shader_source = load("nme_gl_get_shader_source", 1);
- private static var nme_gl_get_supported_extensions = load("nme_gl_get_supported_extensions", 1);
- private static var nme_gl_get_tex_parameter = load("nme_gl_get_tex_parameter", 2);
- private static var nme_gl_get_uniform = load("nme_gl_get_uniform", 2);
- private static var nme_gl_get_uniform_location = load("nme_gl_get_uniform_location", 2);
- private static var nme_gl_get_vertex_attrib = load("nme_gl_get_vertex_attrib", 2);
- private static var nme_gl_get_vertex_attrib_offset = load("nme_gl_get_vertex_attrib_offset", 2);
- private static var nme_gl_hint = load("nme_gl_hint", 2);
- private static var nme_gl_is_buffer = load("nme_gl_is_buffer", 1);
- private static var nme_gl_is_enabled = load("nme_gl_is_enabled", 1);
- private static var nme_gl_is_framebuffer = load("nme_gl_is_framebuffer", 1);
- private static var nme_gl_is_program = load("nme_gl_is_program", 1);
- private static var nme_gl_is_renderbuffer = load("nme_gl_is_renderbuffer", 1);
- private static var nme_gl_is_shader = load("nme_gl_is_shader", 1);
- private static var nme_gl_is_texture = load("nme_gl_is_texture", 1);
- private static var nme_gl_line_width = load("nme_gl_line_width", 1);
- private static var nme_gl_link_program = load("nme_gl_link_program", 1);
- private static var nme_gl_pixel_storei = load("nme_gl_pixel_storei", 2);
- private static var nme_gl_polygon_offset = load("nme_gl_polygon_offset", 2);
- private static var nme_gl_renderbuffer_storage = load("nme_gl_renderbuffer_storage", 4);
- private static var nme_gl_sample_coverage = load("nme_gl_sample_coverage", 2);
- private static var nme_gl_scissor = load("nme_gl_scissor", 4);
- private static var nme_gl_shader_source = load("nme_gl_shader_source", 2);
- private static var nme_gl_stencil_func = load("nme_gl_stencil_func", 3);
- private static var nme_gl_stencil_func_separate = load("nme_gl_stencil_func_separate", 4);
- private static var nme_gl_stencil_mask = load("nme_gl_stencil_mask", 1);
- private static var nme_gl_stencil_mask_separate = load("nme_gl_stencil_mask_separate", 2);
- private static var nme_gl_stencil_op = load("nme_gl_stencil_op", 3);
- private static var nme_gl_stencil_op_separate = load("nme_gl_stencil_op_separate", 4);
- private static var nme_gl_tex_image_2d = load("nme_gl_tex_image_2d", -1);
- private static var nme_gl_tex_parameterf = load("nme_gl_tex_parameterf", 3);
- private static var nme_gl_tex_parameteri = load("nme_gl_tex_parameteri", 3);
- private static var nme_gl_tex_sub_image_2d = load("nme_gl_tex_sub_image_2d", -1);
- private static var nme_gl_uniform1f = load("nme_gl_uniform1f", 2);
- private static var nme_gl_uniform1fv = load("nme_gl_uniform1fv", 2);
- private static var nme_gl_uniform1i = load("nme_gl_uniform1i", 2);
- private static var nme_gl_uniform1iv = load("nme_gl_uniform1iv", 2);
- private static var nme_gl_uniform2f = load("nme_gl_uniform2f", 3);
- private static var nme_gl_uniform2fv = load("nme_gl_uniform2fv", 2);
- private static var nme_gl_uniform2i = load("nme_gl_uniform2i", 3);
- private static var nme_gl_uniform2iv = load("nme_gl_uniform2iv", 2);
- private static var nme_gl_uniform3f = load("nme_gl_uniform3f", 4);
- private static var nme_gl_uniform3fv = load("nme_gl_uniform3fv", 2);
- private static var nme_gl_uniform3i = load("nme_gl_uniform3i", 4);
- private static var nme_gl_uniform3iv = load("nme_gl_uniform3iv", 2);
- private static var nme_gl_uniform4f = load("nme_gl_uniform4f", 5);
- private static var nme_gl_uniform4fv = load("nme_gl_uniform4fv", 2);
- private static var nme_gl_uniform4i = load("nme_gl_uniform4i", 5);
- private static var nme_gl_uniform4iv = load("nme_gl_uniform4iv", 2);
- private static var nme_gl_uniform_matrix = load("nme_gl_uniform_matrix", 4);
- private static var nme_gl_use_program = load("nme_gl_use_program", 1);
- private static var nme_gl_validate_program = load("nme_gl_validate_program", 1);
- private static var nme_gl_version = load("nme_gl_version", 0);
- private static var nme_gl_vertex_attrib1f = load("nme_gl_vertex_attrib1f", 2);
- private static var nme_gl_vertex_attrib1fv = load("nme_gl_vertex_attrib1fv", 2);
- private static var nme_gl_vertex_attrib2f = load("nme_gl_vertex_attrib2f", 3);
- private static var nme_gl_vertex_attrib2fv = load("nme_gl_vertex_attrib2fv", 2);
- private static var nme_gl_vertex_attrib3f = load("nme_gl_vertex_attrib3f", 4);
- private static var nme_gl_vertex_attrib3fv = load("nme_gl_vertex_attrib3fv", 2);
- private static var nme_gl_vertex_attrib4f = load("nme_gl_vertex_attrib4f", 5);
- private static var nme_gl_vertex_attrib4fv = load("nme_gl_vertex_attrib4fv", 2);
- private static var nme_gl_vertex_attrib_pointer = load("nme_gl_vertex_attrib_pointer", -1);
- private static var nme_gl_viewport = load("nme_gl_viewport", 4);
-
-
-}
-
-
-typedef ShaderPrecisionFormat =
-{
- rangeMin : Int,
- rangeMax : Int,
- precision : Int,
-
-};
\ No newline at end of file
+package lime.gl;
+
+
+#if lime_native
+
+ typedef GL = lime.gl.native.GL;
+
+#end //lime_native
+
+
+#if lime_html5
+
+ typedef GL = lime.gl.html5.GL;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLActiveInfo.hx b/lime/gl/GLActiveInfo.hx
index d1cfa3535..fd56939aa 100644
--- a/lime/gl/GLActiveInfo.hx
+++ b/lime/gl/GLActiveInfo.hx
@@ -1,5 +1,6 @@
package lime.gl;
+#if lime_native
typedef GLActiveInfo = {
@@ -7,4 +8,12 @@ typedef GLActiveInfo = {
type : Int,
name : String,
-};
\ No newline at end of file
+};
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLActiveInfo = js.html.webgl.ActiveInfo;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLBuffer.hx b/lime/gl/GLBuffer.hx
index 9309624cd..94e8b5b9f 100644
--- a/lime/gl/GLBuffer.hx
+++ b/lime/gl/GLBuffer.hx
@@ -1,21 +1,20 @@
package lime.gl;
+#if lime_native
-class GLBuffer extends GLObject {
-
-
- public function new (version:Int, id:Dynamic) {
-
- super (version, id);
-
+ class GLBuffer extends GLObject {
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ }
+ override function getType ():String {
+ return "Buffer";
+ }
}
-
-
- override function getType ():String {
-
- return "Buffer";
-
- }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLBuffer = js.html.webgl.Buffer;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLContextAttributes.hx b/lime/gl/GLContextAttributes.hx
index 0c22c71a6..8f5c4535f 100644
--- a/lime/gl/GLContextAttributes.hx
+++ b/lime/gl/GLContextAttributes.hx
@@ -1,13 +1,23 @@
package lime.gl;
-typedef GLContextAttributes = {
-
- alpha:Bool,
- depth:Bool,
- stencil:Bool,
- antialias:Bool,
- premultipliedAlpha:Bool,
- preserveDrawingBuffer:Bool,
-
-};
\ No newline at end of file
+#if lime_native
+
+ typedef GLContextAttributes = {
+
+ alpha:Bool,
+ depth:Bool,
+ stencil:Bool,
+ antialias:Bool,
+ premultipliedAlpha:Bool,
+ preserveDrawingBuffer:Bool,
+
+ };
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLContextAttributes = js.html.webgl.ContextAttributes;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLFramebuffer.hx b/lime/gl/GLFramebuffer.hx
index ceaf1028e..07b4d44cf 100644
--- a/lime/gl/GLFramebuffer.hx
+++ b/lime/gl/GLFramebuffer.hx
@@ -1,21 +1,25 @@
package lime.gl;
+#if lime_native
-class GLFramebuffer extends GLObject {
-
-
- public function new (version:Int, id:Dynamic) {
+ class GLFramebuffer extends GLObject {
- super (version, id);
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ }
- }
-
-
- override function getType ():String {
+ override function getType ():String {
+ return "Framebuffer";
+ }
- return "Framebuffer";
-
- }
+ } //GLFramebuffer
+
+
+#end //lime_native
+
+
+#if lime_html5
-
-}
\ No newline at end of file
+ typedef GLFramebuffer = js.html.webgl.Framebuffer;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLObject.hx b/lime/gl/GLObject.hx
index bfee596c5..68a96d4fb 100644
--- a/lime/gl/GLObject.hx
+++ b/lime/gl/GLObject.hx
@@ -1,78 +1,58 @@
package lime.gl;
+#if lime_native
-class GLObject {
-
-
- public var id (default, null):Dynamic;
- public var invalidated (get, null):Bool;
- public var valid (get, null):Bool;
-
- private var version:Int;
-
-
- private function new (version:Int, id:Dynamic) {
+ class GLObject {
- this.version = version;
- this.id = id;
+ public var id (default, null):Dynamic;
+ public var invalidated (get, null):Bool;
+ public var valid (get, null):Bool;
+
+ private var version:Int;
+
+ private function new (version:Int, id:Dynamic) {
+
+ this.version = version;
+ this.id = id;
+
+ }
+
+ private function getType ():String {
+ return "GLObject";
+ }
+
+ public function invalidate ():Void {
+ id = null;
+ }
+
+ public function isValid ():Bool {
+ return id != null && version == GL.version;
+ }
+
+ public function isInvalid ():Bool {
+ return !isValid ();
+ }
+
+ public function toString ():String {
+ return getType () + "(" + id + ")";
+ }
+
+ // Getters & Setters
+
+ private function get_invalidated ():Bool {
+ return isInvalid ();
+ }
+
+ private function get_valid ():Bool {
+ return isValid ();
+ }
}
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLObject = Dynamic;
-
- private function getType ():String {
-
- return "GLObject";
-
- }
-
-
- public function invalidate ():Void {
-
- id = null;
-
- }
-
-
- public function isValid ():Bool {
-
- return id != null && version == GL.version;
-
- }
-
-
- public function isInvalid ():Bool {
-
- return !isValid ();
-
- }
-
-
- public function toString ():String {
-
- return getType () + "(" + id + ")";
-
- }
-
-
-
-
- // Getters & Setters
-
-
-
-
- private function get_invalidated ():Bool {
-
- return isInvalid ();
-
- }
-
-
- private function get_valid ():Bool {
-
- return isValid ();
-
- }
-
-
-}
\ No newline at end of file
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLProgram.hx b/lime/gl/GLProgram.hx
index ff50a83d4..b6b46bc52 100644
--- a/lime/gl/GLProgram.hx
+++ b/lime/gl/GLProgram.hx
@@ -1,39 +1,34 @@
package lime.gl;
-class GLProgram extends GLObject {
-
-
- public var shaders:Array;
-
-
- public function new (version:Int, id:Dynamic) {
+#if lime_native
+
+ class GLProgram extends GLObject {
- super (version, id);
- shaders = new Array ();
+ public var shaders:Array;
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ shaders = new Array ();
+ }
+
+ public function attach (shader:GLShader):Void {
+ shaders.push (shader);
+ }
+
+ public function getShaders ():Array {
+ return shaders.copy ();
+ }
+
+ override private function getType ():String {
+ return "Program";
+ }
}
-
-
- public function attach (shader:GLShader):Void {
-
- shaders.push (shader);
-
- }
-
-
- public function getShaders ():Array {
-
- return shaders.copy ();
-
- }
-
-
- override private function getType ():String {
-
- return "Program";
-
- }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLProgram = js.html.webgl.Program;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLRenderbuffer.hx b/lime/gl/GLRenderbuffer.hx
index 03f3e3d23..420f2b4b4 100644
--- a/lime/gl/GLRenderbuffer.hx
+++ b/lime/gl/GLRenderbuffer.hx
@@ -1,21 +1,24 @@
package lime.gl;
-class GLRenderbuffer extends GLObject {
-
-
- public function new (version:Int, id:Dynamic) {
+#if lime_native
+
+ class GLRenderbuffer extends GLObject {
- super (version, id);
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ }
+
+ override private function getType ():String {
+ return "Renderbuffer";
+ }
}
-
-
- override private function getType ():String {
-
- return "Renderbuffer";
-
- }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLRenderbuffer = js.html.webgl.Renderbuffer;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLShader.hx b/lime/gl/GLShader.hx
index 32ce722f2..30b4fc793 100644
--- a/lime/gl/GLShader.hx
+++ b/lime/gl/GLShader.hx
@@ -1,21 +1,24 @@
package lime.gl;
-class GLShader extends GLObject {
-
-
- public function new (version:Int, id:Dynamic) {
+#if lime_native
+
+ class GLShader extends GLObject {
- super (version, id);
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ }
+
+ override private function getType ():String {
+ return "Shader";
+ }
}
+
+#end //lime_native
+
+#if lime_html5
-
- override private function getType ():String {
-
- return "Shader";
-
- }
-
-
-}
\ No newline at end of file
+ typedef GLShader = js.html.webgl.Shader;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLTexture.hx b/lime/gl/GLTexture.hx
index 96a10735f..2f2db532b 100644
--- a/lime/gl/GLTexture.hx
+++ b/lime/gl/GLTexture.hx
@@ -1,21 +1,25 @@
package lime.gl;
-class GLTexture extends GLObject {
-
-
- public function new (version:Int, id:Dynamic) {
+#if lime_native
+
+ class GLTexture extends GLObject {
- super (version, id);
+ public function new (version:Int, id:Dynamic) {
+ super (version, id);
+ }
+
+ override private function getType ():String {
+ return "Texture";
+ }
}
-
-
- override private function getType ():String {
-
- return "Texture";
-
- }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
+
+
+#if lime_html5
+
+ typedef GLTexture = js.html.webgl.Texture;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/GLUniformLocation.hx b/lime/gl/GLUniformLocation.hx
index 3d7e2559a..44691d2e6 100644
--- a/lime/gl/GLUniformLocation.hx
+++ b/lime/gl/GLUniformLocation.hx
@@ -1,4 +1,13 @@
package lime.gl;
+#if lime_native
-typedef GLUniformLocation = Dynamic;
\ No newline at end of file
+ typedef GLUniformLocation = Dynamic;
+
+#end //lime_native
+
+#if lime_html5
+
+ typedef GLUniformLocation = js.html.webgl.UniformLocation;
+
+#end //lime_html5
\ No newline at end of file
diff --git a/lime/gl/html5/GL.hx b/lime/gl/html5/GL.hx
new file mode 100644
index 000000000..2f80c311e
--- /dev/null
+++ b/lime/gl/html5/GL.hx
@@ -0,0 +1,1464 @@
+package lime.gl.html5;
+#if js
+
+
+// import flash.display.BitmapData;
+import lime.geometry.Matrix3D;
+import lime.utils.ByteArray;
+// import lime.Lib;
+import js.html.webgl.RenderingContext;
+import lime.utils.ArrayBuffer;
+import lime.utils.ArrayBufferView;
+import lime.utils.Int32Array;
+import lime.utils.Float32Array;
+
+
+class GL {
+
+
+ /* ClearBufferMask */
+ public static inline var DEPTH_BUFFER_BIT = 0x00000100;
+ public static inline var STENCIL_BUFFER_BIT = 0x00000400;
+ public static inline var COLOR_BUFFER_BIT = 0x00004000;
+
+ /* BeginMode */
+ public static inline var POINTS = 0x0000;
+ public static inline var LINES = 0x0001;
+ public static inline var LINE_LOOP = 0x0002;
+ public static inline var LINE_STRIP = 0x0003;
+ public static inline var TRIANGLES = 0x0004;
+ public static inline var TRIANGLE_STRIP = 0x0005;
+ public static inline var TRIANGLE_FAN = 0x0006;
+
+ /* AlphaFunction(not supported in ES20) */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+
+ /* BlendingFactorDest */
+ public static inline var ZERO = 0;
+ public static inline var ONE = 1;
+ public static inline var SRC_COLOR = 0x0300;
+ public static inline var ONE_MINUS_SRC_COLOR = 0x0301;
+ public static inline var SRC_ALPHA = 0x0302;
+ public static inline var ONE_MINUS_SRC_ALPHA = 0x0303;
+ public static inline var DST_ALPHA = 0x0304;
+ public static inline var ONE_MINUS_DST_ALPHA = 0x0305;
+
+ /* BlendingFactorSrc */
+ /* ZERO */
+ /* ONE */
+ public static inline var DST_COLOR = 0x0306;
+ public static inline var ONE_MINUS_DST_COLOR = 0x0307;
+ public static inline var SRC_ALPHA_SATURATE = 0x0308;
+ /* SRC_ALPHA */
+ /* ONE_MINUS_SRC_ALPHA */
+ /* DST_ALPHA */
+ /* ONE_MINUS_DST_ALPHA */
+
+ /* BlendEquationSeparate */
+ public static inline var FUNC_ADD = 0x8006;
+ public static inline var BLEND_EQUATION = 0x8009;
+ public static inline var BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */
+ public static inline var BLEND_EQUATION_ALPHA = 0x883D;
+
+ /* BlendSubtract */
+ public static inline var FUNC_SUBTRACT = 0x800A;
+ public static inline var FUNC_REVERSE_SUBTRACT = 0x800B;
+
+ /* Separate Blend Functions */
+ public static inline var BLEND_DST_RGB = 0x80C8;
+ public static inline var BLEND_SRC_RGB = 0x80C9;
+ public static inline var BLEND_DST_ALPHA = 0x80CA;
+ public static inline var BLEND_SRC_ALPHA = 0x80CB;
+ public static inline var CONSTANT_COLOR = 0x8001;
+ public static inline var ONE_MINUS_CONSTANT_COLOR = 0x8002;
+ public static inline var CONSTANT_ALPHA = 0x8003;
+ public static inline var ONE_MINUS_CONSTANT_ALPHA = 0x8004;
+ public static inline var BLEND_COLOR = 0x8005;
+
+ /* GLBuffer Objects */
+ public static inline var ARRAY_BUFFER = 0x8892;
+ public static inline var ELEMENT_ARRAY_BUFFER = 0x8893;
+ public static inline var ARRAY_BUFFER_BINDING = 0x8894;
+ public static inline var ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
+
+ public static inline var STREAM_DRAW = 0x88E0;
+ public static inline var STATIC_DRAW = 0x88E4;
+ public static inline var DYNAMIC_DRAW = 0x88E8;
+
+ public static inline var BUFFER_SIZE = 0x8764;
+ public static inline var BUFFER_USAGE = 0x8765;
+
+ public static inline var CURRENT_VERTEX_ATTRIB = 0x8626;
+
+ /* CullFaceMode */
+ public static inline var FRONT = 0x0404;
+ public static inline var BACK = 0x0405;
+ public static inline var FRONT_AND_BACK = 0x0408;
+
+ /* DepthFunction */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+
+ /* EnableCap */
+ /* TEXTURE_2D */
+ public static inline var CULL_FACE = 0x0B44;
+ public static inline var BLEND = 0x0BE2;
+ public static inline var DITHER = 0x0BD0;
+ public static inline var STENCIL_TEST = 0x0B90;
+ public static inline var DEPTH_TEST = 0x0B71;
+ public static inline var SCISSOR_TEST = 0x0C11;
+ public static inline var POLYGON_OFFSET_FILL = 0x8037;
+ public static inline var SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
+ public static inline var SAMPLE_COVERAGE = 0x80A0;
+
+ /* ErrorCode */
+ public static inline var NO_ERROR = 0;
+ public static inline var INVALID_ENUM = 0x0500;
+ public static inline var INVALID_VALUE = 0x0501;
+ public static inline var INVALID_OPERATION = 0x0502;
+ public static inline var OUT_OF_MEMORY = 0x0505;
+
+ /* FrontFaceDirection */
+ public static inline var CW = 0x0900;
+ public static inline var CCW = 0x0901;
+
+ /* GetPName */
+ public static inline var LINE_WIDTH = 0x0B21;
+ public static inline var ALIASED_POINT_SIZE_RANGE = 0x846D;
+ public static inline var ALIASED_LINE_WIDTH_RANGE = 0x846E;
+ public static inline var CULL_FACE_MODE = 0x0B45;
+ public static inline var FRONT_FACE = 0x0B46;
+ public static inline var DEPTH_RANGE = 0x0B70;
+ public static inline var DEPTH_WRITEMASK = 0x0B72;
+ public static inline var DEPTH_CLEAR_VALUE = 0x0B73;
+ public static inline var DEPTH_FUNC = 0x0B74;
+ public static inline var STENCIL_CLEAR_VALUE = 0x0B91;
+ public static inline var STENCIL_FUNC = 0x0B92;
+ public static inline var STENCIL_FAIL = 0x0B94;
+ public static inline var STENCIL_PASS_DEPTH_FAIL = 0x0B95;
+ public static inline var STENCIL_PASS_DEPTH_PASS = 0x0B96;
+ public static inline var STENCIL_REF = 0x0B97;
+ public static inline var STENCIL_VALUE_MASK = 0x0B93;
+ public static inline var STENCIL_WRITEMASK = 0x0B98;
+ public static inline var STENCIL_BACK_FUNC = 0x8800;
+ public static inline var STENCIL_BACK_FAIL = 0x8801;
+ public static inline var STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
+ public static inline var STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
+ public static inline var STENCIL_BACK_REF = 0x8CA3;
+ public static inline var STENCIL_BACK_VALUE_MASK = 0x8CA4;
+ public static inline var STENCIL_BACK_WRITEMASK = 0x8CA5;
+ public static inline var VIEWPORT = 0x0BA2;
+ public static inline var SCISSOR_BOX = 0x0C10;
+ /* SCISSOR_TEST */
+ public static inline var COLOR_CLEAR_VALUE = 0x0C22;
+ public static inline var COLOR_WRITEMASK = 0x0C23;
+ public static inline var UNPACK_ALIGNMENT = 0x0CF5;
+ public static inline var PACK_ALIGNMENT = 0x0D05;
+ public static inline var MAX_TEXTURE_SIZE = 0x0D33;
+ public static inline var MAX_VIEWPORT_DIMS = 0x0D3A;
+ public static inline var SUBPIXEL_BITS = 0x0D50;
+ public static inline var RED_BITS = 0x0D52;
+ public static inline var GREEN_BITS = 0x0D53;
+ public static inline var BLUE_BITS = 0x0D54;
+ public static inline var ALPHA_BITS = 0x0D55;
+ public static inline var DEPTH_BITS = 0x0D56;
+ public static inline var STENCIL_BITS = 0x0D57;
+ public static inline var POLYGON_OFFSET_UNITS = 0x2A00;
+ /* POLYGON_OFFSET_FILL */
+ public static inline var POLYGON_OFFSET_FACTOR = 0x8038;
+ public static inline var TEXTURE_BINDING_2D = 0x8069;
+ public static inline var SAMPLE_BUFFERS = 0x80A8;
+ public static inline var SAMPLES = 0x80A9;
+ public static inline var SAMPLE_COVERAGE_VALUE = 0x80AA;
+ public static inline var SAMPLE_COVERAGE_INVERT = 0x80AB;
+
+ /* GetTextureParameter */
+ /* TEXTURE_MAG_FILTER */
+ /* TEXTURE_MIN_FILTER */
+ /* TEXTURE_WRAP_S */
+ /* TEXTURE_WRAP_T */
+
+ public static inline var COMPRESSED_TEXTURE_FORMATS = 0x86A3;
+
+ /* HintMode */
+ public static inline var DONT_CARE = 0x1100;
+ public static inline var FASTEST = 0x1101;
+ public static inline var NICEST = 0x1102;
+
+ /* HintTarget */
+ public static inline var GENERATE_MIPMAP_HINT = 0x8192;
+
+ /* DataType */
+ public static inline var BYTE = 0x1400;
+ public static inline var UNSIGNED_BYTE = 0x1401;
+ public static inline var SHORT = 0x1402;
+ public static inline var UNSIGNED_SHORT = 0x1403;
+ public static inline var INT = 0x1404;
+ public static inline var UNSIGNED_INT = 0x1405;
+ public static inline var FLOAT = 0x1406;
+
+ /* PixelFormat */
+ public static inline var DEPTH_COMPONENT = 0x1902;
+ public static inline var ALPHA = 0x1906;
+ public static inline var RGB = 0x1907;
+ public static inline var RGBA = 0x1908;
+ public static inline var LUMINANCE = 0x1909;
+ public static inline var LUMINANCE_ALPHA = 0x190A;
+
+ /* PixelType */
+ /* UNSIGNED_BYTE */
+ public static inline var UNSIGNED_SHORT_4_4_4_4 = 0x8033;
+ public static inline var UNSIGNED_SHORT_5_5_5_1 = 0x8034;
+ public static inline var UNSIGNED_SHORT_5_6_5 = 0x8363;
+
+ /* Shaders */
+ public static inline var FRAGMENT_SHADER = 0x8B30;
+ public static inline var VERTEX_SHADER = 0x8B31;
+ public static inline var MAX_VERTEX_ATTRIBS = 0x8869;
+ public static inline var MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
+ public static inline var MAX_VARYING_VECTORS = 0x8DFC;
+ public static inline var MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
+ public static inline var MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
+ public static inline var MAX_TEXTURE_IMAGE_UNITS = 0x8872;
+ public static inline var MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
+ public static inline var SHADER_TYPE = 0x8B4F;
+ public static inline var DELETE_STATUS = 0x8B80;
+ public static inline var LINK_STATUS = 0x8B82;
+ public static inline var VALIDATE_STATUS = 0x8B83;
+ public static inline var ATTACHED_SHADERS = 0x8B85;
+ public static inline var ACTIVE_UNIFORMS = 0x8B86;
+ public static inline var ACTIVE_ATTRIBUTES = 0x8B89;
+ public static inline var SHADING_LANGUAGE_VERSION = 0x8B8C;
+ public static inline var CURRENT_PROGRAM = 0x8B8D;
+
+ /* StencilFunction */
+ public static inline var NEVER = 0x0200;
+ public static inline var LESS = 0x0201;
+ public static inline var EQUAL = 0x0202;
+ public static inline var LEQUAL = 0x0203;
+ public static inline var GREATER = 0x0204;
+ public static inline var NOTEQUAL = 0x0205;
+ public static inline var GEQUAL = 0x0206;
+ public static inline var ALWAYS = 0x0207;
+
+ /* StencilOp */
+ /* ZERO */
+ public static inline var KEEP = 0x1E00;
+ public static inline var REPLACE = 0x1E01;
+ public static inline var INCR = 0x1E02;
+ public static inline var DECR = 0x1E03;
+ public static inline var INVERT = 0x150A;
+ public static inline var INCR_WRAP = 0x8507;
+ public static inline var DECR_WRAP = 0x8508;
+
+ /* StringName */
+ public static inline var VENDOR = 0x1F00;
+ public static inline var RENDERER = 0x1F01;
+ public static inline var VERSION = 0x1F02;
+
+ /* TextureMagFilter */
+ public static inline var NEAREST = 0x2600;
+ public static inline var LINEAR = 0x2601;
+
+ /* TextureMinFilter */
+ /* NEAREST */
+ /* LINEAR */
+ public static inline var NEAREST_MIPMAP_NEAREST = 0x2700;
+ public static inline var LINEAR_MIPMAP_NEAREST = 0x2701;
+ public static inline var NEAREST_MIPMAP_LINEAR = 0x2702;
+ public static inline var LINEAR_MIPMAP_LINEAR = 0x2703;
+
+ /* TextureParameterName */
+ public static inline var TEXTURE_MAG_FILTER = 0x2800;
+ public static inline var TEXTURE_MIN_FILTER = 0x2801;
+ public static inline var TEXTURE_WRAP_S = 0x2802;
+ public static inline var TEXTURE_WRAP_T = 0x2803;
+
+ /* TextureTarget */
+ public static inline var TEXTURE_2D = 0x0DE1;
+ public static inline var TEXTURE = 0x1702;
+
+ public static inline var TEXTURE_CUBE_MAP = 0x8513;
+ public static inline var TEXTURE_BINDING_CUBE_MAP = 0x8514;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
+ public static inline var MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
+
+ /* TextureUnit */
+ public static inline var TEXTURE0 = 0x84C0;
+ public static inline var TEXTURE1 = 0x84C1;
+ public static inline var TEXTURE2 = 0x84C2;
+ public static inline var TEXTURE3 = 0x84C3;
+ public static inline var TEXTURE4 = 0x84C4;
+ public static inline var TEXTURE5 = 0x84C5;
+ public static inline var TEXTURE6 = 0x84C6;
+ public static inline var TEXTURE7 = 0x84C7;
+ public static inline var TEXTURE8 = 0x84C8;
+ public static inline var TEXTURE9 = 0x84C9;
+ public static inline var TEXTURE10 = 0x84CA;
+ public static inline var TEXTURE11 = 0x84CB;
+ public static inline var TEXTURE12 = 0x84CC;
+ public static inline var TEXTURE13 = 0x84CD;
+ public static inline var TEXTURE14 = 0x84CE;
+ public static inline var TEXTURE15 = 0x84CF;
+ public static inline var TEXTURE16 = 0x84D0;
+ public static inline var TEXTURE17 = 0x84D1;
+ public static inline var TEXTURE18 = 0x84D2;
+ public static inline var TEXTURE19 = 0x84D3;
+ public static inline var TEXTURE20 = 0x84D4;
+ public static inline var TEXTURE21 = 0x84D5;
+ public static inline var TEXTURE22 = 0x84D6;
+ public static inline var TEXTURE23 = 0x84D7;
+ public static inline var TEXTURE24 = 0x84D8;
+ public static inline var TEXTURE25 = 0x84D9;
+ public static inline var TEXTURE26 = 0x84DA;
+ public static inline var TEXTURE27 = 0x84DB;
+ public static inline var TEXTURE28 = 0x84DC;
+ public static inline var TEXTURE29 = 0x84DD;
+ public static inline var TEXTURE30 = 0x84DE;
+ public static inline var TEXTURE31 = 0x84DF;
+ public static inline var ACTIVE_TEXTURE = 0x84E0;
+
+ /* TextureWrapMode */
+ public static inline var REPEAT = 0x2901;
+ public static inline var CLAMP_TO_EDGE = 0x812F;
+ public static inline var MIRRORED_REPEAT = 0x8370;
+
+ /* Uniform Types */
+ public static inline var FLOAT_VEC2 = 0x8B50;
+ public static inline var FLOAT_VEC3 = 0x8B51;
+ public static inline var FLOAT_VEC4 = 0x8B52;
+ public static inline var INT_VEC2 = 0x8B53;
+ public static inline var INT_VEC3 = 0x8B54;
+ public static inline var INT_VEC4 = 0x8B55;
+ public static inline var BOOL = 0x8B56;
+ public static inline var BOOL_VEC2 = 0x8B57;
+ public static inline var BOOL_VEC3 = 0x8B58;
+ public static inline var BOOL_VEC4 = 0x8B59;
+ public static inline var FLOAT_MAT2 = 0x8B5A;
+ public static inline var FLOAT_MAT3 = 0x8B5B;
+ public static inline var FLOAT_MAT4 = 0x8B5C;
+ public static inline var SAMPLER_2D = 0x8B5E;
+ public static inline var SAMPLER_CUBE = 0x8B60;
+
+ /* Vertex Arrays */
+ public static inline var VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
+ public static inline var VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
+ public static inline var VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
+ public static inline var VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
+ public static inline var VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
+ public static inline var VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
+ public static inline var VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
+
+ /* Point Size */
+ public static inline var VERTEX_PROGRAM_POINT_SIZE = 0x8642;
+ public static inline var POINT_SPRITE = 0x8861;
+
+ /* GLShader Source */
+ public static inline var COMPILE_STATUS = 0x8B81;
+
+ /* GLShader Precision-Specified Types */
+ public static inline var LOW_FLOAT = 0x8DF0;
+ public static inline var MEDIUM_FLOAT = 0x8DF1;
+ public static inline var HIGH_FLOAT = 0x8DF2;
+ public static inline var LOW_INT = 0x8DF3;
+ public static inline var MEDIUM_INT = 0x8DF4;
+ public static inline var HIGH_INT = 0x8DF5;
+
+ /* GLFramebuffer Object. */
+ public static inline var FRAMEBUFFER = 0x8D40;
+ public static inline var RENDERBUFFER = 0x8D41;
+
+ public static inline var RGBA4 = 0x8056;
+ public static inline var RGB5_A1 = 0x8057;
+ public static inline var RGB565 = 0x8D62;
+ public static inline var DEPTH_COMPONENT16 = 0x81A5;
+ public static inline var STENCIL_INDEX = 0x1901;
+ public static inline var STENCIL_INDEX8 = 0x8D48;
+ public static inline var DEPTH_STENCIL = 0x84F9;
+
+ public static inline var RENDERBUFFER_WIDTH = 0x8D42;
+ public static inline var RENDERBUFFER_HEIGHT = 0x8D43;
+ public static inline var RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
+ public static inline var RENDERBUFFER_RED_SIZE = 0x8D50;
+ public static inline var RENDERBUFFER_GREEN_SIZE = 0x8D51;
+ public static inline var RENDERBUFFER_BLUE_SIZE = 0x8D52;
+ public static inline var RENDERBUFFER_ALPHA_SIZE = 0x8D53;
+ public static inline var RENDERBUFFER_DEPTH_SIZE = 0x8D54;
+ public static inline var RENDERBUFFER_STENCIL_SIZE = 0x8D55;
+
+ public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
+ public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
+ public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
+ public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
+
+ public static inline var COLOR_ATTACHMENT0 = 0x8CE0;
+ public static inline var DEPTH_ATTACHMENT = 0x8D00;
+ public static inline var STENCIL_ATTACHMENT = 0x8D20;
+ public static inline var DEPTH_STENCIL_ATTACHMENT = 0x821A;
+
+ public static inline var NONE = 0;
+
+ public static inline var FRAMEBUFFER_COMPLETE = 0x8CD5;
+ public static inline var FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
+ public static inline var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
+ public static inline var FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
+ public static inline var FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
+
+ public static inline var FRAMEBUFFER_BINDING = 0x8CA6;
+ public static inline var RENDERBUFFER_BINDING = 0x8CA7;
+ public static inline var MAX_RENDERBUFFER_SIZE = 0x84E8;
+
+ public static inline var INVALID_FRAMEBUFFER_OPERATION = 0x0506;
+
+ /* WebGL-specific enums */
+ public static inline var UNPACK_FLIP_Y_WEBGL = 0x9240;
+ public static inline var UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
+ public static inline var CONTEXT_LOST_WEBGL = 0x9242;
+ public static inline var UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
+ public static inline var BROWSER_DEFAULT_WEBGL = 0x9244;
+
+
+ public static var drawingBufferHeight(get_drawingBufferHeight, null):Int;
+ public static var drawingBufferWidth(get_drawingBufferWidth, null):Int;
+ public static var version(get_version, null):Int;
+
+ public static var nmeContext:RenderingContext;
+
+
+
+ public static function activeTexture(texture:Int):Void {
+
+ nmeContext.activeTexture(texture);
+
+ }
+
+
+ public static function attachShader(program:GLProgram, shader:GLShader):Void {
+
+ nmeContext.attachShader(program, shader);
+
+ }
+
+
+ public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void {
+
+ nmeContext.bindAttribLocation(program, index, name);
+
+ }
+
+/*
+ public static function bindBitmapDataTexture(texture:BitmapData):Void {
+
+ if (texture.nmeGLTexture == null) {
+
+ texture.nmeGLTexture = nmeContext.createTexture();
+ nmeContext.bindTexture(TEXTURE_2D, texture.nmeGLTexture);
+
+ nmeContext.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
+ nmeContext.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
+ nmeContext.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST);
+ nmeContext.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST);
+
+ texture.lock();
+ nmeContext.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, texture.nmeImageData);
+ texture.unlock();
+
+ } else {
+
+ nmeContext.bindTexture(TEXTURE_2D, texture.nmeGLTexture);
+
+ }
+
+ }
+*/
+
+ public static function bindBuffer(target:Int, buffer:GLBuffer):Void {
+
+ nmeContext.bindBuffer(target, buffer);
+
+ }
+
+
+ public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void {
+
+ nmeContext.bindFramebuffer(target, framebuffer);
+
+ }
+
+
+ public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void {
+
+ nmeContext.bindRenderbuffer(target, renderbuffer);
+
+ }
+
+
+ public static function bindTexture(target:Int, texture:GLTexture):Void {
+
+ nmeContext.bindTexture(target, texture);
+
+ }
+
+
+ public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void {
+
+ nmeContext.blendColor(red, green, blue, alpha);
+
+ }
+
+
+ public static function blendEquation(mode:Int):Void {
+
+ nmeContext.blendEquation(mode);
+
+ }
+
+
+ public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void {
+
+ nmeContext.blendEquationSeparate(modeRGB, modeAlpha);
+
+ }
+
+
+ public static function blendFunc(sfactor:Int, dfactor:Int):Void {
+
+ nmeContext.blendFunc(sfactor, dfactor);
+
+ }
+
+
+ public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void {
+
+ nmeContext.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+
+ }
+
+
+ //public static function bufferData(target:Int, data:IMemoryRange, usage:Int):Void {
+ public static function bufferData(target:Int, data:ArrayBufferView, usage:Int):Void {
+
+ nmeContext.bufferData(target, data, usage);
+
+ }
+
+
+ public static function bufferSubData(target:Int, offset:Int, data:ArrayBufferView):Void {
+
+ nmeContext.bufferSubData(target, offset, data);
+
+ }
+
+
+ public static function checkFramebufferStatus(target:Int):Int {
+
+ return nmeContext.checkFramebufferStatus(target);
+
+ }
+
+
+ public static function clear(mask:Int):Void {
+
+ nmeContext.clear(mask);
+
+ }
+
+
+ public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void {
+
+ nmeContext.clearColor(red, green, blue, alpha);
+
+ }
+
+
+ public static function clearDepth(depth:Float):Void {
+
+ nmeContext.clearDepth(depth);
+
+ }
+
+
+ public static function clearStencil(s:Int):Void {
+
+ nmeContext.clearStencil(s);
+
+ }
+
+
+ public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void {
+
+ nmeContext.colorMask(red, green, blue, alpha);
+
+ }
+
+
+ public static function compileShader(shader:GLShader):Void {
+
+ nmeContext.compileShader(shader);
+
+ }
+
+
+ public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:ArrayBufferView):Void {
+
+ nmeContext.compressedTexImage2D(target, level, internalformat, width, height, border, data);
+
+ }
+
+
+ public static function compressedTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:ArrayBufferView):Void {
+
+ nmeContext.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, data);
+
+ }
+
+
+ public static function copyTexImage2D(target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void {
+
+ nmeContext.copyTexImage2D(target, level, internalformat, x, y, width, height, border);
+
+ }
+
+
+ public static function copyTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void {
+
+ nmeContext.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+
+ }
+
+
+ public static function createBuffer():GLBuffer {
+
+ return nmeContext.createBuffer();
+
+ }
+
+
+ public static function createFramebuffer():GLFramebuffer {
+
+ return nmeContext.createFramebuffer();
+
+ }
+
+
+ public static function createProgram():GLProgram {
+
+ return nmeContext.createProgram();
+
+ }
+
+
+ public static function createRenderbuffer():GLRenderbuffer {
+
+ return nmeContext.createRenderbuffer();
+
+ }
+
+
+ public static function createShader(type:Int):GLShader {
+
+ return nmeContext.createShader(type);
+
+ }
+
+
+ public static function createTexture():GLTexture {
+
+ return nmeContext.createTexture();
+
+ }
+
+
+ public static function cullFace(mode:Int):Void {
+
+ nmeContext.cullFace(mode);
+
+ }
+
+
+ public static function deleteBuffer(buffer:GLBuffer):Void {
+
+ nmeContext.deleteBuffer(buffer);
+
+ }
+
+
+ public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void {
+
+ nmeContext.deleteFramebuffer(framebuffer);
+
+ }
+
+
+ public static function deleteProgram(program:GLProgram):Void {
+
+ nmeContext.deleteProgram(program);
+
+ }
+
+
+ public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void {
+
+ nmeContext.deleteRenderbuffer(renderbuffer);
+
+ }
+
+
+ public static function deleteShader(shader:GLShader):Void {
+
+ nmeContext.deleteShader(shader);
+
+ }
+
+
+ public static function deleteTexture(texture:GLTexture):Void {
+
+ nmeContext.deleteTexture(texture);
+
+ }
+
+
+ public static function depthFunc(func:Int):Void {
+
+ nmeContext.depthFunc(func);
+
+ }
+
+
+ public static function depthMask(flag:Bool):Void {
+
+ nmeContext.depthMask(flag);
+
+ }
+
+
+ public static function depthRange(zNear:Float, zFar:Float):Void {
+
+ nmeContext.depthRange(zNear, zFar);
+
+ }
+
+
+ public static function detachShader(program:GLProgram, shader:GLShader):Void {
+
+ nmeContext.detachShader(program, shader);
+
+ }
+
+
+ public static function disable(cap:Int):Void {
+
+ nmeContext.disable(cap);
+
+ }
+
+
+ public static function disableVertexAttribArray(index:Int):Void {
+
+ nmeContext.disableVertexAttribArray(index);
+
+ }
+
+
+ public static function drawArrays(mode:Int, first:Int, count:Int):Void {
+
+ nmeContext.drawArrays(mode, first, count);
+
+ }
+
+
+ public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void {
+
+ nmeContext.drawElements(mode, count, type, offset);
+
+ }
+
+
+ public static function enable(cap:Int):Void {
+
+ nmeContext.enable(cap);
+
+ }
+
+
+ public static function enableVertexAttribArray(index:Int):Void {
+
+ nmeContext.enableVertexAttribArray(index);
+
+ }
+
+
+ public static function finish():Void {
+
+ nmeContext.finish();
+
+ }
+
+
+ public static function flush():Void {
+
+ nmeContext.flush();
+
+ }
+
+
+ public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void {
+
+ nmeContext.framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+
+ }
+
+
+ public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void {
+
+ nmeContext.framebufferTexture2D(target, attachment, textarget, texture, level);
+
+ }
+
+
+ public static function frontFace(mode:Int):Void {
+
+ nmeContext.frontFace(mode);
+
+ }
+
+
+ public static function generateMipmap(target:Int):Void {
+
+ nmeContext.generateMipmap(target);
+
+ }
+
+
+ public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo {
+
+ return nmeContext.getActiveAttrib(program, index);
+
+ }
+
+
+ public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo {
+
+ return nmeContext.getActiveUniform(program, index);
+
+ }
+
+
+ public static function getAttachedShaders(program:GLProgram):Array {
+
+ return nmeContext.getAttachedShaders(program);
+
+ }
+
+
+ public static function getAttribLocation(program:GLProgram, name:String):Int {
+
+ return nmeContext.getAttribLocation(program, name);
+
+ }
+
+
+ public static function getBufferParameter(target:Int, pname:Int):Dynamic {
+
+ return nmeContext.getBufferParameter(target, pname);
+
+ }
+
+
+ public static function getContextAttributes():GLContextAttributes {
+
+ return nmeContext.getContextAttributes();
+
+ }
+
+
+ public static function getError():Int {
+
+ return nmeContext.getError();
+
+ }
+
+
+ public static function getExtension(name:String):Dynamic {
+
+ // TODO
+
+ return null;
+
+ }
+
+
+ public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic {
+
+ return nmeContext.getFramebufferAttachmentParameter(target, attachment, pname);
+
+ }
+
+
+ public static function getParameter(pname:Int):Dynamic {
+
+ return nmeContext.getParameter(pname);
+
+ }
+
+
+ public static function getProgramInfoLog(program:GLProgram):String {
+
+ return nmeContext.getProgramInfoLog(program);
+
+ }
+
+
+ public static function getProgramParameter(program:GLProgram, pname:Int):Int {
+
+ return nmeContext.getProgramParameter(program, pname);
+
+ }
+
+
+ public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic {
+
+ return nmeContext.getRenderbufferParameter(target, pname);
+
+ }
+
+
+ public static function getShaderInfoLog(shader:GLShader):String {
+
+ return nmeContext.getShaderInfoLog(shader);
+
+ }
+
+
+ public static function getShaderParameter(shader:GLShader, pname:Int):Int {
+
+ return nmeContext.getShaderParameter(shader, pname);
+
+ }
+
+
+ public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat {
+
+ // TODO
+
+ return null;
+ //return nmeContext.getShader
+
+ }
+
+
+ public static function getShaderSource(shader:GLShader):String {
+
+ return nmeContext.getShaderSource(shader);
+
+ }
+
+
+ public static function getSupportedExtensions():Array {
+
+ // TODO
+
+ return null;
+ //return nmeContext.getSuppo
+
+ }
+
+
+ public static function getTexParameter(target:Int, pname:Int):Dynamic {
+
+ return nmeContext.getTexParameter(target, pname);
+
+ }
+
+
+ public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic {
+
+ return nmeContext.getUniform(program, location);
+
+ }
+
+
+ public static function getUniformLocation(program:GLProgram, name:String):GLUniformLocation {
+
+ return nmeContext.getUniformLocation(program, name);
+
+ }
+
+
+ public static function getVertexAttrib(index:Int, pname:Int):Dynamic {
+
+ return nmeContext.getVertexAttrib(index, pname);
+
+ }
+
+
+ public static function getVertexAttribOffset(index:Int, pname:Int):Int {
+
+ return nmeContext.getVertexAttribOffset(index, pname);
+
+ }
+
+
+ public static function hint(target:Int, mode:Int):Void {
+
+ nmeContext.hint(target, mode);
+
+ }
+
+
+ public static function isBuffer(buffer:GLBuffer):Bool {
+
+ return nmeContext.isBuffer(buffer);
+
+ }
+
+
+ // This is non-static
+ // public function isContextLost():Bool { return false; }
+
+
+ public static function isEnabled(cap:Int):Bool {
+
+ return nmeContext.isEnabled(cap);
+
+ }
+
+
+ public static function isFramebuffer(framebuffer:GLFramebuffer):Bool {
+
+ return nmeContext.isFramebuffer(framebuffer);
+
+ }
+
+
+ public static function isProgram(program:GLProgram):Bool {
+
+ return nmeContext.isProgram(program);
+
+ }
+
+
+ public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool {
+
+ return nmeContext.isRenderbuffer(renderbuffer);
+
+ }
+
+
+ public static function isShader(shader:GLShader):Bool {
+
+ return nmeContext.isShader(shader);
+
+ }
+
+
+ public static function isTexture(texture:GLTexture):Bool {
+
+ return nmeContext.isTexture(texture);
+
+ }
+
+
+ public static function lineWidth(width:Float):Void {
+
+ nmeContext.lineWidth(width);
+
+ }
+
+
+ public static function linkProgram(program:GLProgram):Void {
+
+ nmeContext.linkProgram(program);
+
+ }
+
+
+ public static function pixelStorei(pname:Int, param:Int):Void {
+
+ nmeContext.pixelStorei(pname, param);
+
+ }
+
+
+ public static function polygonOffset(factor:Float, units:Float):Void {
+
+ nmeContext.polygonOffset(factor, units);
+
+ }
+
+
+ public static function readPixels(x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void {
+
+ // TODO: pixels? May need setting to work (canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});)
+
+ nmeContext.readPixels(x, y, width, height, format, type, pixels);
+
+ }
+
+
+ public static function renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void {
+
+ nmeContext.renderbufferStorage(target, internalformat, width, height);
+
+ }
+
+
+ public static function sampleCoverage(value:Float, invert:Bool):Void {
+
+ nmeContext.sampleCoverage(value, invert);
+
+ }
+
+
+ public static function scissor(x:Int, y:Int, width:Int, height:Int):Void {
+
+ nmeContext.scissor(x, y, width, height);
+
+ }
+
+
+ public static function shaderSource(shader:GLShader, source:String):Void {
+
+ nmeContext.shaderSource(shader, source);
+
+ }
+
+
+ public static function stencilFunc(func:Int, ref:Int, mask:Int):Void {
+
+ nmeContext.stencilFunc(func, ref, mask);
+
+ }
+
+
+ public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void {
+
+ nmeContext.stencilFuncSeparate(face, func, ref, mask);
+
+ }
+
+
+ public static function stencilMask(mask:Int):Void {
+
+ nmeContext.stencilMask(mask);
+
+ }
+
+
+ public static function stencilMaskSeparate(face:Int, mask:Int):Void {
+
+ nmeContext.stencilMaskSeparate(face, mask);
+
+ }
+
+
+ public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void {
+
+ nmeContext.stencilOp(fail, zfail, zpass);
+
+ }
+
+
+ public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void {
+
+ nmeContext.stencilOpSeparate(face, fail, zfail, zpass);
+
+ }
+
+
+ public static function texImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void {
+
+ nmeContext.texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+
+ }
+
+
+ public static function texParameterf(target:Int, pname:Int, param:Float):Void {
+
+ nmeContext.texParameterf(target, pname, param);
+
+ }
+
+
+ public static function texParameteri(target:Int, pname:Int, param:Int):Void {
+
+ nmeContext.texParameteri(target, pname, param);
+
+ }
+
+
+ public static function texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void {
+
+ nmeContext.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+
+ }
+
+
+ public static function uniform1f(location:GLUniformLocation, x:Float):Void {
+
+ nmeContext.uniform1f(location, x);
+
+ }
+
+
+ public static function uniform1fv(location:GLUniformLocation, x:Float32Array):Void {
+
+ nmeContext.uniform1fv(location, x);
+
+ }
+
+
+ public static function uniform1i(location:GLUniformLocation, x:Int):Void {
+
+ nmeContext.uniform1i(location, x);
+
+ }
+
+
+ public static function uniform1iv(location:GLUniformLocation, v:Int32Array):Void {
+
+ nmeContext.uniform1iv(location, v);
+
+ }
+
+
+ public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void {
+
+ nmeContext.uniform2f(location, x, y);
+
+ }
+
+
+ public static function uniform2fv(location:GLUniformLocation, v:Float32Array):Void {
+
+ nmeContext.uniform2fv(location, v);
+
+ }
+
+
+ public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void {
+
+ nmeContext.uniform2i(location, x, y);
+
+ }
+
+
+ public static function uniform2iv(location:GLUniformLocation, v:Int32Array):Void {
+
+ nmeContext.uniform2iv(location, v);
+
+ }
+
+
+ public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void {
+
+ nmeContext.uniform3f(location, x, y, z);
+
+ }
+
+
+ public static function uniform3fv(location:GLUniformLocation, v:Float32Array):Void {
+
+ nmeContext.uniform3fv(location, v);
+
+ }
+
+
+ public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void {
+
+ nmeContext.uniform3i(location, x, y, z);
+
+ }
+
+
+ public static function uniform3iv(location:GLUniformLocation, v:Int32Array):Void {
+
+ nmeContext.uniform3iv(location, v);
+
+ }
+
+
+ public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void {
+
+ nmeContext.uniform4f(location, x, y, z, w);
+
+ }
+
+
+ public static function uniform4fv(location:GLUniformLocation, v:Float32Array):Void {
+
+ nmeContext.uniform4fv(location, v);
+
+ }
+
+
+ public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void {
+
+ nmeContext.uniform4i(location, x, y, z, w);
+
+ }
+
+
+ public static function uniform4iv(location:GLUniformLocation, v:Int32Array):Void {
+
+ nmeContext.uniform4iv(location, v);
+
+ }
+
+
+ public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void {
+
+ nmeContext.uniformMatrix2fv(location, transpose, v);
+
+ }
+
+
+ public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void {
+
+ nmeContext.uniformMatrix3fv(location, transpose, v);
+
+ }
+
+
+ public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void {
+
+ nmeContext.uniformMatrix4fv(location, transpose, v);
+
+ }
+
+
+ public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void {
+
+ nmeContext.uniformMatrix4fv(location, transpose, new Float32Array(matrix.rawData));
+
+ }
+
+
+ public static function useProgram(program:GLProgram):Void {
+
+ nmeContext.useProgram(program);
+
+ }
+
+
+ public static function validateProgram(program:GLProgram):Void {
+
+ nmeContext.validateProgram(program);
+
+ }
+
+
+ public static function vertexAttrib1f(indx:Int, x:Float):Void {
+
+ nmeContext.vertexAttrib1f(indx, x);
+
+ }
+
+
+ public static function vertexAttrib1fv(indx:Int, values:Float32Array):Void {
+
+ nmeContext.vertexAttrib1fv(indx, values);
+
+ }
+
+
+ public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void {
+
+ nmeContext.vertexAttrib2f(indx, x, y);
+
+ }
+
+
+ public static function vertexAttrib2fv(indx:Int, values:Float32Array):Void {
+
+ nmeContext.vertexAttrib2fv(indx, values);
+
+ }
+
+
+ public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void {
+
+ nmeContext.vertexAttrib3f(indx, x, y, z);
+
+ }
+
+
+ public static function vertexAttrib3fv(indx:Int, values:Float32Array):Void {
+
+ nmeContext.vertexAttrib3fv(indx, values);
+
+ }
+
+
+ public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void {
+
+ nmeContext.vertexAttrib4f(indx, x, y, z, w);
+
+ }
+
+
+ public static function vertexAttrib4fv(indx:Int, values:Float32Array):Void {
+
+ nmeContext.vertexAttrib4fv(indx, values);
+
+ }
+
+
+ public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void {
+
+ nmeContext.vertexAttribPointer(indx, size, type, normalized, stride, offset);
+
+ }
+
+
+ public static function viewport(x:Int, y:Int, width:Int, height:Int):Void {
+
+ nmeContext.viewport(x, y, width, height);
+
+ }
+
+
+
+
+ // Getters & Setters
+
+
+
+
+ private static function get_drawingBufferHeight() { return 640; }
+ private static function get_drawingBufferWidth() { return 960; }
+ private static function get_version():Int { return RenderingContext.VERSION; }
+
+
+
+}
+
+
+typedef ShaderPrecisionFormat = {
+
+ rangeMin : Int,
+ rangeMax : Int,
+ precision : Int,
+
+};
+
+
+#end
\ No newline at end of file
diff --git a/lime/gl/native/GL.hx b/lime/gl/native/GL.hx
new file mode 100644
index 000000000..6e50d8251
--- /dev/null
+++ b/lime/gl/native/GL.hx
@@ -0,0 +1,1303 @@
+package lime.gl.native;
+
+import lime.utils.Libs;
+
+// import flash.display.BitmapData;
+import lime.geometry.Matrix3D;
+// import flash.utils.ByteArray;
+
+import lime.utils.ArrayBuffer;
+import lime.utils.ArrayBufferView;
+import lime.utils.Float32Array;
+import lime.utils.IMemoryRange;
+
+
+class GL {
+
+
+ /* ClearBufferMask */
+ public static inline var DEPTH_BUFFER_BIT = 0x00000100;
+ public static inline var STENCIL_BUFFER_BIT = 0x00000400;
+ public static inline var COLOR_BUFFER_BIT = 0x00004000;
+
+ /* BeginMode */
+ public static inline var POINTS = 0x0000;
+ public static inline var LINES = 0x0001;
+ public static inline var LINE_LOOP = 0x0002;
+ public static inline var LINE_STRIP = 0x0003;
+ public static inline var TRIANGLES = 0x0004;
+ public static inline var TRIANGLE_STRIP = 0x0005;
+ public static inline var TRIANGLE_FAN = 0x0006;
+
+ /* AlphaFunction(not supported in ES20) */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+ /* BlendingFactorDest */
+ public static inline var ZERO = 0;
+ public static inline var ONE = 1;
+ public static inline var SRC_COLOR = 0x0300;
+ public static inline var ONE_MINUS_SRC_COLOR = 0x0301;
+ public static inline var SRC_ALPHA = 0x0302;
+ public static inline var ONE_MINUS_SRC_ALPHA = 0x0303;
+ public static inline var DST_ALPHA = 0x0304;
+ public static inline var ONE_MINUS_DST_ALPHA = 0x0305;
+
+ /* BlendingFactorSrc */
+ /* ZERO */
+ /* ONE */
+ public static inline var DST_COLOR = 0x0306;
+ public static inline var ONE_MINUS_DST_COLOR = 0x0307;
+ public static inline var SRC_ALPHA_SATURATE = 0x0308;
+ /* SRC_ALPHA */
+ /* ONE_MINUS_SRC_ALPHA */
+ /* DST_ALPHA */
+ /* ONE_MINUS_DST_ALPHA */
+ /* BlendEquationSeparate */
+ public static inline var FUNC_ADD = 0x8006;
+ public static inline var BLEND_EQUATION = 0x8009;
+ public static inline var BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */
+ public static inline var BLEND_EQUATION_ALPHA = 0x883D;
+
+ /* BlendSubtract */
+ public static inline var FUNC_SUBTRACT = 0x800A;
+ public static inline var FUNC_REVERSE_SUBTRACT = 0x800B;
+
+ /* Separate Blend Functions */
+ public static inline var BLEND_DST_RGB = 0x80C8;
+ public static inline var BLEND_SRC_RGB = 0x80C9;
+ public static inline var BLEND_DST_ALPHA = 0x80CA;
+ public static inline var BLEND_SRC_ALPHA = 0x80CB;
+ public static inline var CONSTANT_COLOR = 0x8001;
+ public static inline var ONE_MINUS_CONSTANT_COLOR = 0x8002;
+ public static inline var CONSTANT_ALPHA = 0x8003;
+ public static inline var ONE_MINUS_CONSTANT_ALPHA = 0x8004;
+ public static inline var BLEND_COLOR = 0x8005;
+
+ /* GLBuffer Objects */
+ public static inline var ARRAY_BUFFER = 0x8892;
+ public static inline var ELEMENT_ARRAY_BUFFER = 0x8893;
+ public static inline var ARRAY_BUFFER_BINDING = 0x8894;
+ public static inline var ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
+
+ public static inline var STREAM_DRAW = 0x88E0;
+ public static inline var STATIC_DRAW = 0x88E4;
+ public static inline var DYNAMIC_DRAW = 0x88E8;
+
+ public static inline var BUFFER_SIZE = 0x8764;
+ public static inline var BUFFER_USAGE = 0x8765;
+
+ public static inline var CURRENT_VERTEX_ATTRIB = 0x8626;
+
+ /* CullFaceMode */
+ public static inline var FRONT = 0x0404;
+ public static inline var BACK = 0x0405;
+ public static inline var FRONT_AND_BACK = 0x0408;
+
+ /* DepthFunction */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+ /* EnableCap */
+ /* TEXTURE_2D */
+ public static inline var CULL_FACE = 0x0B44;
+ public static inline var BLEND = 0x0BE2;
+ public static inline var DITHER = 0x0BD0;
+ public static inline var STENCIL_TEST = 0x0B90;
+ public static inline var DEPTH_TEST = 0x0B71;
+ public static inline var SCISSOR_TEST = 0x0C11;
+ public static inline var POLYGON_OFFSET_FILL = 0x8037;
+ public static inline var SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
+ public static inline var SAMPLE_COVERAGE = 0x80A0;
+
+ /* ErrorCode */
+ public static inline var NO_ERROR = 0;
+ public static inline var INVALID_ENUM = 0x0500;
+ public static inline var INVALID_VALUE = 0x0501;
+ public static inline var INVALID_OPERATION = 0x0502;
+ public static inline var OUT_OF_MEMORY = 0x0505;
+
+ /* FrontFaceDirection */
+ public static inline var CW = 0x0900;
+ public static inline var CCW = 0x0901;
+
+ /* GetPName */
+ public static inline var LINE_WIDTH = 0x0B21;
+ public static inline var ALIASED_POINT_SIZE_RANGE = 0x846D;
+ public static inline var ALIASED_LINE_WIDTH_RANGE = 0x846E;
+ public static inline var CULL_FACE_MODE = 0x0B45;
+ public static inline var FRONT_FACE = 0x0B46;
+ public static inline var DEPTH_RANGE = 0x0B70;
+ public static inline var DEPTH_WRITEMASK = 0x0B72;
+ public static inline var DEPTH_CLEAR_VALUE = 0x0B73;
+ public static inline var DEPTH_FUNC = 0x0B74;
+ public static inline var STENCIL_CLEAR_VALUE = 0x0B91;
+ public static inline var STENCIL_FUNC = 0x0B92;
+ public static inline var STENCIL_FAIL = 0x0B94;
+ public static inline var STENCIL_PASS_DEPTH_FAIL = 0x0B95;
+ public static inline var STENCIL_PASS_DEPTH_PASS = 0x0B96;
+ public static inline var STENCIL_REF = 0x0B97;
+ public static inline var STENCIL_VALUE_MASK = 0x0B93;
+ public static inline var STENCIL_WRITEMASK = 0x0B98;
+ public static inline var STENCIL_BACK_FUNC = 0x8800;
+ public static inline var STENCIL_BACK_FAIL = 0x8801;
+ public static inline var STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
+ public static inline var STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
+ public static inline var STENCIL_BACK_REF = 0x8CA3;
+ public static inline var STENCIL_BACK_VALUE_MASK = 0x8CA4;
+ public static inline var STENCIL_BACK_WRITEMASK = 0x8CA5;
+ public static inline var VIEWPORT = 0x0BA2;
+ public static inline var SCISSOR_BOX = 0x0C10;
+ /* SCISSOR_TEST */
+ public static inline var COLOR_CLEAR_VALUE = 0x0C22;
+ public static inline var COLOR_WRITEMASK = 0x0C23;
+ public static inline var UNPACK_ALIGNMENT = 0x0CF5;
+ public static inline var PACK_ALIGNMENT = 0x0D05;
+ public static inline var MAX_TEXTURE_SIZE = 0x0D33;
+ public static inline var MAX_VIEWPORT_DIMS = 0x0D3A;
+ public static inline var SUBPIXEL_BITS = 0x0D50;
+ public static inline var RED_BITS = 0x0D52;
+ public static inline var GREEN_BITS = 0x0D53;
+ public static inline var BLUE_BITS = 0x0D54;
+ public static inline var ALPHA_BITS = 0x0D55;
+ public static inline var DEPTH_BITS = 0x0D56;
+ public static inline var STENCIL_BITS = 0x0D57;
+ public static inline var POLYGON_OFFSET_UNITS = 0x2A00;
+ /* POLYGON_OFFSET_FILL */
+ public static inline var POLYGON_OFFSET_FACTOR = 0x8038;
+ public static inline var TEXTURE_BINDING_2D = 0x8069;
+ public static inline var SAMPLE_BUFFERS = 0x80A8;
+ public static inline var SAMPLES = 0x80A9;
+ public static inline var SAMPLE_COVERAGE_VALUE = 0x80AA;
+ public static inline var SAMPLE_COVERAGE_INVERT = 0x80AB;
+
+ /* GetTextureParameter */
+ /* TEXTURE_MAG_FILTER */
+ /* TEXTURE_MIN_FILTER */
+ /* TEXTURE_WRAP_S */
+ /* TEXTURE_WRAP_T */
+ public static inline var COMPRESSED_TEXTURE_FORMATS = 0x86A3;
+
+ /* HintMode */
+ public static inline var DONT_CARE = 0x1100;
+ public static inline var FASTEST = 0x1101;
+ public static inline var NICEST = 0x1102;
+
+ /* HintTarget */
+ public static inline var GENERATE_MIPMAP_HINT = 0x8192;
+
+ /* DataType */
+ public static inline var BYTE = 0x1400;
+ public static inline var UNSIGNED_BYTE = 0x1401;
+ public static inline var SHORT = 0x1402;
+ public static inline var UNSIGNED_SHORT = 0x1403;
+ public static inline var INT = 0x1404;
+ public static inline var UNSIGNED_INT = 0x1405;
+ public static inline var FLOAT = 0x1406;
+
+ /* PixelFormat */
+ public static inline var DEPTH_COMPONENT = 0x1902;
+ public static inline var ALPHA = 0x1906;
+ public static inline var RGB = 0x1907;
+ public static inline var RGBA = 0x1908;
+ public static inline var LUMINANCE = 0x1909;
+ public static inline var LUMINANCE_ALPHA = 0x190A;
+
+ /* PixelType */
+ /* UNSIGNED_BYTE */
+ public static inline var UNSIGNED_SHORT_4_4_4_4 = 0x8033;
+ public static inline var UNSIGNED_SHORT_5_5_5_1 = 0x8034;
+ public static inline var UNSIGNED_SHORT_5_6_5 = 0x8363;
+
+ /* Shaders */
+ public static inline var FRAGMENT_SHADER = 0x8B30;
+ public static inline var VERTEX_SHADER = 0x8B31;
+ public static inline var MAX_VERTEX_ATTRIBS = 0x8869;
+ public static inline var MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
+ public static inline var MAX_VARYING_VECTORS = 0x8DFC;
+ public static inline var MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
+ public static inline var MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
+ public static inline var MAX_TEXTURE_IMAGE_UNITS = 0x8872;
+ public static inline var MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
+ public static inline var SHADER_TYPE = 0x8B4F;
+ public static inline var DELETE_STATUS = 0x8B80;
+ public static inline var LINK_STATUS = 0x8B82;
+ public static inline var VALIDATE_STATUS = 0x8B83;
+ public static inline var ATTACHED_SHADERS = 0x8B85;
+ public static inline var ACTIVE_UNIFORMS = 0x8B86;
+ public static inline var ACTIVE_ATTRIBUTES = 0x8B89;
+ public static inline var SHADING_LANGUAGE_VERSION = 0x8B8C;
+ public static inline var CURRENT_PROGRAM = 0x8B8D;
+
+ /* StencilFunction */
+ public static inline var NEVER = 0x0200;
+ public static inline var LESS = 0x0201;
+ public static inline var EQUAL = 0x0202;
+ public static inline var LEQUAL = 0x0203;
+ public static inline var GREATER = 0x0204;
+ public static inline var NOTEQUAL = 0x0205;
+ public static inline var GEQUAL = 0x0206;
+ public static inline var ALWAYS = 0x0207;
+
+ /* StencilOp */
+ /* ZERO */
+ public static inline var KEEP = 0x1E00;
+ public static inline var REPLACE = 0x1E01;
+ public static inline var INCR = 0x1E02;
+ public static inline var DECR = 0x1E03;
+ public static inline var INVERT = 0x150A;
+ public static inline var INCR_WRAP = 0x8507;
+ public static inline var DECR_WRAP = 0x8508;
+
+ /* StringName */
+ public static inline var VENDOR = 0x1F00;
+ public static inline var RENDERER = 0x1F01;
+ public static inline var VERSION = 0x1F02;
+
+ /* TextureMagFilter */
+ public static inline var NEAREST = 0x2600;
+ public static inline var LINEAR = 0x2601;
+
+ /* TextureMinFilter */
+ /* NEAREST */
+ /* LINEAR */
+ public static inline var NEAREST_MIPMAP_NEAREST = 0x2700;
+ public static inline var LINEAR_MIPMAP_NEAREST = 0x2701;
+ public static inline var NEAREST_MIPMAP_LINEAR = 0x2702;
+ public static inline var LINEAR_MIPMAP_LINEAR = 0x2703;
+
+ /* TextureParameterName */
+ public static inline var TEXTURE_MAG_FILTER = 0x2800;
+ public static inline var TEXTURE_MIN_FILTER = 0x2801;
+ public static inline var TEXTURE_WRAP_S = 0x2802;
+ public static inline var TEXTURE_WRAP_T = 0x2803;
+
+ /* TextureTarget */
+ public static inline var TEXTURE_2D = 0x0DE1;
+ public static inline var TEXTURE = 0x1702;
+
+ public static inline var TEXTURE_CUBE_MAP = 0x8513;
+ public static inline var TEXTURE_BINDING_CUBE_MAP = 0x8514;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
+ public static inline var TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
+ public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
+ public static inline var MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
+
+ /* TextureUnit */
+ public static inline var TEXTURE0 = 0x84C0;
+ public static inline var TEXTURE1 = 0x84C1;
+ public static inline var TEXTURE2 = 0x84C2;
+ public static inline var TEXTURE3 = 0x84C3;
+ public static inline var TEXTURE4 = 0x84C4;
+ public static inline var TEXTURE5 = 0x84C5;
+ public static inline var TEXTURE6 = 0x84C6;
+ public static inline var TEXTURE7 = 0x84C7;
+ public static inline var TEXTURE8 = 0x84C8;
+ public static inline var TEXTURE9 = 0x84C9;
+ public static inline var TEXTURE10 = 0x84CA;
+ public static inline var TEXTURE11 = 0x84CB;
+ public static inline var TEXTURE12 = 0x84CC;
+ public static inline var TEXTURE13 = 0x84CD;
+ public static inline var TEXTURE14 = 0x84CE;
+ public static inline var TEXTURE15 = 0x84CF;
+ public static inline var TEXTURE16 = 0x84D0;
+ public static inline var TEXTURE17 = 0x84D1;
+ public static inline var TEXTURE18 = 0x84D2;
+ public static inline var TEXTURE19 = 0x84D3;
+ public static inline var TEXTURE20 = 0x84D4;
+ public static inline var TEXTURE21 = 0x84D5;
+ public static inline var TEXTURE22 = 0x84D6;
+ public static inline var TEXTURE23 = 0x84D7;
+ public static inline var TEXTURE24 = 0x84D8;
+ public static inline var TEXTURE25 = 0x84D9;
+ public static inline var TEXTURE26 = 0x84DA;
+ public static inline var TEXTURE27 = 0x84DB;
+ public static inline var TEXTURE28 = 0x84DC;
+ public static inline var TEXTURE29 = 0x84DD;
+ public static inline var TEXTURE30 = 0x84DE;
+ public static inline var TEXTURE31 = 0x84DF;
+ public static inline var ACTIVE_TEXTURE = 0x84E0;
+
+ /* TextureWrapMode */
+ public static inline var REPEAT = 0x2901;
+ public static inline var CLAMP_TO_EDGE = 0x812F;
+ public static inline var MIRRORED_REPEAT = 0x8370;
+
+ /* Uniform Types */
+ public static inline var FLOAT_VEC2 = 0x8B50;
+ public static inline var FLOAT_VEC3 = 0x8B51;
+ public static inline var FLOAT_VEC4 = 0x8B52;
+ public static inline var INT_VEC2 = 0x8B53;
+ public static inline var INT_VEC3 = 0x8B54;
+ public static inline var INT_VEC4 = 0x8B55;
+ public static inline var BOOL = 0x8B56;
+ public static inline var BOOL_VEC2 = 0x8B57;
+ public static inline var BOOL_VEC3 = 0x8B58;
+ public static inline var BOOL_VEC4 = 0x8B59;
+ public static inline var FLOAT_MAT2 = 0x8B5A;
+ public static inline var FLOAT_MAT3 = 0x8B5B;
+ public static inline var FLOAT_MAT4 = 0x8B5C;
+ public static inline var SAMPLER_2D = 0x8B5E;
+ public static inline var SAMPLER_CUBE = 0x8B60;
+
+ /* Vertex Arrays */
+ public static inline var VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
+ public static inline var VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
+ public static inline var VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
+ public static inline var VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
+ public static inline var VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
+ public static inline var VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
+ public static inline var VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
+
+ /* Point Size */
+ public static inline var VERTEX_PROGRAM_POINT_SIZE = 0x8642;
+ public static inline var POINT_SPRITE = 0x8861;
+
+ /* GLShader Source */
+ public static inline var COMPILE_STATUS = 0x8B81;
+
+ /* GLShader Precision-Specified Types */
+ public static inline var LOW_FLOAT = 0x8DF0;
+ public static inline var MEDIUM_FLOAT = 0x8DF1;
+ public static inline var HIGH_FLOAT = 0x8DF2;
+ public static inline var LOW_INT = 0x8DF3;
+ public static inline var MEDIUM_INT = 0x8DF4;
+ public static inline var HIGH_INT = 0x8DF5;
+
+ /* GLFramebuffer Object. */
+ public static inline var FRAMEBUFFER = 0x8D40;
+ public static inline var RENDERBUFFER = 0x8D41;
+
+ public static inline var RGBA4 = 0x8056;
+ public static inline var RGB5_A1 = 0x8057;
+ public static inline var RGB565 = 0x8D62;
+ public static inline var DEPTH_COMPONENT16 = 0x81A5;
+ public static inline var STENCIL_INDEX = 0x1901;
+ public static inline var STENCIL_INDEX8 = 0x8D48;
+ public static inline var DEPTH_STENCIL = 0x84F9;
+
+ public static inline var RENDERBUFFER_WIDTH = 0x8D42;
+ public static inline var RENDERBUFFER_HEIGHT = 0x8D43;
+ public static inline var RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
+ public static inline var RENDERBUFFER_RED_SIZE = 0x8D50;
+ public static inline var RENDERBUFFER_GREEN_SIZE = 0x8D51;
+ public static inline var RENDERBUFFER_BLUE_SIZE = 0x8D52;
+ public static inline var RENDERBUFFER_ALPHA_SIZE = 0x8D53;
+ public static inline var RENDERBUFFER_DEPTH_SIZE = 0x8D54;
+ public static inline var RENDERBUFFER_STENCIL_SIZE = 0x8D55;
+
+ public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
+ public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
+ public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
+ public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
+
+ public static inline var COLOR_ATTACHMENT0 = 0x8CE0;
+ public static inline var DEPTH_ATTACHMENT = 0x8D00;
+ public static inline var STENCIL_ATTACHMENT = 0x8D20;
+ public static inline var DEPTH_STENCIL_ATTACHMENT = 0x821A;
+
+ public static inline var NONE = 0;
+
+ public static inline var FRAMEBUFFER_COMPLETE = 0x8CD5;
+ public static inline var FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
+ public static inline var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
+ public static inline var FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
+ public static inline var FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
+
+ public static inline var FRAMEBUFFER_BINDING = 0x8CA6;
+ public static inline var RENDERBUFFER_BINDING = 0x8CA7;
+ public static inline var MAX_RENDERBUFFER_SIZE = 0x84E8;
+
+ public static inline var INVALID_FRAMEBUFFER_OPERATION = 0x0506;
+
+ /* WebGL-specific enums */
+ public static inline var UNPACK_FLIP_Y_WEBGL = 0x9240;
+ public static inline var UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
+ public static inline var CONTEXT_LOST_WEBGL = 0x9242;
+ public static inline var UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
+ public static inline var BROWSER_DEFAULT_WEBGL = 0x9244;
+
+ public static var drawingBufferHeight(get_drawingBufferHeight, null):Int;
+ public static var drawingBufferWidth(get_drawingBufferWidth, null):Int;
+ public static var version(get_version, null):Int;
+
+ public static function activeTexture(texture:Int):Void { nme_gl_active_texture(texture); }
+
+ public static function attachShader(program:GLProgram, shader:GLShader):Void
+ {
+ program.attach(shader);
+ nme_gl_attach_shader(program.id, shader.id);
+ }
+
+ public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void
+ {
+ nme_gl_bind_attrib_location(program.id, index, name);
+ }
+
+ //todo sven
+ // public static function bindBitmapDataTexture(texture:BitmapData):Void
+ // {
+ // nme_gl_bind_bitmap_data_texture(texture.__handle);
+ // }
+
+ public static function bindBuffer(target:Int, buffer:GLBuffer):Void
+ {
+ nme_gl_bind_buffer(target, buffer == null ? 0 : buffer.id);
+ }
+
+ public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void
+ {
+ nme_gl_bind_framebuffer(target, framebuffer == null ? 0 : framebuffer.id);
+ }
+
+ public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void
+ {
+ nme_gl_bind_renderbuffer(target, renderbuffer == null ? 0 : renderbuffer.id);
+ }
+
+ public static function bindTexture(target:Int, texture:GLTexture):Void
+ {
+ nme_gl_bind_texture(target, texture == null ? 0 : texture.id);
+ }
+
+ public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void
+ {
+ nme_gl_blend_color(red, green, blue, alpha);
+ }
+
+ public static function blendEquation(mode:Int):Void
+ {
+ nme_gl_blend_equation(mode);
+ }
+
+ public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void
+ {
+ nme_gl_blend_equation_separate(modeRGB, modeAlpha);
+ }
+
+ public static function blendFunc(sfactor:Int, dfactor:Int):Void
+ {
+ nme_gl_blend_func(sfactor, dfactor);
+ }
+
+ public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void
+ {
+ nme_gl_blend_func_separate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ }
+
+ public static function bufferData(target:Int, data:IMemoryRange, usage:Int):Void
+ {
+ nme_gl_buffer_data(target, data.getByteBuffer(), data.getStart(), data.getLength(), usage);
+ }
+
+ public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange):Void
+ {
+ nme_gl_buffer_sub_data(target, offset, data.getByteBuffer(), data.getStart(), data.getLength());
+ }
+
+ public static function checkFramebufferStatus(target:Int):Int
+ {
+ return nme_gl_check_framebuffer_status(target);
+ }
+
+ public static function clear(mask:Int):Void
+ {
+ nme_gl_clear(mask);
+ }
+
+ public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void
+ {
+ nme_gl_clear_color(red, green, blue, alpha);
+ }
+
+ public static function clearDepth(depth:Float):Void
+ {
+ nme_gl_clear_depth(depth);
+ }
+
+ public static function clearStencil(s:Int):Void
+ {
+ nme_gl_clear_stencil(s);
+ }
+
+ public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void
+ {
+ nme_gl_color_mask(red, green, blue, alpha);
+ }
+
+ public static function compileShader(shader:GLShader):Void
+ {
+ nme_gl_compile_shader(shader.id);
+ }
+
+ public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:IMemoryRange):Void
+ {
+ nme_gl_compressed_tex_image_2d(target, level, internalformat, width, height, border, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart());
+ }
+
+ public static function compressedTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:IMemoryRange):Void
+ {
+ nme_gl_compressed_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart());
+ }
+
+ public static function copyTexImage2D(target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void
+ {
+ nme_gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border);
+ }
+
+ public static function copyTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void
+ {
+ nme_gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height);
+ }
+
+ public static function createBuffer():GLBuffer
+ {
+ return new GLBuffer(version, nme_gl_create_buffer());
+ }
+
+ public static function createFramebuffer():GLFramebuffer
+ {
+ return new GLFramebuffer(version, nme_gl_create_framebuffer());
+ }
+
+ public static function createProgram():GLProgram
+ {
+ return new GLProgram(version, nme_gl_create_program());
+ }
+
+ public static function createRenderbuffer():GLRenderbuffer
+ {
+ return new GLRenderbuffer(version, nme_gl_create_render_buffer());
+ }
+
+ public static function createShader(type:Int):GLShader
+ {
+ return new GLShader(version, nme_gl_create_shader(type));
+ }
+
+ public static function createTexture():GLTexture
+ {
+ return new GLTexture(version, nme_gl_create_texture());
+ }
+
+ public static function cullFace(mode:Int):Void
+ {
+ }
+
+ public static function deleteBuffer(buffer:GLBuffer):Void
+ {
+ nme_gl_delete_buffer(buffer.id);
+ buffer.invalidate();
+ }
+
+ public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void
+ {
+ }
+
+ public static function deleteProgram(program:GLProgram):Void
+ {
+ nme_gl_delete_program(program.id);
+ program.invalidate();
+ }
+
+ public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void
+ {
+ }
+
+ public static function deleteShader(shader:GLShader):Void
+ {
+ nme_gl_delete_shader(shader.id);
+ shader.invalidate();
+ }
+
+ public static function deleteTexture(texture:GLTexture):Void
+ {
+ nme_gl_delete_texture(texture.id);
+ texture.invalidate();
+ }
+
+ public static function depthFunc(func:Int):Void
+ {
+ nme_gl_depth_func(func);
+ }
+
+ public static function depthMask(flag:Bool):Void
+ {
+ nme_gl_depth_mask(flag);
+ }
+
+ public static function depthRange(zNear:Float, zFar:Float):Void
+ {
+ nme_gl_depth_range(zNear, zFar);
+ }
+
+ public static function detachShader(program:GLProgram, shader:GLShader):Void
+ {
+ nme_gl_detach_shader(program.id, shader.id);
+ }
+
+ public static function disable(cap:Int):Void
+ {
+ nme_gl_disable(cap);
+ }
+
+ public static function disableVertexAttribArray(index:Int):Void
+ {
+ nme_gl_disable_vertex_attrib_array(index);
+ }
+
+ public static function drawArrays(mode:Int, first:Int, count:Int):Void
+ {
+ nme_gl_draw_arrays(mode, first, count);
+ }
+
+ public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void
+ {
+ nme_gl_draw_elements(mode, count, type, offset);
+ }
+
+ public static function enable(cap:Int):Void
+ {
+ nme_gl_enable(cap);
+ }
+
+ public static function enableVertexAttribArray(index:Int):Void
+ {
+ nme_gl_enable_vertex_attrib_array(index);
+ }
+
+ public static function finish():Void
+ {
+ nme_gl_finish();
+ }
+
+ public static function flush():Void
+ {
+ nme_gl_flush();
+ }
+
+ public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void
+ {
+ nme_gl_framebuffer_renderbuffer(target, attachment, renderbuffertarget, renderbuffer.id);
+ }
+
+ public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void
+ {
+ nme_gl_framebuffer_texture2D(target, attachment, textarget, texture.id, level);
+ }
+
+ public static function frontFace(mode:Int):Void
+ {
+ nme_gl_front_face(mode);
+ }
+
+ public static function generateMipmap(target:Int):Void
+ {
+ nme_gl_generate_mipmap(target);
+ }
+
+ public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo
+ {
+ return nme_gl_get_active_attrib(program.id, index);
+ }
+
+ public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo
+ {
+ return nme_gl_get_active_uniform(program.id, index);
+ }
+
+ public static function getAttachedShaders(program:GLProgram):Array
+ {
+ return program.getShaders();
+ }
+
+ public static function getAttribLocation(program:GLProgram, name:String):Int
+ {
+ return nme_gl_get_attrib_location(program.id, name);
+ }
+
+ public static function getBufferParameter(target:Int, pname:Int):Dynamic
+ {
+ return nme_gl_get_buffer_paramerter(target, pname);
+ }
+
+ public static function getContextAttributes():GLContextAttributes
+ {
+ var base = nme_gl_get_context_attributes();
+ base.premultipliedAlpha = false;
+ base.preserveDrawingBuffer = false;
+ return base;
+ }
+
+ public static function getError():Int
+ {
+ return nme_gl_get_error();
+ }
+
+ public static function getExtension(name:String):Dynamic
+ {
+ // Hmmm
+ return null;
+ }
+
+ public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic
+ {
+ return nme_gl_get_framebuffer_attachment_parameter(target, attachment, pname);
+ }
+
+ public static function getParameter(pname:Int):Dynamic
+ {
+ return nme_gl_get_parameter(pname);
+ }
+
+ public static function getProgramInfoLog(program:GLProgram):String
+ {
+ return nme_gl_get_program_info_log(program.id);
+ }
+
+ public static function getProgramParameter(program:GLProgram, pname:Int):Int
+ {
+ return nme_gl_get_program_parameter(program.id, pname);
+ }
+
+ public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic
+ {
+ return nme_gl_get_render_buffer_parameter(target, pname);
+ }
+
+ public static function getShaderInfoLog(shader:GLShader):String
+ {
+ return nme_gl_get_shader_info_log(shader.id);
+ }
+
+ public static function getShaderParameter(shader:GLShader, pname:Int):Int
+ {
+ return nme_gl_get_shader_parameter(shader.id, pname);
+ }
+
+ public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat
+ {
+ return nme_gl_get_shader_precision_format(shadertype, precisiontype);
+ }
+
+ public static function getShaderSource(shader:GLShader):String
+ {
+ return nme_gl_get_shader_source(shader.id);
+ }
+
+ public static function getSupportedExtensions():Array
+ {
+ var result = new Array();
+ nme_gl_get_supported_extensions(result);
+ return result;
+ }
+
+ public static function getTexParameter(target:Int, pname:Int):Dynamic
+ {
+ return nme_gl_get_tex_parameter(target, pname);
+ }
+
+ public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic
+ {
+ return nme_gl_get_uniform(program.id, location);
+ }
+
+ public static function getUniformLocation(program:GLProgram, name:String):Dynamic
+ {
+ return nme_gl_get_uniform_location(program.id, name);
+ }
+
+ public static function getVertexAttrib(index:Int, pname:Int):Dynamic
+ {
+ return nme_gl_get_vertex_attrib(index, pname);
+ }
+
+ public static function getVertexAttribOffset(index:Int, pname:Int):Int
+ {
+ return nme_gl_get_vertex_attrib_offset(index, pname);
+ }
+
+ public static function hint(target:Int, mode:Int):Void
+ {
+ nme_gl_hint(target, mode);
+ }
+
+ public static function isBuffer(buffer:GLBuffer):Bool
+ {
+ return buffer != null && buffer.id > 0 && nme_gl_is_buffer(buffer.id);
+ }
+
+ // This is non-static
+ // public function isContextLost():Bool { return false; }
+ public static function isEnabled(cap:Int):Bool
+ {
+ return nme_gl_is_enabled(cap);
+ }
+
+ public static function isFramebuffer(framebuffer:GLFramebuffer):Bool
+ {
+ return framebuffer != null && framebuffer.id > 0 && nme_gl_is_framebuffer(framebuffer.id);
+ }
+
+ public static function isProgram(program:GLProgram):Bool
+ {
+ return program != null && program.id > 0 && nme_gl_is_program(program.id);
+ }
+
+ public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool
+ {
+ return renderbuffer != null && renderbuffer.id > 0 && nme_gl_is_renderbuffer(renderbuffer.id);
+ }
+
+ public static function isShader(shader:GLShader):Bool
+ {
+ return shader != null && shader.id > 0 && nme_gl_is_shader(shader.id);
+ }
+
+ public static function isTexture(texture:GLTexture):Bool
+ {
+ return texture != null && texture.id > 0 && nme_gl_is_texture(texture.id);
+ }
+
+ public static function lineWidth(width:Float):Void
+ {
+ nme_gl_line_width(width);
+ }
+
+ public static function linkProgram(program:GLProgram):Void
+ {
+ nme_gl_link_program(program.id);
+ }
+
+ private static function load(inName:String, inArgCount:Int):Dynamic
+ {
+ try
+ {
+ return Libs.load("nme", inName, inArgCount);
+
+ } catch(e:Dynamic)
+ {
+ trace(e);
+ return null;
+ }
+ }
+
+ public static function pixelStorei(pname:Int, param:Int):Void
+ {
+ nme_gl_pixel_storei(pname, param);
+ }
+
+ public static function polygonOffset(factor:Float, units:Float):Void
+ {
+ nme_gl_polygon_offset(factor, units);
+ }
+
+ //todo sven
+ // public static function readPixels(x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ByteArray):Void
+ // {
+ // }
+
+ public static function renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void
+ {
+ nme_gl_renderbuffer_storage(target, internalformat, width, height);
+ }
+
+ public static function sampleCoverage(value:Float, invert:Bool):Void
+ {
+ nme_gl_sample_coverage(value, invert);
+ }
+
+ public static function scissor(x:Int, y:Int, width:Int, height:Int):Void
+ {
+ nme_gl_scissor(x, y, width, height);
+ }
+
+ public static function shaderSource(shader:GLShader, source:String):Void
+ {
+ nme_gl_shader_source(shader.id, source);
+ }
+
+ public static function stencilFunc(func:Int, ref:Int, mask:Int):Void
+ {
+ nme_gl_stencil_func(func, ref, mask);
+ }
+
+ public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void
+ {
+ nme_gl_stencil_func_separate(face, func, ref, mask);
+ }
+
+ public static function stencilMask(mask:Int):Void
+ {
+ nme_gl_stencil_mask(mask);
+ }
+
+ public static function stencilMaskSeparate(face:Int, mask:Int):Void
+ {
+ nme_gl_stencil_mask_separate(face, mask);
+ }
+
+ public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void
+ {
+ nme_gl_stencil_op(fail, zfail, zpass);
+ }
+
+ public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void
+ {
+ nme_gl_stencil_op_separate(face, fail, zfail, zpass);
+ }
+
+ public static function texImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
+ {
+ nme_gl_tex_image_2d(target, level, internalformat, width, height, border, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart());
+ }
+
+ public static function texParameterf(target:Int, pname:Int, param:Float):Void
+ {
+ nme_gl_tex_parameterf(target, pname, param);
+ }
+
+ public static function texParameteri(target:Int, pname:Int, param:Int):Void
+ {
+ nme_gl_tex_parameteri(target, pname, param);
+ }
+
+ public static function texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
+ {
+ nme_gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart());
+ }
+
+ public static function uniform1f(location:GLUniformLocation, x:Float):Void
+ {
+ nme_gl_uniform1f(location, x);
+ }
+
+ public static function uniform1fv(location:GLUniformLocation, x:Array):Void
+ {
+ nme_gl_uniform1fv(location, x);
+ }
+
+ public static function uniform1i(location:GLUniformLocation, x:Int):Void
+ {
+ nme_gl_uniform1i(location, x);
+ }
+
+ public static function uniform1iv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform1iv(location, v);
+ }
+
+ public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void
+ {
+ nme_gl_uniform2f(location, x, y);
+ }
+
+ public static function uniform2fv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform2fv(location, v);
+ }
+
+ public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void
+ {
+ nme_gl_uniform2i(location, x, y);
+ }
+
+ public static function uniform2iv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform2iv(location, v);
+ }
+
+ public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void
+ {
+ nme_gl_uniform3f(location, x, y, z);
+ }
+
+ public static function uniform3fv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform3fv(location, v);
+ }
+
+ public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void
+ {
+ nme_gl_uniform3i(location, x, y, z);
+ }
+
+ public static function uniform3iv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform3iv(location, v);
+ }
+
+ public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void
+ {
+ nme_gl_uniform4f(location, x, y, z, w);
+ }
+
+ public static function uniform4fv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform4fv(location, v);
+ }
+
+ public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void
+ {
+ nme_gl_uniform4i(location, x, y, z, w);
+ }
+
+ public static function uniform4iv(location:GLUniformLocation, v:Array):Void
+ {
+ nme_gl_uniform4iv(location, v);
+ }
+
+ public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
+ {
+ nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 2);
+ }
+
+ public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
+ {
+ nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 3);
+ }
+
+ public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void
+ {
+ nme_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 4);
+ }
+
+ public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void
+ {
+ nme_gl_uniform_matrix(location, transpose, Float32Array.fromMatrix(matrix).getByteBuffer() , 4);
+ }
+
+ public static function useProgram(program:GLProgram):Void
+ {
+ nme_gl_use_program(program == null ? 0 : program.id);
+ }
+
+ public static function validateProgram(program:GLProgram):Void
+ {
+ nme_gl_validate_program(program.id);
+ }
+
+ public static function vertexAttrib1f(indx:Int, x:Float):Void
+ {
+ nme_gl_vertex_attrib1f(indx, x);
+ }
+
+ public static function vertexAttrib1fv(indx:Int, values:Array):Void
+ {
+ nme_gl_vertex_attrib1fv(indx, values);
+ }
+
+ public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void
+ {
+ nme_gl_vertex_attrib2f(indx, x, y);
+ }
+
+ public static function vertexAttrib2fv(indx:Int, values:Array):Void
+ {
+ nme_gl_vertex_attrib2fv(indx, values);
+ }
+
+ public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void
+ {
+ nme_gl_vertex_attrib3f(indx, x, y, z);
+ }
+
+ public static function vertexAttrib3fv(indx:Int, values:Array):Void
+ {
+ nme_gl_vertex_attrib3fv(indx, values);
+ }
+
+ public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void
+ {
+ nme_gl_vertex_attrib4f(indx, x, y, z, w);
+ }
+
+ public static function vertexAttrib4fv(indx:Int, values:Array):Void
+ {
+ nme_gl_vertex_attrib4fv(indx, values);
+ }
+
+ public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void
+ {
+ nme_gl_vertex_attrib_pointer(indx, size, type, normalized, stride, offset);
+ }
+
+ public static function viewport(x:Int, y:Int, width:Int, height:Int):Void
+ {
+ nme_gl_viewport(x, y, width, height);
+ }
+
+
+
+
+ // Getters & Setters
+
+
+
+
+ private static function get_drawingBufferHeight() { return 640; }//Lib.current.stage.stageHeight; }
+ private static function get_drawingBufferWidth() { return 960; } //Lib.current.stage.stageWidth; }
+ private static function get_version():Int { return nme_gl_version(); }
+
+
+
+
+ // Native Methods
+
+
+
+
+ private static var nme_gl_active_texture = load("nme_gl_active_texture", 1);
+ private static var nme_gl_attach_shader = load("nme_gl_attach_shader", 2);
+ private static var nme_gl_bind_attrib_location = load("nme_gl_bind_attrib_location", 3);
+ private static var nme_gl_bind_bitmap_data_texture = load("nme_gl_bind_bitmap_data_texture", 1);
+ private static var nme_gl_bind_buffer = load("nme_gl_bind_buffer", 2);
+ private static var nme_gl_bind_framebuffer = load("nme_gl_bind_framebuffer", 2);
+ private static var nme_gl_bind_renderbuffer = load("nme_gl_bind_renderbuffer", 2);
+ private static var nme_gl_bind_texture = load("nme_gl_bind_texture", 2);
+ private static var nme_gl_blend_color = load("nme_gl_blend_color", 4);
+ private static var nme_gl_blend_equation = load("nme_gl_blend_equation", 1);
+ private static var nme_gl_blend_equation_separate = load("nme_gl_blend_equation_separate", 2);
+ private static var nme_gl_blend_func = load("nme_gl_blend_func", 2);
+ private static var nme_gl_blend_func_separate = load("nme_gl_blend_func_separate", 4);
+ private static var nme_gl_buffer_data = load("nme_gl_buffer_data", 5);
+ private static var nme_gl_buffer_sub_data = load("nme_gl_buffer_sub_data", 5);
+ private static var nme_gl_check_framebuffer_status = load("nme_gl_check_framebuffer_status", 1);
+ private static var nme_gl_clear = load("nme_gl_clear", 1);
+ private static var nme_gl_clear_color = load("nme_gl_clear_color", 4);
+ private static var nme_gl_clear_depth = load("nme_gl_clear_depth", 1);
+ private static var nme_gl_clear_stencil = load("nme_gl_clear_stencil", 1);
+ private static var nme_gl_color_mask = load("nme_gl_color_mask", 4);
+ private static var nme_gl_compile_shader = load("nme_gl_compile_shader", 1);
+ private static var nme_gl_compressed_tex_image_2d = load("nme_gl_compressed_tex_image_2d", -1);
+ private static var nme_gl_compressed_tex_sub_image_2d = load("nme_gl_compressed_tex_sub_image_2d", -1);
+ private static var nme_gl_copy_tex_image_2d = load("nme_gl_copy_tex_image_2d", -1);
+ private static var nme_gl_copy_tex_sub_image_2d = load("nme_gl_copy_tex_sub_image_2d", -1);
+ private static var nme_gl_create_buffer = load("nme_gl_create_buffer", 0);
+ private static var nme_gl_create_framebuffer = load("nme_gl_create_framebuffer", 0);
+ private static var nme_gl_create_program = load("nme_gl_create_program", 0);
+ private static var nme_gl_create_render_buffer = load("nme_gl_create_render_buffer", 0);
+ private static var nme_gl_create_shader = load("nme_gl_create_shader", 1);
+ private static var nme_gl_create_texture = load("nme_gl_create_texture", 0);
+ private static var nme_gl_delete_buffer = load("nme_gl_delete_buffer", 1);
+ private static var nme_gl_delete_program = load("nme_gl_delete_program", 1);
+ private static var nme_gl_delete_shader = load("nme_gl_delete_shader", 1);
+ private static var nme_gl_delete_texture = load("nme_gl_delete_texture", 1);
+ private static var nme_gl_depth_func = load("nme_gl_depth_func", 1);
+ private static var nme_gl_depth_mask = load("nme_gl_depth_mask", 1);
+ private static var nme_gl_depth_range = load("nme_gl_depth_range", 2);
+ private static var nme_gl_detach_shader = load("nme_gl_detach_shader", 2);
+ private static var nme_gl_disable = load("nme_gl_disable", 1);
+ private static var nme_gl_disable_vertex_attrib_array = load("nme_gl_disable_vertex_attrib_array", 1);
+ private static var nme_gl_draw_arrays = load("nme_gl_draw_arrays", 3);
+ private static var nme_gl_draw_elements = load("nme_gl_draw_elements", 4);
+ private static var nme_gl_enable = load("nme_gl_enable", 1);
+ private static var nme_gl_enable_vertex_attrib_array = load("nme_gl_enable_vertex_attrib_array", 1);
+ private static var nme_gl_finish = load("nme_gl_finish", 0);
+ private static var nme_gl_flush = load("nme_gl_flush", 0);
+ private static var nme_gl_framebuffer_renderbuffer = load("nme_gl_framebuffer_renderbuffer", 4);
+ private static var nme_gl_framebuffer_texture2D = load("nme_gl_framebuffer_texture2D", 5);
+ private static var nme_gl_front_face = load("nme_gl_front_face", 1);
+ private static var nme_gl_generate_mipmap = load("nme_gl_generate_mipmap", 1);
+ private static var nme_gl_get_active_attrib = load("nme_gl_get_active_attrib", 2);
+ private static var nme_gl_get_active_uniform = load("nme_gl_get_active_uniform", 2);
+ private static var nme_gl_get_attrib_location = load("nme_gl_get_attrib_location", 2);
+ private static var nme_gl_get_buffer_paramerter = load("nme_gl_get_buffer_paramerter", 2);
+ private static var nme_gl_get_context_attributes = load("nme_gl_get_context_attributes", 0);
+ private static var nme_gl_get_error = load("nme_gl_get_error", 0);
+ private static var nme_gl_get_framebuffer_attachment_parameter = load("nme_gl_get_framebuffer_attachment_parameter", 3);
+ private static var nme_gl_get_parameter = load("nme_gl_get_parameter", 1);
+ private static var nme_gl_get_program_info_log = load("nme_gl_get_program_info_log", 1);
+ private static var nme_gl_get_program_parameter = load("nme_gl_get_program_parameter", 2);
+ private static var nme_gl_get_render_buffer_parameter = load("nme_gl_get_render_buffer_parameter", 2);
+ private static var nme_gl_get_shader_info_log = load("nme_gl_get_shader_info_log", 1);
+ private static var nme_gl_get_shader_parameter = load("nme_gl_get_shader_parameter", 2);
+ private static var nme_gl_get_shader_precision_format = load("nme_gl_get_shader_precision_format", 2);
+ private static var nme_gl_get_shader_source = load("nme_gl_get_shader_source", 1);
+ private static var nme_gl_get_supported_extensions = load("nme_gl_get_supported_extensions", 1);
+ private static var nme_gl_get_tex_parameter = load("nme_gl_get_tex_parameter", 2);
+ private static var nme_gl_get_uniform = load("nme_gl_get_uniform", 2);
+ private static var nme_gl_get_uniform_location = load("nme_gl_get_uniform_location", 2);
+ private static var nme_gl_get_vertex_attrib = load("nme_gl_get_vertex_attrib", 2);
+ private static var nme_gl_get_vertex_attrib_offset = load("nme_gl_get_vertex_attrib_offset", 2);
+ private static var nme_gl_hint = load("nme_gl_hint", 2);
+ private static var nme_gl_is_buffer = load("nme_gl_is_buffer", 1);
+ private static var nme_gl_is_enabled = load("nme_gl_is_enabled", 1);
+ private static var nme_gl_is_framebuffer = load("nme_gl_is_framebuffer", 1);
+ private static var nme_gl_is_program = load("nme_gl_is_program", 1);
+ private static var nme_gl_is_renderbuffer = load("nme_gl_is_renderbuffer", 1);
+ private static var nme_gl_is_shader = load("nme_gl_is_shader", 1);
+ private static var nme_gl_is_texture = load("nme_gl_is_texture", 1);
+ private static var nme_gl_line_width = load("nme_gl_line_width", 1);
+ private static var nme_gl_link_program = load("nme_gl_link_program", 1);
+ private static var nme_gl_pixel_storei = load("nme_gl_pixel_storei", 2);
+ private static var nme_gl_polygon_offset = load("nme_gl_polygon_offset", 2);
+ private static var nme_gl_renderbuffer_storage = load("nme_gl_renderbuffer_storage", 4);
+ private static var nme_gl_sample_coverage = load("nme_gl_sample_coverage", 2);
+ private static var nme_gl_scissor = load("nme_gl_scissor", 4);
+ private static var nme_gl_shader_source = load("nme_gl_shader_source", 2);
+ private static var nme_gl_stencil_func = load("nme_gl_stencil_func", 3);
+ private static var nme_gl_stencil_func_separate = load("nme_gl_stencil_func_separate", 4);
+ private static var nme_gl_stencil_mask = load("nme_gl_stencil_mask", 1);
+ private static var nme_gl_stencil_mask_separate = load("nme_gl_stencil_mask_separate", 2);
+ private static var nme_gl_stencil_op = load("nme_gl_stencil_op", 3);
+ private static var nme_gl_stencil_op_separate = load("nme_gl_stencil_op_separate", 4);
+ private static var nme_gl_tex_image_2d = load("nme_gl_tex_image_2d", -1);
+ private static var nme_gl_tex_parameterf = load("nme_gl_tex_parameterf", 3);
+ private static var nme_gl_tex_parameteri = load("nme_gl_tex_parameteri", 3);
+ private static var nme_gl_tex_sub_image_2d = load("nme_gl_tex_sub_image_2d", -1);
+ private static var nme_gl_uniform1f = load("nme_gl_uniform1f", 2);
+ private static var nme_gl_uniform1fv = load("nme_gl_uniform1fv", 2);
+ private static var nme_gl_uniform1i = load("nme_gl_uniform1i", 2);
+ private static var nme_gl_uniform1iv = load("nme_gl_uniform1iv", 2);
+ private static var nme_gl_uniform2f = load("nme_gl_uniform2f", 3);
+ private static var nme_gl_uniform2fv = load("nme_gl_uniform2fv", 2);
+ private static var nme_gl_uniform2i = load("nme_gl_uniform2i", 3);
+ private static var nme_gl_uniform2iv = load("nme_gl_uniform2iv", 2);
+ private static var nme_gl_uniform3f = load("nme_gl_uniform3f", 4);
+ private static var nme_gl_uniform3fv = load("nme_gl_uniform3fv", 2);
+ private static var nme_gl_uniform3i = load("nme_gl_uniform3i", 4);
+ private static var nme_gl_uniform3iv = load("nme_gl_uniform3iv", 2);
+ private static var nme_gl_uniform4f = load("nme_gl_uniform4f", 5);
+ private static var nme_gl_uniform4fv = load("nme_gl_uniform4fv", 2);
+ private static var nme_gl_uniform4i = load("nme_gl_uniform4i", 5);
+ private static var nme_gl_uniform4iv = load("nme_gl_uniform4iv", 2);
+ private static var nme_gl_uniform_matrix = load("nme_gl_uniform_matrix", 4);
+ private static var nme_gl_use_program = load("nme_gl_use_program", 1);
+ private static var nme_gl_validate_program = load("nme_gl_validate_program", 1);
+ private static var nme_gl_version = load("nme_gl_version", 0);
+ private static var nme_gl_vertex_attrib1f = load("nme_gl_vertex_attrib1f", 2);
+ private static var nme_gl_vertex_attrib1fv = load("nme_gl_vertex_attrib1fv", 2);
+ private static var nme_gl_vertex_attrib2f = load("nme_gl_vertex_attrib2f", 3);
+ private static var nme_gl_vertex_attrib2fv = load("nme_gl_vertex_attrib2fv", 2);
+ private static var nme_gl_vertex_attrib3f = load("nme_gl_vertex_attrib3f", 4);
+ private static var nme_gl_vertex_attrib3fv = load("nme_gl_vertex_attrib3fv", 2);
+ private static var nme_gl_vertex_attrib4f = load("nme_gl_vertex_attrib4f", 5);
+ private static var nme_gl_vertex_attrib4fv = load("nme_gl_vertex_attrib4fv", 2);
+ private static var nme_gl_vertex_attrib_pointer = load("nme_gl_vertex_attrib_pointer", -1);
+ private static var nme_gl_viewport = load("nme_gl_viewport", 4);
+
+
+}
+
+
+typedef ShaderPrecisionFormat =
+{
+ rangeMin : Int,
+ rangeMax : Int,
+ precision : Int,
+
+};
\ No newline at end of file
diff --git a/lime/utils/ArrayBufferView.hx b/lime/utils/ArrayBufferView.hx
index 7c8086045..c3f9606f6 100644
--- a/lime/utils/ArrayBufferView.hx
+++ b/lime/utils/ArrayBufferView.hx
@@ -1,194 +1,200 @@
package lime.utils;
+#if lime_html5
-import lime.utils.ByteArray;
+ typedef ArrayBufferView = js.html.ArrayBufferView;
-#if cpp
-import haxe.io.BytesData;
-#end
+#end //lime_html5
+
+#if lime_native
+
+ import lime.utils.ByteArray;
+
+ #if cpp
+ import haxe.io.BytesData;
+ #end
-class ArrayBufferView implements IMemoryRange {
-
-
- public var buffer (default, null):ByteArray;
- public var byteOffset (default, null):Int;
- public var byteLength (default, null):Int;
-
- private static var invalidDataIndex = "Invalid data index";
- #if cpp
- private var bytes:BytesData;
- #end
-
-
- private function new (lengthOrBuffer:Dynamic, byteOffset:Int = 0, length:Null = null) {
-
- if (Std.is (lengthOrBuffer, Int)) {
+ class ArrayBufferView implements IMemoryRange {
- byteLength = Std.int (lengthOrBuffer);
- this.byteOffset = 0;
- buffer = new ArrayBuffer (Std.int (lengthOrBuffer));
+ public var buffer (default, null):ByteArray;
+ public var byteOffset (default, null):Int;
+ public var byteLength (default, null):Int;
- } else {
+ private static var invalidDataIndex = "Invalid data index";
+ #if cpp
+ private var bytes:BytesData;
+ #end
- buffer = lengthOrBuffer;
- if (buffer == null) {
+ private function new (lengthOrBuffer:Dynamic, byteOffset:Int = 0, length:Null = null) {
- throw ("Invalid input buffer");
-
- }
-
- this.byteOffset = byteOffset;
-
- if (byteOffset > buffer.length) {
-
- throw ("Invalid starting position");
-
- }
-
- if (length == null) {
-
- byteLength = buffer.length - byteOffset;
-
- } else {
-
- byteLength = length;
-
- if (byteLength + byteOffset > buffer.length) {
+ if (Std.is (lengthOrBuffer, Int)) {
- throw ("Invalid buffer length");
+ byteLength = Std.int (lengthOrBuffer);
+ this.byteOffset = 0;
+ buffer = new ArrayBuffer (Std.int (lengthOrBuffer));
+
+ } else {
+
+ buffer = lengthOrBuffer;
+
+ if (buffer == null) {
+
+ throw ("Invalid input buffer");
+
+ }
+
+ this.byteOffset = byteOffset;
+
+ if (byteOffset > buffer.length) {
+
+ throw ("Invalid starting position");
+
+ }
+
+ if (length == null) {
+
+ byteLength = buffer.length - byteOffset;
+
+ } else {
+
+ byteLength = length;
+
+ if (byteLength + byteOffset > buffer.length) {
+
+ throw ("Invalid buffer length");
+
+ }
+
+ }
}
+ buffer.bigEndian = false;
+
+ #if cpp
+ bytes = buffer.getData ();
+ #end
+
}
+
+ public function getByteBuffer ():ByteArray {
+
+ return buffer;
+
+ }
+
+
+ inline public function getFloat32 (position:Int):Float {
+
+ #if cpp
+ untyped return __global__.__hxcpp_memory_get_float (bytes, position + byteOffset);
+ #else
+ buffer.position = position + byteOffset;
+ return buffer.readFloat ();
+ #end
+
+ }
+
+
+ inline public function getInt16 (position:Int):Int {
+
+ #if cpp
+ untyped return __global__.__hxcpp_memory_get_i16 (bytes, position + byteOffset);
+ #else
+ buffer.position = position + byteOffset;
+ return buffer.readShort ();
+ #end
+
+ }
+
+
+ inline public function getInt32 (position:Int):Int {
+
+ #if cpp
+ untyped return __global__.__hxcpp_memory_get_i32 (bytes, position + byteOffset);
+ #else
+ buffer.position = position + byteOffset;
+ return buffer.readInt ();
+ #end
+
+ }
+
+
+ public function getLength ():Int {
+
+ return byteLength;
+
+ }
+
+
+ public function getStart ():Int {
+
+ return byteOffset;
+
+ }
+
+
+ inline public function getUInt8 (position:Int):Int {
+
+ #if cpp
+ untyped return __global__.__hxcpp_memory_get_byte (bytes, position + byteOffset);
+ #else
+ buffer.position = position + byteOffset;
+ return buffer.readByte ();
+ #end
+
+ }
+
+
+ inline public function setFloat32 (position:Int, value:Float):Void {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_float (bytes, position + byteOffset, value);
+ #else
+ buffer.position = position + byteOffset;
+ buffer.writeFloat (value);
+ #end
+
+ }
+
+
+ inline public function setInt16 (position:Int, value:Int):Void {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_i16 (bytes, position + byteOffset, value);
+ #else
+ buffer.position = position + byteOffset;
+ buffer.writeShort (Std.int (value));
+ #end
+
+ }
+
+
+ inline public function setInt32 (position:Int, value:Int):Void {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_i32 (bytes, position + byteOffset, value);
+ #else
+ buffer.position = position + byteOffset;
+ buffer.writeInt (Std.int (value));
+ #end
+
+ }
+
+
+ inline public function setUInt8 (position:Int, value:Int):Void {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_byte (bytes, position + byteOffset, value);
+ #else
+ buffer.position = position + byteOffset;
+ buffer.writeByte (value);
+ #end
+
+ }
}
-
- buffer.bigEndian = false;
-
- #if cpp
- bytes = buffer.getData ();
- #end
-
- }
-
-
- public function getByteBuffer ():ByteArray {
-
- return buffer;
-
- }
-
-
- inline public function getFloat32 (position:Int):Float {
-
- #if cpp
- untyped return __global__.__hxcpp_memory_get_float (bytes, position + byteOffset);
- #else
- buffer.position = position + byteOffset;
- return buffer.readFloat ();
- #end
-
- }
-
-
- inline public function getInt16 (position:Int):Int {
-
- #if cpp
- untyped return __global__.__hxcpp_memory_get_i16 (bytes, position + byteOffset);
- #else
- buffer.position = position + byteOffset;
- return buffer.readShort ();
- #end
-
- }
-
-
- inline public function getInt32 (position:Int):Int {
-
- #if cpp
- untyped return __global__.__hxcpp_memory_get_i32 (bytes, position + byteOffset);
- #else
- buffer.position = position + byteOffset;
- return buffer.readInt ();
- #end
-
- }
-
-
- public function getLength ():Int {
-
- return byteLength;
-
- }
-
-
- public function getStart ():Int {
-
- return byteOffset;
-
- }
-
-
- inline public function getUInt8 (position:Int):Int {
-
- #if cpp
- untyped return __global__.__hxcpp_memory_get_byte (bytes, position + byteOffset);
- #else
- buffer.position = position + byteOffset;
- return buffer.readByte ();
- #end
-
- }
-
-
- inline public function setFloat32 (position:Int, value:Float):Void {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_float (bytes, position + byteOffset, value);
- #else
- buffer.position = position + byteOffset;
- buffer.writeFloat (value);
- #end
-
- }
-
-
- inline public function setInt16 (position:Int, value:Int):Void {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_i16 (bytes, position + byteOffset, value);
- #else
- buffer.position = position + byteOffset;
- buffer.writeShort (Std.int (value));
- #end
-
- }
-
-
- inline public function setInt32 (position:Int, value:Int):Void {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_i32 (bytes, position + byteOffset, value);
- #else
- buffer.position = position + byteOffset;
- buffer.writeInt (Std.int (value));
- #end
-
- }
-
-
- inline public function setUInt8 (position:Int, value:Int):Void {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_byte (bytes, position + byteOffset, value);
- #else
- buffer.position = position + byteOffset;
- buffer.writeByte (value);
- #end
-
- }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
\ No newline at end of file
diff --git a/lime/utils/Assets.hx b/lime/utils/Assets.hx
index c59e1b91b..8424fdbac 100644
--- a/lime/utils/Assets.hx
+++ b/lime/utils/Assets.hx
@@ -1,4 +1,6 @@
package lime.utils;
+
+
#if !macro
@@ -211,31 +213,33 @@ class Assets {
#if flash
- return Type.createInstance(AssetData.className.get(id), []);
+ return Type.createInstance(AssetData.className.get(id), []);
#elseif js
- var bytes:ByteArray = null;
- var data = ApplicationMain.urlLoaders.get(AssetData.path.get(id)).data;
- if (Std.is(data, String)) {
- var bytes = new ByteArray();
- bytes.writeUTFBytes(data);
- } else if (Std.is(data, ByteArray)) {
- bytes = cast data;
- } else {
- bytes = null;
- }
+ #if !lime_html5
+ var bytes:ByteArray = null;
+ var data = ApplicationMain.urlLoaders.get(AssetData.path.get(id)).data;
+ if (Std.is(data, String)) {
+ var bytes = new ByteArray();
+ bytes.writeUTFBytes(data);
+ } else if (Std.is(data, ByteArray)) {
+ bytes = cast data;
+ } else {
+ bytes = null;
+ }
- if (bytes != null) {
- bytes.position = 0;
- return bytes;
- } else {
- return null;
- }
+ if (bytes != null) {
+ bytes.position = 0;
+ return bytes;
+ } else {
+ return null;
+ }
+ #end //lime_html5
- #else
+ #else //js or flash
- return ByteArray.readFile(AssetData.path.get(id));
+ return ByteArray.readFile(AssetData.path.get(id));
#end
diff --git a/lime/utils/ByteArray.hx b/lime/utils/ByteArray.hx
index c9fad2a6c..ccf6a4946 100644
--- a/lime/utils/ByteArray.hx
+++ b/lime/utils/ByteArray.hx
@@ -1,5 +1,6 @@
package lime.utils;
-#if (cpp || neko)
+// #if (cpp || neko)
+#if (lime_native || lime_html5)
import lime.utils.Libs;
@@ -9,16 +10,20 @@ import haxe.io.BytesData;
import lime.utils.CompressionAlgorithm;
import lime.utils.IDataInput;
-#if neko
-import neko.Lib;
-import neko.zip.Compress;
-import neko.zip.Uncompress;
-import neko.zip.Flush;
-#else
-import cpp.Lib;
-import cpp.zip.Compress;
-import cpp.zip.Uncompress;
-import cpp.zip.Flush;
+#if !lime_html5
+
+ #if neko
+ import neko.Lib;
+ import neko.zip.Compress;
+ import neko.zip.Uncompress;
+ import neko.zip.Flush;
+ #else
+ import cpp.Lib;
+ import cpp.zip.Compress;
+ import cpp.zip.Uncompress;
+ import cpp.zip.Flush;
+ #end
+
#end
class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if !haxe3 , #end implements IDataInput #if !haxe3 , #end implements IMemoryRange
@@ -80,8 +85,10 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
var bytes = function(inArray:ByteArray) { return inArray==null ? null : inArray.b; }
var slen = function(inArray:ByteArray) { return inArray == null ? 0 : inArray.length; }
- var init = Libs.load("nme", "nme_byte_array_init", 4);
- init(factory, slen, resize, bytes);
+ #if !lime_html5
+ var init = Libs.load("nme", "nme_byte_array_init", 4);
+ init(factory, slen, resize, bytes);
+ #end //lime_html5
}
#end
@@ -113,6 +120,9 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
length = 0;
}
+#if !lime_html5
+//todo- sven
+
public function compress(algorithm:CompressionAlgorithm = null)
{
#if neko
@@ -156,6 +166,8 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
compress(CompressionAlgorithm.DEFLATE);
}
+#end //!lime_html5
+
/** @private */ private function ensureElem(inSize:Int, inUpdateLenght:Bool) {
var len = inSize + 1;
@@ -189,10 +201,15 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
public function getByteBuffer():ByteArray { return this; }
public function getStart():Int { return 0; }
- public function inflate()
- {
+#if !lime_html5
+
+ public function inflate() {
+
uncompress(CompressionAlgorithm.DEFLATE);
+
}
+
+#end //!lime_html5
private inline function nmeFromBytes(inBytes:Bytes):Void
{
@@ -241,17 +258,23 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
public function readDouble():Float
{
- if (position + 8 > length)
- ThrowEOFi();
+ #if !lime_html5
- #if neko
- var bytes = new Bytes(8, untyped __dollar__ssub(b, position, 8));
- #elseif cpp
- var bytes = new Bytes(8, b.slice(position, position + 8));
- #end
+ if (position + 8 > length)
+ ThrowEOFi();
- position += 8;
- return _double_of_bytes(bytes.b, bigEndian);
+ #if neko
+ var bytes = new Bytes(8, untyped __dollar__ssub(b, position, 8));
+ #elseif cpp
+ var bytes = new Bytes(8, b.slice(position, position + 8));
+ #end
+
+ position += 8;
+ return _double_of_bytes(bytes.b, bigEndian);
+
+ #end //!lime_html5
+
+ return 0.0;
}
#if !no_nme_io
@@ -262,18 +285,24 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
#end
public function readFloat():Float
- {
- if (position + 4 > length)
- ThrowEOFi();
+ {
+ #if !lime_html5
+
+ if (position + 4 > length)
+ ThrowEOFi();
- #if neko
- var bytes = new Bytes(4, untyped __dollar__ssub(b, position, 4));
- #elseif cpp
- var bytes = new Bytes(4, b.slice(position, position + 4));
- #end
+ #if neko
+ var bytes = new Bytes(4, untyped __dollar__ssub(b, position, 4));
+ #elseif cpp
+ var bytes = new Bytes(4, b.slice(position, position + 4));
+ #end
- position += 4;
- return _float_of_bytes(bytes.b, bigEndian);
+ position += 4;
+ return _float_of_bytes(bytes.b, bigEndian);
+
+ #end //!lime_html5
+
+ return 0.0;
}
public function readInt():Int
@@ -339,13 +368,20 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
var p = position;
position += inLen;
- #if neko
- return new String(untyped __dollar__ssub(b, p, inLen));
- #elseif cpp
- var result:String="";
- untyped __global__.__hxcpp_string_of_bytes(b, result, p, inLen);
- return result;
+ #if lime_native
+
+ #if neko
+ return new String(untyped __dollar__ssub(b, p, inLen));
+ #elseif cpp
+ var result:String="";
+ untyped __global__.__hxcpp_string_of_bytes(b, result, p, inLen);
+ return result;
+ #end
+
+ #else
+ return "-";
#end
+
}
public function setLength(inLength:Int):Void
@@ -393,6 +429,9 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
return 0;
}
+#if !lime_html5
+//todo sven
+
public function uncompress(algorithm:CompressionAlgorithm = null):Void
{
if (algorithm == null) algorithm = CompressionAlgorithm.GZIP;
@@ -433,6 +472,8 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
#end
}
+#end //!lime_html5
+
/** @private */ inline function write_uncheck(inByte:Int) {
#if cpp
untyped b.__unsafe_set(position++, inByte);
@@ -467,14 +508,18 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
}
public function writeDouble(x:Float)
- {
- #if neko
- var bytes = new Bytes(8, _double_bytes(x, bigEndian));
- #elseif cpp
- var bytes = Bytes.ofData(_double_bytes(x, bigEndian));
- #end
+ {
+ #if !lime_html5
- writeBytes(bytes);
+ #if neko
+ var bytes = new Bytes(8, _double_bytes(x, bigEndian));
+ #elseif cpp
+ var bytes = Bytes.ofData(_double_bytes(x, bigEndian));
+ #end
+
+ writeBytes(bytes);
+
+ #end //!lime_html5
}
#if !no_nme_io
@@ -486,13 +531,17 @@ class ByteArray extends Bytes #if !haxe3 , #end implements ArrayAccess #if
public function writeFloat(x:Float)
{
- #if neko
- var bytes = new Bytes(4, _float_bytes(x, bigEndian));
- #elseif cpp
- var bytes = Bytes.ofData(_float_bytes(x, bigEndian));
- #end
+ #if !lime_html5
- writeBytes(bytes);
+ #if neko
+ var bytes = new Bytes(4, _float_bytes(x, bigEndian));
+ #elseif cpp
+ var bytes = Bytes.ofData(_float_bytes(x, bigEndian));
+ #end
+
+ writeBytes(bytes);
+
+ #end //!lime_html5
}
public function writeInt(value:Int)
diff --git a/lime/utils/CompressionAlgorithm.hx b/lime/utils/CompressionAlgorithm.hx
index c4d191b61..4087e8c56 100644
--- a/lime/utils/CompressionAlgorithm.hx
+++ b/lime/utils/CompressionAlgorithm.hx
@@ -1,5 +1,6 @@
package lime.utils;
-#if (cpp || neko)
+#if (lime_native || lime_html5)
+// #if (cpp || neko)
enum CompressionAlgorithm {
DEFLATE;
diff --git a/lime/utils/Float32Array.hx b/lime/utils/Float32Array.hx
index 394560714..cd39e4559 100644
--- a/lime/utils/Float32Array.hx
+++ b/lime/utils/Float32Array.hx
@@ -1,88 +1,91 @@
package lime.utils;
-
-import lime.geometry.Matrix3D;
-
-
-class Float32Array extends ArrayBufferView implements ArrayAccess {
-
-
- static public inline var SBYTES_PER_ELEMENT = 4;
-
- public var BYTES_PER_ELEMENT (default, null):Int;
- public var length (default, null):Int;
-
-
- public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
+#if lime_html5
- BYTES_PER_ELEMENT = 4;
+ typedef Float32Array = js.html.Float32Array;
+
+#end //lime_html5
+
+
+#if lime_native
+
+ import lime.geometry.Matrix3D;
+
+
+ class Float32Array extends ArrayBufferView implements ArrayAccess {
- if (Std.is (bufferOrArray, Int)) {
+ static public inline var SBYTES_PER_ELEMENT = 4;
+
+ public var BYTES_PER_ELEMENT (default, null):Int;
+ public var length (default, null):Int;
+
+ public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
- super (Std.int (bufferOrArray) * BYTES_PER_ELEMENT);
+ BYTES_PER_ELEMENT = 4;
- } else if (Std.is (bufferOrArray, Array)) {
-
- var floats:Array = bufferOrArray;
-
- if (length != null) {
+ if (Std.is (bufferOrArray, Int)) {
- this.length = length;
+ super (Std.int (bufferOrArray) * BYTES_PER_ELEMENT);
+
+ } else if (Std.is (bufferOrArray, Array)) {
+
+ var floats:Array = bufferOrArray;
+
+ if (length != null) {
+
+ this.length = length;
+
+ } else {
+
+ this.length = floats.length - start;
+
+ }
+
+ super (this.length << 2);
+
+ #if !cpp
+ buffer.position = 0;
+ #end
+
+ for (i in 0...this.length) {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_float (bytes, (i << 2), floats[i]);
+ #else
+ buffer.writeFloat (floats[i + start]);
+ #end
+
+ }
} else {
- this.length = floats.length - start;
+ super (bufferOrArray, start, length);
+ if ((byteLength & 0x03) > 0) {
+
+ throw("Invalid array size");
+
+ }
+
+ this.length = byteLength >> 2;
+
+ if ((this.length << 2) != byteLength) {
+
+ throw "Invalid length multiple";
+
+ }
}
-
- super (this.length << 2);
-
- #if !cpp
- buffer.position = 0;
- #end
-
- for (i in 0...this.length) {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_float (bytes, (i << 2), floats[i]);
- #else
- buffer.writeFloat (floats[i + start]);
- #end
-
- }
-
- } else {
-
- super (bufferOrArray, start, length);
-
- if ((byteLength & 0x03) > 0) {
-
- throw("Invalid array size");
-
- }
-
- this.length = byteLength >> 2;
-
- if ((this.length << 2) != byteLength) {
-
- throw "Invalid length multiple";
-
- }
-
}
- }
-
-
- public static function fromMatrix (matrix:Matrix3D):Float32Array {
- return new Float32Array (matrix.rawData);
+ public static function fromMatrix (matrix:Matrix3D):Float32Array {
+ return new Float32Array (matrix.rawData);
+ }
+
+ @:noCompletion @:keep inline public function __get (index:Int):Float { return getFloat32 (index << 2); }
+ @:noCompletion @:keep inline public function __set (index:Int, value:Float):Void { setFloat32 (index << 2, value); }
+
}
-
-
- @:noCompletion @:keep inline public function __get (index:Int):Float { return getFloat32 (index << 2); }
- @:noCompletion @:keep inline public function __set (index:Int, value:Float):Void { setFloat32 (index << 2, value); }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
diff --git a/lime/utils/IDataInput.hx b/lime/utils/IDataInput.hx
index 8e893d4e4..ea2c32f31 100644
--- a/lime/utils/IDataInput.hx
+++ b/lime/utils/IDataInput.hx
@@ -1,5 +1,6 @@
package lime.utils;
-#if (cpp || neko)
+// #if (cpp || neko)
+#if (lime_native || lime_html5)
interface IDataInput
{
diff --git a/lime/utils/Int16Array.hx b/lime/utils/Int16Array.hx
index 245e3470e..52a917354 100644
--- a/lime/utils/Int16Array.hx
+++ b/lime/utils/Int16Array.hx
@@ -1,6 +1,7 @@
package lime.utils;
+
class Int16Array extends ArrayBufferView implements ArrayAccess {
diff --git a/lime/utils/Int32Array.hx b/lime/utils/Int32Array.hx
index a395e8fe0..9170fde12 100644
--- a/lime/utils/Int32Array.hx
+++ b/lime/utils/Int32Array.hx
@@ -1,79 +1,88 @@
package lime.utils;
+#if lime_html5
+
+ typedef Int32Array = js.html.Int32Array;
-@:arrayAccess
-class Int32Array extends ArrayBufferView implements ArrayAccess {
-
-
- static public inline var SBYTES_PER_ELEMENT = 4;
-
- public var BYTES_PER_ELEMENT (default, null):Int;
- public var length (default, null):Int;
-
-
- public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
+#end //lime_html5
+
+#if lime_native
+
+ @:arrayAccess
+ class Int32Array extends ArrayBufferView implements ArrayAccess {
- BYTES_PER_ELEMENT = 4;
- if (Std.is (bufferOrArray, Int)) {
+ static public inline var SBYTES_PER_ELEMENT = 4;
+
+ public var BYTES_PER_ELEMENT (default, null):Int;
+ public var length (default, null):Int;
+
+
+ public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
- super (Std.int (bufferOrArray) << 2);
+ BYTES_PER_ELEMENT = 4;
- } else if (Std.is (bufferOrArray, Array)) {
-
- var ints:Array = bufferOrArray;
-
- if (length != null) {
+ if (Std.is (bufferOrArray, Int)) {
- this.length = length;
+ super (Std.int (bufferOrArray) << 2);
+
+ } else if (Std.is (bufferOrArray, Array)) {
+
+ var ints:Array = bufferOrArray;
+
+ if (length != null) {
+
+ this.length = length;
+
+ } else {
+
+ this.length = ints.length - start;
+
+ }
+
+ super (this.length << 2);
+
+ #if !cpp
+ buffer.position = 0;
+ #end
+
+ for (i in 0...this.length) {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_i32 (bytes, (i << 2), ints[i]);
+ #else
+ buffer.writeInt (ints[i + start]);
+ #end
+
+ }
} else {
- this.length = ints.length - start;
+ super (bufferOrArray, start, length);
- }
-
- super (this.length << 2);
-
- #if !cpp
- buffer.position = 0;
- #end
-
- for (i in 0...this.length) {
+ if ((byteLength & 0x03) > 0) {
+
+ throw ("Invalid array size");
+
+ }
- #if cpp
- untyped __global__.__hxcpp_memory_set_i32 (bytes, (i << 2), ints[i]);
- #else
- buffer.writeInt (ints[i + start]);
- #end
+ this.length = byteLength >> 2;
- }
-
- } else {
-
- super (bufferOrArray, start, length);
-
- if ((byteLength & 0x03) > 0) {
-
- throw ("Invalid array size");
-
- }
-
- this.length = byteLength >> 2;
-
- if ((this.length << 2) != byteLength) {
-
- throw "Invalid length multiple";
+ if ((this.length << 2) != byteLength) {
+
+ throw "Invalid length multiple";
+
+ }
}
}
+
+ @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt32 (index << 2); }
+ @:noCompletion @:keep inline public function __set (index:Int, value:Int):Void { setInt32 (index << 2, value); }
+
+
}
-
-
- @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt32 (index << 2); }
- @:noCompletion @:keep inline public function __set (index:Int, value:Int):Void { setInt32 (index << 2, value); }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
\ No newline at end of file
diff --git a/lime/utils/Libs.hx b/lime/utils/Libs.hx
index c5a8582b9..dac15ce39 100644
--- a/lime/utils/Libs.hx
+++ b/lime/utils/Libs.hx
@@ -1,7 +1,5 @@
package lime.utils;
-import sys.io.Process;
-
class Libs {
//for Load function
@@ -13,29 +11,34 @@ class Libs {
private static function tryLoad (name:String, library:String, func:String, args:Int):Dynamic {
- try {
-
- #if cpp
- var result = cpp.Lib.load (name, func, args);
- #elseif (neko)
- var result = neko.Lib.load (name, func, args);
- #else
- return null;
- #end
-
- if (result != null) {
+
+ #if lime_native
+
+ try {
- loaderTrace ("Got result " + name);
- __moduleNames.set (library, name);
- return result;
+ #if cpp
+ var result = cpp.Lib.load (name, func, args);
+ #elseif (neko)
+ var result = neko.Lib.load (name, func, args);
+ #else
+ return null;
+ #end
+
+ if (result != null) {
+
+ loaderTrace ("Got result " + name);
+ __moduleNames.set (library, name);
+ return result;
+
+ }
+
+ } catch (e:Dynamic) {
+
+ loaderTrace ("Failed to load : " + name);
}
-
- } catch (e:Dynamic) {
-
- loaderTrace ("Failed to load : " + name);
-
- }
+
+ #end //lime_native
return null;
@@ -66,35 +69,39 @@ class Libs {
try {
- var proc = new Process ("haxelib", [ "path", library ]);
+ #if lime_native
- if (proc != null) {
+ var proc = new sys.io.Process ("haxelib", [ "path", library ]);
- var stream = proc.stdout;
-
- try {
+ if (proc != null) {
- while (true) {
+ var stream = proc.stdout;
+
+ try {
- var s = stream.readLine ();
-
- if (s.substr (0, 1) != "-") {
+ while (true) {
- stream.close ();
- proc.close ();
- loaderTrace ("Found haxelib " + s);
- return s;
+ var s = stream.readLine ();
+
+ if (s.substr (0, 1) != "-") {
+
+ stream.close ();
+ proc.close ();
+ loaderTrace ("Found haxelib " + s);
+ return s;
+
+ }
}
- }
+ } catch(e:Dynamic) { }
- } catch(e:Dynamic) { }
-
- stream.close ();
- proc.close ();
-
- }
+ stream.close ();
+ proc.close ();
+
+ }
+
+ #end //lime_native
} catch (e:Dynamic) { }
@@ -104,11 +111,19 @@ class Libs {
private static function sysName ():String {
- #if cpp
- var sys_string = cpp.Lib.load ("std", "sys_string", 0);
- return sys_string ();
- #else
- return Sys.systemName ();
+ #if lime_native
+ #if cpp
+ var sys_string = cpp.Lib.load ("std", "sys_string", 0);
+ return sys_string ();
+ #else
+ return Sys.systemName ();
+ #end
+ #end
+
+
+ #if lime_html5
+ return "Lime_Browser_WebGL";
+ //todo get browser info
#end
}
@@ -181,18 +196,29 @@ class Libs {
private static function loaderTrace (message:String) {
- #if cpp
- var get_env = cpp.Lib.load ("std", "get_env", 1);
- var debug = (get_env ("OPENFL_LOAD_DEBUG") != null);
- #else
- var debug = (Sys.getEnv ("OPENFL_LOAD_DEBUG") !=null);
- #end
-
- if (debug) {
-
- Sys.println (message);
-
- }
+ #if lime_native
+
+ #if cpp
+
+ var get_env = cpp.Lib.load ("std", "get_env", 1);
+ var debug = (get_env ("OPENFL_LOAD_DEBUG") != null);
+
+ #else //# not cpp
+
+ var debug = (Sys.getEnv ("OPENFL_LOAD_DEBUG") !=null);
+
+ #end //# if cpp
+
+ if (debug) {
+ Sys.println (message);
+ } //if debug
+
+ #end //lime_native
+
+
+ #if lime_html5
+ //todo leverage console.log somehow?
+ #end //lime_html5
}
diff --git a/lime/utils/UInt8Array.hx b/lime/utils/UInt8Array.hx
index 1a02b72dd..8a3c7c6b8 100644
--- a/lime/utils/UInt8Array.hx
+++ b/lime/utils/UInt8Array.hx
@@ -1,65 +1,75 @@
package lime.utils;
+#if lime_html5
+
+ typedef UInt8Array = js.html.Uint8Array;
-class UInt8Array extends ArrayBufferView implements ArrayAccess {
-
-
- static public inline var SBYTES_PER_ELEMENT = 1;
-
- public var BYTES_PER_ELEMENT (default, null):Int;
- public var length (default, null):Int;
-
-
- public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
+#end //lime_html5
+
+
+#if lime_native
+
+ class UInt8Array extends ArrayBufferView implements ArrayAccess {
- BYTES_PER_ELEMENT = 1;
- if (Std.is (bufferOrArray, Int)) {
+ static public inline var SBYTES_PER_ELEMENT = 1;
+
+ public var BYTES_PER_ELEMENT (default, null):Int;
+ public var length (default, null):Int;
+
+
+ public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) {
- super (Std.int (bufferOrArray));
+ BYTES_PER_ELEMENT = 1;
- } else if (Std.is (bufferOrArray, Array)) {
-
- var ints:Array = bufferOrArray;
-
- if (length != null) {
+ if (Std.is (bufferOrArray, Int)) {
- this.length = length;
+ super (Std.int (bufferOrArray));
+
+ } else if (Std.is (bufferOrArray, Array)) {
+
+ var ints:Array = bufferOrArray;
+
+ if (length != null) {
+
+ this.length = length;
+
+ } else {
+
+ this.length = ints.length - start;
+
+ }
+
+ super (this.length);
+
+ #if !cpp
+ buffer.position = 0;
+ #end
+
+ for (i in 0...this.length) {
+
+ #if cpp
+ untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i]);
+ #else
+ buffer.writeByte(ints[i + start]);
+ #end
+
+ }
} else {
- this.length = ints.length - start;
+ super (bufferOrArray, start, length);
+ this.length = byteLength;
}
- super (this.length);
-
- #if !cpp
- buffer.position = 0;
- #end
-
- for (i in 0...this.length) {
-
- #if cpp
- untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i]);
- #else
- buffer.writeByte(ints[i + start]);
- #end
-
- }
-
- } else {
-
- super (bufferOrArray, start, length);
- this.length = byteLength;
-
}
+
+ @:noCompletion @:keep inline public function __get (index:Int):Int { return getUInt8 (index); }
+ @:noCompletion @:keep inline public function __set (index:Int, value:Int):Void { setUInt8 (index, value); }
+
+
}
-
-
- @:noCompletion @:keep inline public function __get (index:Int):Int { return getUInt8 (index); }
- @:noCompletion @:keep inline public function __set (index:Int, value:Int):Void { setUInt8 (index, value); }
-
-
-}
\ No newline at end of file
+
+#end //lime_native
\ No newline at end of file