diff --git a/lime/AudioHandler.hx b/lime/AudioHandler.hx deleted file mode 100644 index c7129e609..000000000 --- a/lime/AudioHandler.hx +++ /dev/null @@ -1,185 +0,0 @@ -package lime; - -import lime.utils.Libs; -import lime.helpers.AudioHelper; -import lime.helpers.AudioHelper.Sound; - -class AudioHandler { - - public var lib : Lime; - - public var sounds : Map; - public var helper : lime.helpers.AudioHelper; - - public function new( _lib:Lime ) { - lib = _lib; - //create the helper, this defers based on platform inside AudioHelper - helper = new AudioHelper( lib ); - } - - public function startup() { - - sounds = new Map(); - - helper.startup(); - - } //startup - - @:noCompletion public function shutdown() { - - helper.shutdown(); - - } //shutdown - - @:noCompletion public function update() { - - helper.update(); - - #if lime_native - - for(sound in sounds) { - sound.check_complete(); - } //each sound - - #end //lime_native - - } //update - - public function create( _name:String, _file:String, ?_music:Bool = false ) : Sound { - - if( sounds.exists(_name) ) { - throw "lime : audio : Named sounds are not allowed to have duplicate names for now"; - } - - var sound_instance = helper.create( _name, _file, _music ); - - if(sound_instance != null) { - sounds.set( _name, sound_instance ); - } - - return sound_instance; - - } //create - - //fetch a named sound, or null if not found (see also exists) - public function sound( _name:String ) : Sound { - - return sounds.get(_name); - - } //sound - - public function loop( _name:String ) : Void { - - var _sound = sound(_name); - - if(_sound != null) { - //set the looping flag so it continues to loop - _sound.looping = true; - //:todo: start position for looping? - _sound.play(); - - } else { - trace('Audio :: Sound does not exist, use Luxe.audio.create() first : ' + _name); - } - - } //loop - - public function stop( _name:String ) : Void { - - var _sound = sound(_name); - - if(_sound != null) { - _sound.stop(); - } else { - trace('lime : audio : sound does not exist for stop(' + _name + '), use audio.create() first'); - } - - } //stop - - public function play( _name:String, ?_number_of_times:Int=1, ?_start_position_in_ms:Float = 0 ) : Void { - - var _sound = sound(_name); - - if(_sound != null) { - _sound.play( _number_of_times , _start_position_in_ms ); - } else { - trace('lime : audio : sound does not exist for play(' + _name + '), use audio.create() first'); - } - - } //play - - //true or false if a sound is playing - public function playing( _name:String ) : Bool { - - var s = sound(_name); - if(s != null) { - return s.playing; - } - - return false; - - } //playing - - public function exists( _name:String ) : Bool { - - return sound( _name ) != null; - - } //exists - - //without expressing a value for volume, - //a sound will return it's volume - public function volume( _name:String, ?_volume:Float = null ) : Float { - - var _sound = sound(_name); - if(_sound == null) { - trace('lime : audio : sound does not exist for volume(' + _name + '), use audio.create() first'); - return 0.0; - } - - if(_volume != null) { - _sound.volume = _volume; - } - - return _sound.volume; - - } //volume - - //without expressing a value for pan, - //a sound will return it's pan - public function pan( _name:String, ?_pan:Float = null ) : Float { - - var _sound = sound(_name); - if(_sound == null) { - trace('lime : audio : sound does not exist for pan(' + _name + '), use audio.create() first'); - return 0.0; - } - - if(_pan != null) { - _sound.pan = _pan; - } - - return _sound.pan; - - } //pan - - //without expressing a value for position, - //a sound will return it's position - public function position( _name:String, ?_pos:Float = null ) : Float { - - var _sound = sound(_name); - if(_sound == null) { - trace('lime : audio : sound does not exist for position(' + _name + '), use Luxe.audio.create() first'); - return 0.0; - } - - if(_pos != null) { - _sound.position = _pos; - } - - return _sound.position; - - } //position - -} //AudioHandler - - diff --git a/lime/Constants.hx b/lime/Constants.hx deleted file mode 100644 index e8a977cc8..000000000 --- a/lime/Constants.hx +++ /dev/null @@ -1,54 +0,0 @@ -package lime; - - //Window constants -class Window { - - static public var FULLSCREEN = 0x0001; - static public var BORDERLESS = 0x0002; - static public var RESIZABLE = 0x0004; - static public var HARDWARE = 0x0008; - static public var VSYNC = 0x0010; - static public var HW_AA = 0x0020; - static public var HW_AA_HIRES = 0x0060; - static public var ALLOW_SHADERS = 0x0080; - static public var REQUIRE_SHADERS = 0x0100; - static public var DEPTH_BUFFER = 0x0200; - static public var STENCIL_BUFFER = 0x0400; - -} - -class SystemEvents { - - static public var char = 1; - static public var keydown = 2; - static public var keyup = 3; - static public var mousemove = 4; - static public var mousedown = 5; - static public var mouseclick = 6; - static public var mouseup = 7; - static public var resize = 8; - static public var poll = 9; - static public var quit = 10; - static public var focus = 11; - static public var shouldrotate = 12; - - static public var redraw = 14; - static public var touchbegin = 15; - static public var touchmove = 16; - static public var touchend = 17; - static public var touchtap = 18; - static public var change = 19; - static public var activate = 20; - static public var deactivate = 21; - static public var gotinputfocus = 22; - static public var lostinputfocus = 23; - static public var joyaxismove = 24; - static public var joyballmove = 25; - static public var joyhatmove = 26; - static public var joybuttondown = 27; - static public var joybuttonup = 28; - static public var joydeviceadded = 29; - static public var joydeviceremoved = 30; - static public var syswm = 31; - -} \ No newline at end of file diff --git a/lime/InputHandler.hx b/lime/InputHandler.hx deleted file mode 100644 index 9fd145d58..000000000 --- a/lime/InputHandler.hx +++ /dev/null @@ -1,704 +0,0 @@ -package lime; - -import lime.Lime; -import lime.RenderHandler; -import lime.helpers.Keys; -import lime.helpers.InputHelper; - -class InputHandler { - - public var lib : Lime; - - //the active touches at any point - public var touches_active : Map; - - //this is a code/scan specific key repeat map - public var keys_down : Map; - //this is the enum based flags for keypressed/keyreleased/keydown - public var key_value_down : Map; - public var key_value_pressed : Map; - public var key_value_released : Map; - //previous move x/y - public var last_mouse_x : Int = 0; - public var last_mouse_y : Int = 0; - - //input helper for diff platforms - public var helper : InputHelper; - - public function new( _lib:Lime ) { - - lib = _lib; - - helper = new InputHelper( lib ); - - } //new - -//Public facing API - -//Down / Pressed / Released helpers - - public function keypressed( _value:KeyValue ) { - return key_value_pressed.exists(_value); - } //keypressed - - public function keyreleased( _value:KeyValue ) { - return key_value_released.exists(_value); - } //keyreleased - - public function keydown( _value:KeyValue ) { - return key_value_down.exists(_value); - } //keydown - -//Internal API - - @:noCompletion public function startup() { - - #if debug - lib._debug(':: lime :: \t InputHandler Initialized.'); - #end //debug - - touches_active = new Map(); - keys_down = new Map(); - - key_value_pressed = new Map(); - key_value_down = new Map(); - key_value_released = new Map(); - - helper.startup(); - - } //startup - - @:noCompletion public function shutdown() { - - #if debug - lib._debug(':: lime :: \t InputHandler shut down.'); - #end //debug - - } //shutdown - - @:noCompletion public function update() { - - //update any helper stuff - helper.update(); - - //remove any stale key pressed value - //unless it wasn't alive for a full frame yet, - //then flag it so that it may be - for(_value in key_value_pressed.keys()){ - - var _flag : Bool = key_value_pressed.get(_value); - if(_flag){ - key_value_pressed.remove(_value); - } else { - key_value_pressed.set(_value, true); - } - - } //each pressed_value - - //remove any stale key released value - //unless it wasn't alive for a full frame yet, - //then flag it so that it may be - for(_value in key_value_released.keys()){ - - var _flag : Bool = key_value_released.get(_value); - if(_flag){ - key_value_released.remove(_value); - } else { - key_value_released.set(_value, true); - } - - } //each pressed_value - - } //update - -//Keyboard - - @:noCompletion public function lime_onchar(_event:Dynamic) { - - if(lib.host.onchar != null) { - lib.host.onchar({ - raw : _event, - code : _event.code, - char : _event.code, - value : _event.value, - flags : _event.flags, - key : lime.helpers.Keys.toKeyValue(_event) - }); - } - - _event.char = _event.code; - - lime_onkeydown( _event ); - - } //lime_onchar - - - @:noCompletion public function lime_onkeydown(_event:Dynamic) { - - if(lib.host.onkeydown != null && !keys_down.exists(_event.value)) { - - var _keyvalue = lime.helpers.Keys.toKeyValue(_event); - - keys_down.set(_event.value, true); - - //flag the key as pressed, but unprocessed (false) - key_value_pressed.set(_keyvalue, false); - //flag it as down, because keyup removes it - key_value_down.set(_keyvalue, true); - - //some characters can come directly, not via the onchar, - //but we want end user to only require one check, - //if(event.char != 0) { //printable key } else { //other keys } - if(_event.char == null) { - _event.char = 0; - } - - lib.host.onkeydown({ - raw : _event, - code : _event.code, - char : _event.char, - value : _event.value, - flags : _event.flags, - key : _keyvalue, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }); - - } //key is down and !repeated - - } //lime_onkeydown - - @:noCompletion public function lime_onkeyup(_event:Dynamic) { - - var _keyvalue = lime.helpers.Keys.toKeyValue(_event); - - //no longer flagged as down - keys_down.remove(_event.value); - - //flag it as released but unprocessed - key_value_released.set(_keyvalue, false); - //remove the down flag - key_value_down.remove(_keyvalue); - - //pass to the host - if(lib.host.onkeyup != null) { - - lib.host.onkeyup({ - raw : _event, - code : _event.code, - char : _event.char, - value : _event.value, - flags : _event.flags, - key : _keyvalue, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }); - - } //lib.host.onkeyup != null - - } //lime_onkeyup - - @:noCompletion public function lime_gotinputfocus(_event:Dynamic) { - - //pass to the host - if(lib.host.ongotinputfocus != null) { - - lib.host.ongotinputfocus({ - raw : _event, - code : _event.code, - char : _event.char, - value : _event.value, - flags : _event.flags, - key : lime.helpers.Keys.toKeyValue(_event), - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }); - - } //host.ongotinputfocus - - } //lime_onkeyup - - @:noCompletion public function lime_lostinputfocus(_event:Dynamic) { - - //pass to the host - if(lib.host.onlostinputfocus != null) { - - lib.host.onlostinputfocus({ - raw : _event, - code : _event.code, - char : _event.char, - value : _event.value, - flags : _event.flags, - key : lime.helpers.Keys.toKeyValue(_event), - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }); - - } //host.onlostinputfocus - - } //lime_lostinputfocus - -//Mouse - - @:noCompletion public function mouse_button_from_id( id:Int ) : Dynamic { - - switch(id) { - - case 0 : return MouseButton.left; - case 1 : return MouseButton.middle; - case 2 : return MouseButton.right; - case 3 : return MouseButton.wheel_down; - case 4 : return MouseButton.wheel_up; - - default : return id; - - } //switch id - - } //mouse_button_from_id - - @:noCompletion public function lime_mousemove( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - var deltaX = _event.x - last_mouse_x; - var deltaY = _event.y - last_mouse_y; - - last_mouse_x = _event.x; - last_mouse_y = _event.y; - - //locked cursor gives us the delta directly from sdl - #if lime_native - if(lib.window.cursor_locked) { - deltaX = _event.deltaX; - deltaY = _event.deltaY; - } - #end //lime_native - - if(lib.host.onmousemove != null) { - - var _mouse_event = _event; - - if(!_pass_through) { - - _mouse_event = { - raw : _event, - button : MouseButton.move, - state : MouseState.down, - x : _event.x, - y : _event.y, - deltaX : deltaX, - deltaY : deltaY, - flags : _event.flags, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }; - - } //_pass_through - - lib.host.onmousemove( _mouse_event ); - - } //if host onmousemove - - } //lime_mousemove - - @:noCompletion public function lime_mousedown( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.onmousedown != null) { - - var _mouse_event = _event; - - if(!_pass_through) { - - _mouse_event = { - raw : _event, - button : mouse_button_from_id(_event.value), - state : MouseState.down, - x : _event.x, - y : _event.y, - flags : _event.flags, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }; // - - } //_pass_through - - lib.host.onmousedown( _mouse_event ); - - } //if host onmousedown - - } //lime_mousedown - - @:noCompletion public function lime_mouseclick( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.onmouseclick != null) { - - var _mouse_event = _event; - - if(!_pass_through) { - - _mouse_event = { - raw : _event, - button : _event.value, - state : MouseState.down, - x : _event.x, - y : _event.y, - flags : _event.flags, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }; - - } //_pass_through - - lib.host.onmouseclick( _mouse_event ); - - } //if host onmouseclick - - } //lime_mouseclick - - @:noCompletion public function lime_mouseup( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.onmouseup != null) { - - var _mouse_event = _event; - var _button = mouse_button_from_id(_event.value); - - //on native platforms, the wheel can come from mouseup events - //so we watch for those and forward it to wheel instead - if( _button == MouseButton.wheel_down || _button == MouseButton.wheel_up ) { - - return lime_mousewheel( _event, _pass_through); - - } //wheel event - - - if(!_pass_through) { - - _mouse_event = { - raw : _event, - button : _button, - state : MouseState.up, - x : _event.x, - y : _event.y, - flags : _event.flags, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }; - - } //pass through - - - lib.host.onmouseup( _mouse_event ); - - } //if host onmouseup - - } //lime_mouseup - - @:noCompletion public function lime_mousewheel( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.onmousewheel != null) { - - var _mouse_event = _event; - - if(!_pass_through) { - - _mouse_event = { - raw : _event, - button : mouse_button_from_id(_event.value), - state : MouseState.wheel, - x : _event.x, - y : _event.y, - flags : _event.flags, - ctrl_down : (_event.flags & efCtrlDown > 0), - alt_down : (_event.flags & efAltDown > 0), - shift_down : (_event.flags & efShiftDown > 0), - meta_down : (_event.flags & efCommandDown > 0) - }; - - } //pass through - - lib.host.onmousewheel( _mouse_event ); - - } //if host onmouseup - - } //lime_mousewheel - -//Touch - - @:noCompletion public function lime_touchbegin(_event:Dynamic) : Void { - - var touch_item = { - state : TouchState.begin, - flags : _event.flags, - ID : _event.value, - x : _event.x, - y : _event.y - }; - - //store the touch in the set - touches_active.set( touch_item.ID, touch_item ); - - //forward to the host - if(lib.host.ontouchbegin != null) { - lib.host.ontouchbegin( touch_item ); - } - - //forward the down event - if ((_event.flags & 0x8000) > 0) { - lime_mousedown(_event); - } - - } //lime_touchbegin - - @:noCompletion public function lime_touchmove(_event:Dynamic) : Void { - - //Get the touch item from the set - var touch_item = touches_active.get( _event.value ); - //Update the values - touch_item.x = _event.x; - touch_item.y = _event.y; - touch_item.state = TouchState.move; - touch_item.flags = _event.flags; - - //Call the host function - if(lib.host.ontouchmove != null) { - lib.host.ontouchmove(touch_item); - } - - } //lime_touchmove - - @:noCompletion public function lime_touchend(_event:Dynamic) : Void { - - //Get the touch item from the set - var touch_item = touches_active.get( _event.value ); - //Update the values - touch_item.x = _event.x; - touch_item.y = _event.y; - touch_item.state = TouchState.end; - touch_item.flags = _event.flags; - - if(lib.host.ontouchend != null) { - lib.host.ontouchend(touch_item); - } - - //Forward the up event - if ((_event.flags & 0x8000) > 0) { - lime_mouseup(_event); - } - - //remove it from the map - touches_active.remove(_event.value); - - } //lime_touchend - - @:noCompletion public function lime_touchtap(_event:Dynamic) : Void { - - if(lib.host.ontouchtap != null) { - lib.host.ontouchtap(_event); - } - - } //lime_touchtap - -//Gamepad - - @:noCompletion public function lime_gamepadaxis( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.ongamepadaxis != null) { - - var _gamepad_event = _event; - - if(!_pass_through) { - - _gamepad_event = { - raw : _event, - axis : _event.code, - value : (_event.value / 32767), - gamepad : _event.id - } - - } //pass through - - lib.host.ongamepadaxis( _gamepad_event ); - - } //lib.host.ongamepadaxis != null - - } //lime_gamepadaxis - - @:noCompletion public function lime_gamepadbuttondown( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.ongamepadbuttondown != null) { - - var _gamepad_event = _event; - - if(!_pass_through) { - - _gamepad_event = { - raw : _event, - state : ButtonState.down, - value : 0, - button : _event.code, - gamepad : _event.id - }; - - } - - lib.host.ongamepadbuttondown( _gamepad_event ); - - } - - } //lime_gamepadbuttondown - - @:noCompletion public function lime_gamepadbuttonup( _event:Dynamic, ?_pass_through:Bool=false ) : Void { - - if(lib.host.ongamepadbuttonup != null) { - - var _gamepad_event = _event; - - if(!_pass_through) { - - _gamepad_event = { - raw : _event, - state : ButtonState.up, - value : 1, - button : _event.code, - gamepad : _event.id - }; - - } - - lib.host.ongamepadbuttonup( _gamepad_event ); - - } - - } //lime_gamepadbuttonup - - @:noCompletion public function lime_gamepadball(_event:Dynamic) : Void { - if(lib.host.ongamepadball != null) { - lib.host.ongamepadball(_event); - } - } //lime_gamepadball - - @:noCompletion public function lime_gamepadhat(_event:Dynamic) : Void { - if(lib.host.ongamepadhat != null) { - lib.host.ongamepadhat(_event); - } - } //lime_gamepadhat - - public function lime_gamepaddeviceadded(_event:Dynamic) { - if(lib.host.ongamepaddeviceadded != null) { - lib.host.ongamepaddeviceadded(_event); - } - } //lime_gamepaddeviceadded - - public function lime_gamepaddeviceremoved(_event:Dynamic) { - if(lib.host.ongamepaddeviceremoved != null) { - lib.host.ongamepaddeviceremoved(_event); - } - } //lime_gamepaddeviceremoved - - private static var efLeftDown = 0x0001; - private static var efShiftDown = 0x0002; - private static var efCtrlDown = 0x0004; - private static var efAltDown = 0x0008; - private static var efCommandDown = 0x0010; - -} //InputHandler - - -enum TouchState { - begin; - move; - end; -} - -enum MouseState { - down; - move; - wheel; - up; -} - -enum ButtonState { - down; - up; -} - -enum MouseButton { - move; - left; - middle; - right; - wheel_up; - wheel_down; -} - -typedef KeyEvent = { - var raw : Dynamic; - var code : Int; - var char : Int; - var value : Int; - var flags : Int; - var key : lime.helpers.Keys.KeyValue; - var shift_down : Bool; - var ctrl_down : Bool; - var alt_down : Bool; - var meta_down : Bool; -}; - -typedef TouchEvent = { - var state : TouchState; - var flags : Int; - var ID : Int; - var x : Float; - var y : Float; - var raw : Dynamic; -}; - -typedef MouseEvent = { - var raw : Dynamic; - var state : MouseState; - var flags : Int; - var button : MouseButton; - var x : Float; - var y : Float; - var deltaX : Float; - var deltaY : Float; - var shift_down : Bool; - var ctrl_down : Bool; - var alt_down : Bool; - var meta_down : Bool; -} - -typedef GamepadEvent = { - var raw : Dynamic; - var gamepad : Int; -} - -typedef GamepadButtonEvent = { - var raw : Dynamic; - var gamepad : Int; - var button : Int; - var value : Float; - var state : ButtonState; -} - -typedef GamepadAxisEvent = { - var raw : Dynamic; - var gamepad : Int; - var axis : Int; - var value : Float; -} - diff --git a/lime/Lime.hx b/lime/Lime.hx deleted file mode 100644 index 6d0a92cf4..000000000 --- a/lime/Lime.hx +++ /dev/null @@ -1,497 +0,0 @@ -package lime; - -import lime.utils.Libs; - -import lime.Constants; -import lime.RenderHandler; -import lime.AudioHandler; -import lime.InputHandler; -import lime.WindowHandler; - -import haxe.Timer; - -typedef LimeConfig = { - ? host : Dynamic, - ? fullscreen : Bool, - ? resizable : Bool, - ? borderless : Bool, - ? antialiasing : Int, - ? stencil_buffer : Bool, - ? depth_buffer : Bool, - ? vsync : Bool, - ? multitouch_supported : Bool, - ? multitouch : Bool, - ? fps : Int, - ? width : Int, - ? height : Int, - ? title : String, - ? orientation : String -} - -class Lime { - - //The host class of the application - public var host : Dynamic; - //the config passed to us on creation - public var config : LimeConfig; - - //The handlers for the messages from lime - public var audio : AudioHandler; - public var input : InputHandler; - public var render : RenderHandler; - public var window : WindowHandler; - -//lime specifics - - //the handle to the window from lime - public var window_handle : Dynamic; - //the handle to the lime stage - public var view_handle : Dynamic; - -// timing - - public var frame_rate (default, set): Float; - public var render_request_function:Void -> Void; - - var frame_period : Float = 0.0; - var last_render_time : Float = 0.0; - @:noCompletion public static var early_wakeup = 0.005; - private function set_frame_rate (value:Float):Float { - - frame_rate = value; - frame_period = (frame_rate <= 0 ? frame_rate : 1.0 / frame_rate); - - #if debug - _debug(':: lime :: frame rate set to ' + frame_rate); - #end - - return value; - - } - -//flags - - //if we have started a shutdown - public var shutting_down : Bool = false; - public var has_shutdown : Bool = false; - - //constructor - public function new() {} //new - - //Initialize - public function init( _main_, _config : LimeConfig ) { - - config = _config; - host = _main_; - - #if debug - _debug(':: lime :: initializing - '); - _debug(':: lime :: Creating window at ' + config.width + 'x' + config.height); - #end - - //default to 60 fps - if( config.fps != null ) { - frame_rate = config.fps; - } else { //config.fps - frame_rate = 60; - } - - #if android - render_request_function = lime_stage_request_render; - #else - render_request_function = null; - #end //android - - - //Create our window handler class, - //this will handle initialization - window = new WindowHandler( this ); - window.startup(); - - } //init - - //This gets called once the create_main_frame call inside new() - //comes back with our window - - public function on_window_ready( handle:Dynamic ) { - - //Store a reference to the handle - window_handle = handle; - - //do any on ready initialization for the window - window.ready(); - - //For the asset class to keep lists and such - lime.AssetData.initialize(); - - //Create our input message handler class - input = new InputHandler( this ); - input.startup(); - - //Create our audio message handler class - audio = new AudioHandler( this ); - audio.startup(); - - //Create our render message handler class - render = new RenderHandler( this ); - render.startup(); - - //Since we are done... - window.set_active(true); - - #if debug - _debug(':: lime :: Ready.'); - #end - - //Tell the host application we are ready - if(host.ready != null) { - host.ready(this); - } - - //if any post ready things that need - //to happen, do it here. - window.post_ready(); - - } //on_window_ready - - public function shutdown() { - - shutting_down = true; - - //tell the host game we are killing it - if(host.shutdown != null) { - host.shutdown(); - } - - //We don't want to process much now - window.set_active(false); - - //Order is imporant here too - audio.shutdown(); - render.shutdown(); - input.shutdown(); - window.shutdown(); - - //Flag it - has_shutdown = true; - - #if debug - _debug(':: lime :: Goodbye.'); - #end - } - - public function cleanup() { - render = null; - input = null; - window = null; - } - - public function on_lime_event( _event:Dynamic ) : Dynamic { - - var result = 0.0; - var event_type:Int = Std.int(Reflect.field(_event, "type")); - - #if debug - if(event_type != SystemEvents.poll) { - _debug('event_from_stage : ' + event_type, true, true); - } - #end - - switch(event_type) { - - //Main run loop - - case SystemEvents.poll: - on_update(_event); - - case SystemEvents.quit: - shutdown(); - - //keyboard - case SystemEvents.char: - _event.result = 1; - input.lime_onchar(_event); - - case SystemEvents.keydown: - - #if android - if(_event.value == 27) { - _event.result = 1; - } - #end //android - - input.lime_onkeydown(_event); - - case SystemEvents.keyup: - - #if android - if(_event.value == 27) { - _event.result = 1; - } - #end //android - - input.lime_onkeyup(_event); - - case SystemEvents.gotinputfocus: - input.lime_gotinputfocus(_event); - - case SystemEvents.lostinputfocus: - input.lime_lostinputfocus(_event); - - //mouse - case SystemEvents.mousemove: - input.lime_mousemove(_event); - - case SystemEvents.mousedown: - input.lime_mousedown(_event); - - case SystemEvents.mouseclick: - input.lime_mouseclick(_event); - - case SystemEvents.mouseup: - input.lime_mouseup(_event); - - - //touch - case SystemEvents.touchbegin: - input.lime_touchbegin(_event); - - case SystemEvents.touchmove: - input.lime_touchmove(_event); - - case SystemEvents.touchend: - input.lime_touchend(_event); - - case SystemEvents.touchtap: - input.lime_touchtap(_event); - - //gamepad/joystick - - case SystemEvents.joyaxismove: - input.lime_gamepadaxis(_event); - - case SystemEvents.joyballmove: - input.lime_gamepadball(_event); - - case SystemEvents.joyhatmove: - input.lime_gamepadhat(_event); - - case SystemEvents.joybuttondown: - input.lime_gamepadbuttondown(_event); - - case SystemEvents.joybuttonup: - input.lime_gamepadbuttonup(_event); - - case SystemEvents.joydeviceadded: - input.lime_gamepaddeviceadded(_event); - - case SystemEvents.joydeviceremoved: - input.lime_gamepaddeviceremoved(_event); - - //Window - - case SystemEvents.activate: - window.set_active(true); - - case SystemEvents.deactivate: - window.set_active(false); - - case SystemEvents.resize: - window.on_resize(_event); - - case SystemEvents.focus: - window.on_focus(_event); - - case SystemEvents.redraw: - window.on_redraw(_event); - - case SystemEvents.shouldrotate: - window.on_should_rotate(_event); - - //System - case SystemEvents.syswm: - on_syswm(_event); - - case SystemEvents.change: - on_change(_event); - - } - - __updateNextWake(); - return null; - - } //on_lime_event - - //Handle system/window messages - public function on_syswm(ev:Dynamic) { - #if debug - _debug('syswm event'); - #end - } //on_syswm - - public function on_change(ev:Dynamic) { - #if debug - _debug('change event'); - #end - } //on_syswm - - - public function on_update(_event) { - - #if debug - _debug('on_update ' + Timer.stamp(), true, false); - #end //debug - - #if lime_native - Timer.__checkTimers(); - #end - - if(!has_shutdown) { - - #if lime_native - var do_update = __checkRender(); - #else - var do_update = true; - #end - - if(do_update) { - - //process any audio - // :todo: this might want to be outside the loop like before - audio.update(); - //process any input state - input.update(); - - //call the host update - if( host.update != null) { - host.update(); - } - - //make a render happen - perform_render(); - - } //do_update? - - } // if !has_shutdown - - return true; - - } //on_update - - - public function perform_render() { - - if (render_request_function != null) { - render_request_function(); - } else { - render.render(); - } - - } //perform render - - @:noCompletion private function __checkRender():Bool { - - #if emscripten - render.render(); - return true; - #end - - if (frame_rate > 0) { - - var now = haxe.Timer.stamp(); - if (now >= last_render_time + frame_period) { - - last_render_time = now; - - return true; - - } //if now >= last + frame_period - - } else { - - return true; - - } - - return false; - - } //__checkRender - - - @:noCompletion public function __updateNextWake():Float { - - #if lime_native - - var nextWake = haxe.Timer.__nextWake (315000000.0); - - nextWake = __nextFrameDue( nextWake ); - lime_stage_set_next_wake( view_handle, nextWake ); - - return nextWake; - - #else //lime_native - return null; - #end //!lime_native - - - } //__updateNextWake - - @:noCompletion private function __nextFrameDue( _otherTimers:Float ) { - - if(has_shutdown) { - return _otherTimers; - } - - if (!window.active) { // && pauseWhenDeactivated - return _otherTimers; - } - - if(frame_rate > 0) { - - var next = last_render_time + frame_period - haxe.Timer.stamp() - early_wakeup; - if (next < _otherTimers) { - return next; - } - - } //frame_rate - - return _otherTimers; - - } //__nextFrameDue - -//Noisy stuff - - #if lime_native - - private static var lime_stage_request_render = Libs.load("lime","lime_stage_request_render", 0); - private static var lime_stage_set_next_wake = Libs.load("lime","lime_stage_set_next_wake", 2); - - #end //lime_native - - //temporary debugging with verbosity options - - #if debug - - public var log : Bool = false; - public var verbose : Bool = false; - public var more_verbose : Bool = false; - public function _debug(value:Dynamic, _verbose:Bool = false, _more_verbose:Bool = false) { - if(log) { - if(verbose && _verbose && !_more_verbose) { - trace(value); - } else - if(more_verbose && _more_verbose) { - trace(value); - } else { - if(!_verbose && !_more_verbose) { - trace(value); - } - } //elses - } //log - } //_debug - - #end //debug - -} //Lime - - diff --git a/lime/RenderHandler.hx b/lime/RenderHandler.hx deleted file mode 100644 index 18abe99ff..000000000 --- a/lime/RenderHandler.hx +++ /dev/null @@ -1,270 +0,0 @@ -package lime; - -import lime.Lime; -import lime.utils.Libs; - - //Import GL -import lime.gl.GL; -import lime.gl.GLBuffer; -import lime.gl.GLProgram; - - //utils -import lime.utils.Float32Array; - - //geometry -import lime.utils.Matrix3D; - - -#if lime_html5 - - import js.Browser; - import js.html.CanvasElement; - - -enum BrowserLike { - unknown; - chrome; - firefox; - opera; - ie; - safari; -} - -#end //lime_html5 - - -class RenderHandler { - - public var lib : Lime; - public function new( _lib:Lime ) { lib = _lib; } - - public var __handle : Dynamic; - - //direct_renderer_handle for drawing - public var direct_renderer_handle : Dynamic; - - #if lime_html5 - public var requestAnimFrame : Dynamic; - public var browser : BrowserLike; - public var canvas_position : Dynamic; - #end //lime_html5 - - - @:noCompletion private function __onRender(rect:Dynamic):Void { - - - } - - public function startup() { - - #if lime_native - - __handle = lime_get_frame_stage( lib.window_handle ); - - //Set up the OpenGL View - direct_renderer_handle = lime_direct_renderer_create(); - - //Add this to the main stage, so it will render - lime_doc_add_child( __handle, direct_renderer_handle ); - - //Set this handle to the real view with a render function - lime_direct_renderer_set( direct_renderer_handle, on_render ); - - #end //lime_native - - #if lime_html5 - //default to 0,0 - canvas_position = {x:0, y:0}; - - //default to unknown - browser = BrowserLike.unknown; - - var _window_handle : js.html.CanvasElement = cast lib.window_handle; - direct_renderer_handle = _window_handle.getContextWebGL({ alpha:false, premultipliedAlpha:false }); - - //for use with mouseoffsets and so on - update_canvas_position(); - - if(direct_renderer_handle == null) { - throw "WebGL is required to run this"; - } - - lime.gl.GL.limeContext = direct_renderer_handle; - - requestAnimFrame = js.Browser.window.requestAnimationFrame; - - if(requestAnimFrame != null) { - browser = BrowserLike.chrome; - } else { - - var _firefox = untyped js.Browser.window.mozRequestAnimationFrame; - var _safari = untyped js.Browser.window.webkitRequestAnimationFrame; - var _opera = untyped js.Browser.window.oRequestAnimationFrame; - - if(_firefox) { - browser = BrowserLike.firefox; - } else if(_safari) { - browser = BrowserLike.safari; - } else if(_opera){ - browser = BrowserLike.opera; - } - - } //else there is no RequestAnimationFrame - - #end //lime_html5 - - //Done. - #if debug - lib._debug(':: lime :: \t RenderHandler Initialized.'); - #end //debug - } - - - public function shutdown() { - #if debug - lib._debug(':: lime :: \t RenderHandler shut down.'); - #end //debug - } - - public function on_resize(_event:Dynamic) { - - #if lime_html5 - update_canvas_position(); - #end //lime_html5 - - if(lib.host.onresize != null) { - lib.host.onresize(_event); - } - - } //on_resize - -#if lime_html5 - - public function update_canvas_position() { - // see the following link for this implementation - // http://www.quirksmode.org/js/findpos.html - - var curleft = 0; - var curtop = 0; - - //start at the canvas - var _obj : Dynamic = lib.window_handle; - var _has_parent : Bool = true; - var _max_count = 0; - - while(_has_parent == true) { - - _max_count++; - - if(_max_count > 30) { - _has_parent = false; - break; - } //prevent rogue endless loops - - if(_obj.offsetParent) { - - //it still has an offset parent, add it up - curleft += _obj.offsetLeft; - curtop += _obj.offsetTop; - - //then move onto the parent - _obj = _obj.offsetParent; - - } else { - //we are done - _has_parent = false; - - } - } //while - - canvas_position = { x:curleft, y:curtop }; - } - - public function _requestAnimFrame(callback:Dynamic) { - - if(browser == BrowserLike.chrome) { - - requestAnimFrame(callback); - - } else //chrome - if(browser == BrowserLike.firefox) { - - untyped { - js.Browser.window.mozRequestAnimationFrame(callback); - } - - } else //firefox - if(browser == BrowserLike.safari) { - - untyped { - js.Browser.window.webkitRequestAnimationFrame(callback); - } - - } else //safari - if(browser == BrowserLike.opera) { - - untyped { - js.Browser.window.oRequestAnimationFrame(callback); - } - - } else { //opera - - js.Browser.window.setTimeout(function(){ - callback(); - }, 16); - - } //no RAF? fall back to setTimeout for now - } -#end //lime_html5 - - public function request_render() { - - #if lime_native - lime_stage_request_render(); - #end - } - - public function render() : Bool { - - if( !lib.window.active ) { - return false; - } - - #if lime_html5 - - on_render(null); - _requestAnimFrame( lib.on_update ); - - return true; - #end - - #if lime_native - lime_render_stage( lib.view_handle ); - #end //lime_native - - return true; - } - - public function on_render(rect:Dynamic):Void { - - if( lib.host.render != null ) { - lib.host.render(); - } - - } //on_render - - -//lime functions -#if lime_native - private static var lime_get_frame_stage = Libs.load("lime","lime_get_frame_stage", 1); - private static var lime_stage_request_render = Libs.load("lime","lime_stage_request_render", 0); - private static var lime_render_stage = Libs.load("lime","lime_render_stage", 1); - private static var lime_doc_add_child = Libs.load("lime","lime_doc_add_child", 2); - private static var lime_direct_renderer_create = Libs.load("lime","lime_direct_renderer_create", 0); - private static var lime_direct_renderer_set = Libs.load("lime","lime_direct_renderer_set", 2); - private static var lime_stage_set_next_wake = Libs.load("lime","lime_stage_set_next_wake", 2); -#end //lime_native - -} - - \ No newline at end of file diff --git a/lime/WindowHandler.hx b/lime/WindowHandler.hx deleted file mode 100644 index 963650560..000000000 --- a/lime/WindowHandler.hx +++ /dev/null @@ -1,350 +0,0 @@ -package lime; - -import lime.Lime; -import lime.utils.Libs; -import lime.Constants; - - -class WindowHandler { - - public var lib : Lime; - public function new( _lib:Lime ) { lib = _lib; } - - //if the core is active - public var active : Bool = false; - //if the window is invalidated - public var invalidated : Bool = false; - //if the cursor is constrained inside the window - public var cursor_locked : Bool = false; - //if the cursor is hidden or not - public var cursor_visible : Bool = true; - - public function startup() { - - #if debug - lib._debug(':: lime :: \t WindowHandler Initializing...'); - #end //debug - - #if lime_native - - lime_create_main_frame( - - lib.on_window_ready, - lib.config.width, //width - lib.config.height, //height - //required flags - - Window.HARDWARE | - Window.ALLOW_SHADERS | - Window.REQUIRE_SHADERS | - - //optional flags - - ( lib.config.fullscreen ? Window.FULLSCREEN : 0) | - ( lib.config.borderless ? Window.BORDERLESS : 0) | - ( lib.config.resizable ? Window.RESIZABLE : 0) | - ( lib.config.antialiasing == 2 ? Window.HW_AA : 0) | - ( lib.config.antialiasing == 4 ? Window.HW_AA_HIRES : 0) | - ( lib.config.depth_buffer ? Window.DEPTH_BUFFER : 0) | - ( lib.config.stencil_buffer ? Window.STENCIL_BUFFER : 0) | - ( lib.config.vsync ? Window.VSYNC : 0), - - lib.config.title, //title - null //icon - - ); //lime_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'); - lib.on_window_ready( handle ); - } - } - - #end //lime_html5 - } - - public function shutdown() { - - #if lime_native - lime_close(); - #end - - #if debug - lib._debug(':: lime :: \t WindowHandler shut down.'); - #end //debug - } - - public function ready() { - - #if lime_native - //Fetch the stage handle - lib.view_handle = lime_get_frame_stage( lib.window_handle ); - //Make sure nothing silly is happening to the stage scale - lime_stage_set_scale_mode(lib.view_handle, 1); - //Make sure that our configs are up to date with the actual screen resolution - //not just the specified resolution in the project file - lib.config.width = lime_stage_get_stage_width(lib.view_handle); - lib.config.height = lime_stage_get_stage_height(lib.view_handle); - - //move the window based on xml flags - // if(lib.config.x != null && lib.config.y != null) { - // set_window_position(lib.config.x, lib.config.y); - // } - - //Update the touch support - lib.config.multitouch_supported = lime_stage_get_multitouch_supported(lib.view_handle); - lib.config.multitouch = true; - //Enable it if needed - lime_stage_set_multitouch_active(lib.view_handle, true); - - #end //lime_native - - } - - public function post_ready() { - - #if lime_native - //Set the stage handler for lime to send us events - lime_set_stage_handler(lib.view_handle, lib.on_lime_event, lib.config.width, lib.config.height); - #end - - #if lime_html5 - //start the run loop on html5, as there is no - //window creation callback there. - lib.render.render(); - #end - - #if debug - lib._debug(':: lime :: \t WindowHandler Initialized.'); - #end //debug - } - - //Invalidate the window (forcing a redraw on next update) - public function invalidate() : Void { - invalidated = true; - } //invalidate - - public function set_active( _active : Bool ) { - - 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 - - public function set_cursor_visible(val:Bool = true) { - - #if lime_native - if(lime_stage_show_cursor!=null) { - lime_stage_show_cursor(lib.view_handle, val); - } - #end //lime_native - - cursor_visible = val; - } - - public function constrain_cursor_to_window_frame( val:Bool = false ) { - - #if lime_native - if(lime_stage_constrain_cursor_to_window_frame!=null) { - lime_stage_constrain_cursor_to_window_frame(lib.view_handle, val); - } - #end //lime_native - - #if lime_html5 - html5_enable_pointerlock( val ); - #end //lime_html5 - - cursor_locked = val; - } - - public function set_window_position( x:Int, y:Int ) { - #if lime_native - lime_stage_set_window_position(lib.view_handle, x, y); - #end //lime_native - } - -#if lime_html5 - - //html5 api for querying html5 - private function html5_enable_pointerlock( val:Bool = false ) { - - var _normal : Bool = untyped __js__("'pointerLockElement' in document"); - var _firefox : Bool = untyped __js__("'mozPointerLockElement' in document"); - var _webkit : Bool = untyped __js__("'webkitPointerLockElement' in document"); - - if(!_normal && !_firefox && !_webkit) { - trace("Pointer lock is not supported by this browser yet, sorry!"); - return; - } - - untyped __js__(" - var _element = document.getElementById('lime_canvas'); - _element.requestPointerLock = _element.requestPointerLock || - _element.mozRequestPointerLock || - _element.webkitRequestPointerLock; - - // Ask the browser to release the pointer - _element.exitPointerLock = _element.exitPointerLock || - _element.mozExitPointerLock || - _element.webkitExitPointerLock;"); - - // Ask the browser to lock the pointer - - if(val) { - untyped __js__("if(_element.requestPointerLock) _element.requestPointerLock()"); - } else { - untyped __js__("if(_element.exitPointerLock) _element.exitPointerLock()"); - } - - } //html5_enable_pointerlock - -#end //lime_html5 - - public function set_cursor_position_in_window(_x:Int = 0, _y:Int = 0) { - #if lime_native - if(lime_stage_set_cursor_position_in_window!=null) { - lime_stage_set_cursor_position_in_window(lib.view_handle, _x, _y); - } - lib.input.last_mouse_x = _x; - lib.input.last_mouse_y = _y; - #end //lime_native - } - - public function on_redraw( _event:Dynamic ) { - // trace(_event); - lib.render.render(); - } //on_redraw - - public function on_resize(_event:Dynamic) { - - //make sure the view is informed - lib.render.on_resize(_event); - - //todo: - - //limeOnResize(_event.x, _event.y); - //if (renderRequest == null) - // limeRender(false); - } - - public function on_should_rotate( _event:Dynamic ) { - //if (shouldRotateInterface(_event.value)) - // _event.result = 2; - } //on_redraw - - public function on_focus( _event:Dynamic ) { - // trace("focus"); - // trace(_event); - } //on_focus - - //Called when the application wants to go to the background and stop - public function on_pause() { - #if lime_native - lime_pause_animation(); - #end //lime_native - } //on_pause - - //Called when the application resumes operation from the background - public function on_resume() { - #if lime_native - lime_resume_animation(); - #end //lime_native - } //on_resume - - // Terminates the process straight away, bypassing graceful shutdown - public function on_force_close() { - #if lime_native - lime_terminate(); - #end //lime_native - } //on_force_close - - public function openURL( _url:String ) { - - #if lime_native - lime_get_url( _url ); - #end //lime_native - - #if lime_html5 - - untyped __js__(' - var win = window.open( _url, "_blank" ); - win.focus(); - '); - - #end //lime_html5 - - } //openURL - - public function fileDialogOpen(_title:String, _text:String) : String { - #if lime_native - return lime_file_dialog_open(_title, _text, []); - #else - return ""; - #end - } - public function fileDialogSave(_title:String, _text:String) : String { - #if lime_native - return lime_file_dialog_save(_title, _text, []); - #else - return ""; - #end - } - public function fileDialogFolder(_title:String, _text:String) : String { - #if lime_native - return lime_file_dialog_folder(_title, _text); - #else - return ""; - #end - } - -//lime functions -#if lime_native - private static var lime_stage_set_scale_mode = Libs.load ("lime", "lime_stage_set_scale_mode", 2); - private static var lime_stage_get_stage_width = Libs.load("lime","lime_stage_get_stage_width", 1); - private static var lime_stage_get_stage_height = Libs.load("lime","lime_stage_get_stage_height", 1); - private static var lime_set_stage_handler = Libs.load("lime","lime_set_stage_handler", 4); - private static var lime_get_frame_stage = Libs.load("lime","lime_get_frame_stage", 1); - private static var lime_create_main_frame = Libs.load("lime","lime_create_main_frame", -1); - private static var lime_pause_animation = Libs.load("lime","lime_pause_animation", 0); - private static var lime_resume_animation = Libs.load("lime","lime_resume_animation", 0); - private static var lime_terminate = Libs.load("lime","lime_terminate", 0); - private static var lime_close = Libs.load("lime","lime_close", 0); - private static var lime_get_url = Libs.load("lime","lime_get_url", 1); - - //File Dialogs - private static var lime_file_dialog_save = Libs.load("lime", "lime_file_dialog_save", 3); - private static var lime_file_dialog_open = Libs.load("lime", "lime_file_dialog_open", 3); - private static var lime_file_dialog_folder = Libs.load("lime", "lime_file_dialog_folder", 2); - - //Cursor and window control (desktop only obviously) - private static var lime_stage_set_window_position = Libs.load("lime","lime_stage_set_window_position", 3); - private static var lime_stage_show_cursor = Libs.load("lime","lime_stage_show_cursor", 2); - private static var lime_stage_constrain_cursor_to_window_frame = Libs.load("lime","lime_stage_constrain_cursor_to_window_frame", 2); - private static var lime_stage_set_cursor_position_in_window = Libs.load("lime","lime_stage_set_cursor_position_in_window", 3); - - //Multitouch - private static var lime_stage_get_multitouch_supported = Libs.load("lime","lime_stage_get_multitouch_supported", 1); - private static var lime_stage_set_multitouch_active = Libs.load("lime","lime_stage_set_multitouch_active", 2); - -#end //lime_native - -} \ No newline at end of file diff --git a/lime/about_lime_wrapper.md b/lime/about_lime_wrapper.md deleted file mode 100644 index bf0bbda39..000000000 --- a/lime/about_lime_wrapper.md +++ /dev/null @@ -1,59 +0,0 @@ -##What it the lime wrapper? ---- - -The lime wrapper handles creating the window, forwarding events from the window, and giving you access to an external API that allows you to access the lime features across platforms. - -For example - on html5 - it will handle the canvas creation, run loop, and provide an api like `lime.audio.create` or `lime.input.keydown` allowing you to access the features in a consistent way. - ---- - -##Structure - -The lime wrapper consistents of : - -- **Lime.hx** - - the main entry point, and bootstrapper -- ***feature***Handler.hx - - The _feature_ handler, which implements the internal and external API -- **helpers/** - - helpers to define enums, values or types and to convert values to and from the types. - - Also where the implementation for specific platforms is held, if needed -- **gl/** - - The OpenGL bindings api, based directly on the WebGL spec -- **utils/** - - common and cross platform variations of the utility classes - -  - ---- - -##Bootstrapped? - -Traditionally [bootstrapping](https://en.wikipedia.org/wiki/Bootstrapping) is characterized by a few things, but specifically in our case : - ->The process involves a chain of stages, in which at each stage a smaller simpler program loads and then executes the larger more complicated program of the next stage. - -This is exactly the purpose of the lime wrapper, it is light weight, low level, to the point. It picks itself up by the bootstraps, and directly executes your application with end points that allow you to communicate with the bindings. - -The flow is simple, lime starts, handles any setup necessary, and immediately calls ready. Whenever an event arrives from the system, it tells your application directly. Imagine it like strapping your application on top of the wrapper, filling in the handlers for the events you want to know about. - ---- - -##Feature details - -###native -When the term native is used, it refers to the cpp targets, such as _mac_, _windows_, _linux_, _tizen_, _android_, _iOS_, and so on. - -- Audio - Handled by OpenAL on all platforms -- Input - Handled by SDL and lime native code -- Windowing - Handled by SDL and lime native code -- Rendering - OpenGL exposed via the wrapper as WebGL - -###html5 -When the term html5 is used, it refers directly to the WebGL implementation of the lime wrapper. - -- Audio - Handled by the lime wrapper through [SoundManager 2](http://www.schillmania.com/projects/soundmanager2/) -- Input - Handled by the lime wrapper -- Windowing - Handled by the lime wrapper -- Rendering - WebGL exposed via the wrapper - diff --git a/lime/app/Application.hx b/lime/app/Application.hx new file mode 100644 index 000000000..2537c6445 --- /dev/null +++ b/lime/app/Application.hx @@ -0,0 +1,75 @@ +package lime.app; + + +import lime.ui.IMouseEventListener; +import lime.ui.ITouchEventListener; +import lime.ui.MouseEvent; +import lime.ui.TouchEvent; +import lime.system.System; + + +class Application implements IMouseEventListener implements ITouchEventListener { + + + public var handle:Dynamic; + + + public function new () { + + + + } + + + public function create (config:Config) { + + #if (cpp || neko) + handle = lime_application_create (); + #end + + var window = new Window (this); + var renderer = new Renderer (window); + + } + + + public function exec () { + + #if (cpp || neko) + return lime_application_exec (handle); + #end + + } + + + public function onMouseDown (event:MouseEvent):Void {} + public function onMouseMove (event:MouseEvent):Void {} + public function onMouseUp (event:MouseEvent):Void {} + public function onTouchEnd (event:TouchEvent):Void {} + public function onTouchMove (event:TouchEvent):Void {} + public function onTouchStart (event:TouchEvent):Void {} + + + + public function render ():Void { + + + + } + + + public function update ():Void { + + + + } + + + + #if (cpp || neko) + private static var lime_application_create = System.load ("lime", "lime_application_create", 0); + private static var lime_application_exec = System.load ("lime", "lime_application_exec", 1); + #end + + +} \ No newline at end of file diff --git a/lime/app/Config.hx b/lime/app/Config.hx new file mode 100644 index 000000000..62565c284 --- /dev/null +++ b/lime/app/Config.hx @@ -0,0 +1,19 @@ +package lime.app; + + +typedef Config = { + + @:optional var antialiasing:Int; + @:optional var borderless:Bool; + @:optional var depthBuffer:Bool; + @:optional var fps:Int; + @:optional var fullscreen:Bool; + @:optional var height:Int; + @:optional var orientation:String; + @:optional var resizable:Bool; + @:optional var stencilBuffer:Bool; + @:optional var title:String; + @:optional var vsync:Bool; + @:optional var width:Int; + +} \ No newline at end of file diff --git a/lime/app/Renderer.hx b/lime/app/Renderer.hx new file mode 100644 index 000000000..a8b8194c4 --- /dev/null +++ b/lime/app/Renderer.hx @@ -0,0 +1,27 @@ +package lime.app; + + +import lime.system.System; + + +class Renderer { + + + public var handle:Dynamic; + + + public function new (window:Window) { + + #if (cpp || neko) + handle = lime_renderer_create (window.handle); + #end + + } + + + #if (cpp || neko) + private static var lime_renderer_create = System.load ("lime", "lime_renderer_create", 1); + #end + + +} \ No newline at end of file diff --git a/lime/app/Window.hx b/lime/app/Window.hx new file mode 100644 index 000000000..2d00758a4 --- /dev/null +++ b/lime/app/Window.hx @@ -0,0 +1,27 @@ +package lime.app; + + +import lime.system.System; + + +class Window { + + + public var handle:Dynamic; + + + public function new (application:Application) { + + #if (cpp || neko) + handle = lime_window_create (application.handle); + #end + + } + + + #if (cpp || neko) + private static var lime_window_create = System.load ("lime", "lime_window_create", 1); + #end + + +} \ No newline at end of file diff --git a/lime/gl/GL.hx b/lime/gl/GL.hx deleted file mode 100644 index 1fbf643c6..000000000 --- a/lime/gl/GL.hx +++ /dev/null @@ -1,9 +0,0 @@ -package lime.gl; - -#if lime_html5 - typedef GL = lime.gl.html5.GL; - typedef Ext = lime.gl.html5.Ext; -#else - typedef GL = lime.gl.native.GL; - typedef Ext = lime.gl.native.Ext; -#end //lime_html5 \ No newline at end of file diff --git a/lime/gl/GLActiveInfo.hx b/lime/gl/GLActiveInfo.hx deleted file mode 100644 index 08fbf7afe..000000000 --- a/lime/gl/GLActiveInfo.hx +++ /dev/null @@ -1,17 +0,0 @@ -package lime.gl; - -#if lime_html5 - - typedef GLActiveInfo = js.html.webgl.ActiveInfo; - -#else - - typedef GLActiveInfo = { - - size : Int, - type : Int, - name : String, - - }; - -#end //lime_html5 \ No newline at end of file diff --git a/lime/gl/GLBuffer.hx b/lime/gl/GLBuffer.hx deleted file mode 100644 index e635a4a63..000000000 --- a/lime/gl/GLBuffer.hx +++ /dev/null @@ -1,18 +0,0 @@ -package lime.gl; - -#if lime_html5 - - typedef GLBuffer = js.html.webgl.Buffer; - -#else - - class GLBuffer extends GLObject { - public function new (version:Int, id:Dynamic) { - super (version, id); - } - override function getType ():String { - return "Buffer"; - } - } - -#end //lime_html5 \ No newline at end of file diff --git a/lime/gl/GLContextAttributes.hx b/lime/gl/GLContextAttributes.hx deleted file mode 100644 index e5a6cb8b1..000000000 --- a/lime/gl/GLContextAttributes.hx +++ /dev/null @@ -1,20 +0,0 @@ -package lime.gl; - -#if lime_html5 - - typedef GLContextAttributes = js.html.webgl.ContextAttributes; - -#else - - typedef GLContextAttributes = { - - alpha:Bool, - depth:Bool, - stencil:Bool, - antialias:Bool, - premultipliedAlpha:Bool, - preserveDrawingBuffer:Bool, - - }; - -#end //lime_html5 \ No newline at end of file diff --git a/lime/gl/GLFramebuffer.hx b/lime/gl/GLFramebuffer.hx deleted file mode 100644 index 331c00567..000000000 --- a/lime/gl/GLFramebuffer.hx +++ /dev/null @@ -1,23 +0,0 @@ -package lime.gl; - - -#if lime_html5 - - typedef GLFramebuffer = js.html.webgl.Framebuffer; - -#else - - class GLFramebuffer extends GLObject { - - public function new (version:Int, id:Dynamic) { - super (version, id); - } - - override function getType ():String { - return "Framebuffer"; - } - - } //GLFramebuffer - - -#end //lime_html5 \ No newline at end of file diff --git a/lime/gl/GLObject.hx b/lime/gl/GLObject.hx deleted file mode 100644 index 32731d81d..000000000 --- a/lime/gl/GLObject.hx +++ /dev/null @@ -1,57 +0,0 @@ -package lime.gl; - - -#if lime_html5 - - typedef GLObject = Dynamic; - -#else //lime_html5 - - class GLObject { - - public var id : 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 diff --git a/lime/gl/GLProgram.hx b/lime/gl/GLProgram.hx deleted file mode 100644 index cba91aa72..000000000 --- a/lime/gl/GLProgram.hx +++ /dev/null @@ -1,33 +0,0 @@ -package lime.gl; - - - -#if lime_html5 - - typedef GLProgram = js.html.webgl.Program; - -#else //lime_html5 - - class GLProgram extends GLObject { - - 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"; - } - } - -#end //lime_native diff --git a/lime/gl/GLRenderbuffer.hx b/lime/gl/GLRenderbuffer.hx deleted file mode 100644 index 902db21c2..000000000 --- a/lime/gl/GLRenderbuffer.hx +++ /dev/null @@ -1,22 +0,0 @@ -package lime.gl; - -#if lime_html5 - - typedef GLRenderbuffer = js.html.webgl.Renderbuffer; - -#else //lime_html5 - - class GLRenderbuffer extends GLObject { - - public function new (version:Int, id:Dynamic) { - super (version, id); - } - - override private function getType ():String { - return "Renderbuffer"; - } - - } - -#end //lime_native - diff --git a/lime/gl/GLShader.hx b/lime/gl/GLShader.hx deleted file mode 100644 index 776ecc883..000000000 --- a/lime/gl/GLShader.hx +++ /dev/null @@ -1,23 +0,0 @@ -package lime.gl; - - -#if lime_html5 - - typedef GLShader = js.html.webgl.Shader; - -#else //lime_html5 - - class GLShader extends GLObject { - - public function new (version:Int, id:Dynamic) { - super (version, id); - } - - override private function getType ():String { - return "Shader"; - } - - } - -#end //lime_native - diff --git a/lime/gl/GLTexture.hx b/lime/gl/GLTexture.hx deleted file mode 100644 index d86edeac8..000000000 --- a/lime/gl/GLTexture.hx +++ /dev/null @@ -1,24 +0,0 @@ -package lime.gl; - - -#if lime_html5 - - typedef GLTexture = js.html.webgl.Texture; - -#else //lime_html5 - - class GLTexture extends GLObject { - - public function new (version:Int, id:Dynamic) { - super (version, id); - } - - override private function getType ():String { - return "Texture"; - } - - } - -#end //lime_native - - diff --git a/lime/gl/GLUniformLocation.hx b/lime/gl/GLUniformLocation.hx deleted file mode 100644 index 505972147..000000000 --- a/lime/gl/GLUniformLocation.hx +++ /dev/null @@ -1,12 +0,0 @@ -package lime.gl; - -#if lime_html5 - - typedef GLUniformLocation = js.html.webgl.UniformLocation; - -#else //lime_html5 - - typedef GLUniformLocation = Dynamic; - -#end //lime_native - diff --git a/lime/gl/html5/Ext.hx b/lime/gl/html5/Ext.hx deleted file mode 100644 index 5dd32585d..000000000 --- a/lime/gl/html5/Ext.hx +++ /dev/null @@ -1,60 +0,0 @@ -package lime.gl.html5; - - -class Ext { - - public static function drawBuffers( n:Int, buffers:Int ){ - - if(ext_draw_buffers == null) { - ext_draw_buffers = GL.getExtension('EXT_draw_buffers'); - if(ext_draw_buffers == null) { - ext_draw_buffers = GL.getExtension('WEBGL_draw_buffers'); - if(ext_draw_buffers == null) { - throw "Attemping to use GL.Ext.drawBuffers when it is not found in this browser."; - } - } - } - - return ext_draw_buffers( n, buffers ); - } - - public static inline var COLOR_ATTACHMENT0 = 0x8CE0; - public static inline var COLOR_ATTACHMENT1 = 0x8CE1; - public static inline var COLOR_ATTACHMENT2 = 0x8CE2; - public static inline var COLOR_ATTACHMENT3 = 0x8CE3; - public static inline var COLOR_ATTACHMENT4 = 0x8CE4; - public static inline var COLOR_ATTACHMENT5 = 0x8CE5; - public static inline var COLOR_ATTACHMENT6 = 0x8CE6; - public static inline var COLOR_ATTACHMENT7 = 0x8CE7; - public static inline var COLOR_ATTACHMENT8 = 0x8CE8; - public static inline var COLOR_ATTACHMENT9 = 0x8CE9; - public static inline var COLOR_ATTACHMENT10 = 0x8CEA; - public static inline var COLOR_ATTACHMENT11 = 0x8CEB; - public static inline var COLOR_ATTACHMENT12 = 0x8CEC; - public static inline var COLOR_ATTACHMENT13 = 0x8CED; - public static inline var COLOR_ATTACHMENT14 = 0x8CEE; - public static inline var COLOR_ATTACHMENT15 = 0x8CEF; - - public static inline var DRAW_BUFFER0 = 0x8825; - public static inline var DRAW_BUFFER1 = 0x8826; - public static inline var DRAW_BUFFER2 = 0x8827; - public static inline var DRAW_BUFFER3 = 0x8828; - public static inline var DRAW_BUFFER4 = 0x8829; - public static inline var DRAW_BUFFER5 = 0x882A; - public static inline var DRAW_BUFFER6 = 0x882B; - public static inline var DRAW_BUFFER7 = 0x882C; - public static inline var DRAW_BUFFER8 = 0x882D; - public static inline var DRAW_BUFFER9 = 0x882E; - public static inline var DRAW_BUFFER10 = 0x882F; - public static inline var DRAW_BUFFER11 = 0x8830; - public static inline var DRAW_BUFFER12 = 0x8831; - public static inline var DRAW_BUFFER13 = 0x8832; - public static inline var DRAW_BUFFER14 = 0x8833; - public static inline var DRAW_BUFFER15 = 0x8834; - - public static inline var MAX_COLOR_ATTACHMENTS = 0x8CDF; - public static inline var MAX_DRAW_BUFFERS = 0x8824; - - private static var ext_draw_buffers : Dynamic = null; -} - diff --git a/lime/gl/html5/GL.hx b/lime/gl/html5/GL.hx deleted file mode 100644 index 8e67e716f..000000000 --- a/lime/gl/html5/GL.hx +++ /dev/null @@ -1,1457 +0,0 @@ -package lime.gl.html5; - -// import flash.display.BitmapData; -import lime.utils.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 limeContext:RenderingContext; - - - - public static function activeTexture(texture:Int):Void { - - limeContext.activeTexture(texture); - - } - - - public static function attachShader(program:GLProgram, shader:GLShader):Void { - - limeContext.attachShader(program, shader); - - } - - - public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void { - - limeContext.bindAttribLocation(program, index, name); - - } - -/* - public static function bindBitmapDataTexture(texture:BitmapData):Void { - - if (texture.limeGLTexture == null) { - - texture.limeGLTexture = limeContext.createTexture(); - limeContext.bindTexture(TEXTURE_2D, texture.limeGLTexture); - - limeContext.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE); - limeContext.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE); - limeContext.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST); - limeContext.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST); - - texture.lock(); - limeContext.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, texture.limeImageData); - texture.unlock(); - - } else { - - limeContext.bindTexture(TEXTURE_2D, texture.limeGLTexture); - - } - - } -*/ - - public static function bindBuffer(target:Int, buffer:GLBuffer):Void { - - limeContext.bindBuffer(target, buffer); - - } - - - public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void { - - limeContext.bindFramebuffer(target, framebuffer); - - } - - - public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void { - - limeContext.bindRenderbuffer(target, renderbuffer); - - } - - - public static function bindTexture(target:Int, texture:GLTexture):Void { - - limeContext.bindTexture(target, texture); - - } - - - public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void { - - limeContext.blendColor(red, green, blue, alpha); - - } - - - public static function blendEquation(mode:Int):Void { - - limeContext.blendEquation(mode); - - } - - - public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void { - - limeContext.blendEquationSeparate(modeRGB, modeAlpha); - - } - - - public static function blendFunc(sfactor:Int, dfactor:Int):Void { - - limeContext.blendFunc(sfactor, dfactor); - - } - - - public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void { - - limeContext.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 { - - limeContext.bufferData(target, data, usage); - - } - - - public static function bufferSubData(target:Int, offset:Int, data:ArrayBufferView):Void { - - limeContext.bufferSubData(target, offset, data); - - } - - - public static function checkFramebufferStatus(target:Int):Int { - - return limeContext.checkFramebufferStatus(target); - - } - - - public static function clear(mask:Int):Void { - - limeContext.clear(mask); - - } - - - public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void { - - limeContext.clearColor(red, green, blue, alpha); - - } - - - public static function clearDepth(depth:Float):Void { - - limeContext.clearDepth(depth); - - } - - - public static function clearStencil(s:Int):Void { - - limeContext.clearStencil(s); - - } - - - public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void { - - limeContext.colorMask(red, green, blue, alpha); - - } - - - public static function compileShader(shader:GLShader):Void { - - limeContext.compileShader(shader); - - } - - - public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:ArrayBufferView):Void { - - limeContext.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 { - - limeContext.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 { - - limeContext.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 { - - limeContext.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); - - } - - - public static function createBuffer():GLBuffer { - - return limeContext.createBuffer(); - - } - - - public static function createFramebuffer():GLFramebuffer { - - return limeContext.createFramebuffer(); - - } - - - public static function createProgram():GLProgram { - - return limeContext.createProgram(); - - } - - - public static function createRenderbuffer():GLRenderbuffer { - - return limeContext.createRenderbuffer(); - - } - - - public static function createShader(type:Int):GLShader { - - return limeContext.createShader(type); - - } - - - public static function createTexture():GLTexture { - - return limeContext.createTexture(); - - } - - - public static function cullFace(mode:Int):Void { - - limeContext.cullFace(mode); - - } - - - public static function deleteBuffer(buffer:GLBuffer):Void { - - limeContext.deleteBuffer(buffer); - - } - - - public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void { - - limeContext.deleteFramebuffer(framebuffer); - - } - - - public static function deleteProgram(program:GLProgram):Void { - - limeContext.deleteProgram(program); - - } - - - public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void { - - limeContext.deleteRenderbuffer(renderbuffer); - - } - - - public static function deleteShader(shader:GLShader):Void { - - limeContext.deleteShader(shader); - - } - - - public static function deleteTexture(texture:GLTexture):Void { - - limeContext.deleteTexture(texture); - - } - - - public static function depthFunc(func:Int):Void { - - limeContext.depthFunc(func); - - } - - - public static function depthMask(flag:Bool):Void { - - limeContext.depthMask(flag); - - } - - - public static function depthRange(zNear:Float, zFar:Float):Void { - - limeContext.depthRange(zNear, zFar); - - } - - - public static function detachShader(program:GLProgram, shader:GLShader):Void { - - limeContext.detachShader(program, shader); - - } - - - public static function disable(cap:Int):Void { - - limeContext.disable(cap); - - } - - - public static function disableVertexAttribArray(index:Int):Void { - - limeContext.disableVertexAttribArray(index); - - } - - - public static function drawArrays(mode:Int, first:Int, count:Int):Void { - - limeContext.drawArrays(mode, first, count); - - } - - - public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void { - - limeContext.drawElements(mode, count, type, offset); - - } - - - public static function enable(cap:Int):Void { - - limeContext.enable(cap); - - } - - - public static function enableVertexAttribArray(index:Int):Void { - - limeContext.enableVertexAttribArray(index); - - } - - - public static function finish():Void { - - limeContext.finish(); - - } - - - public static function flush():Void { - - limeContext.flush(); - - } - - - public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void { - - limeContext.framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); - - } - - - public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void { - - limeContext.framebufferTexture2D(target, attachment, textarget, texture, level); - - } - - - public static function frontFace(mode:Int):Void { - - limeContext.frontFace(mode); - - } - - - public static function generateMipmap(target:Int):Void { - - limeContext.generateMipmap(target); - - } - - - public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo { - - return limeContext.getActiveAttrib(program, index); - - } - - - public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo { - - return limeContext.getActiveUniform(program, index); - - } - - - public static function getAttachedShaders(program:GLProgram):Array { - - return limeContext.getAttachedShaders(program); - - } - - - public static function getAttribLocation(program:GLProgram, name:String):Int { - - return limeContext.getAttribLocation(program, name); - - } - - - public static function getBufferParameter(target:Int, pname:Int):Dynamic { - - return limeContext.getBufferParameter(target, pname); - - } - - - public static function getContextAttributes():GLContextAttributes { - - return limeContext.getContextAttributes(); - - } - - - public static function getError():Int { - - return limeContext.getError(); - - } - - - public static function getExtension(name:String):Dynamic { - - return limeContext.getExtension(name); - - } - - - public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic { - - return limeContext.getFramebufferAttachmentParameter(target, attachment, pname); - - } - - - public static function getParameter(pname:Int):Dynamic { - - return limeContext.getParameter(pname); - - } - - - public static function getProgramInfoLog(program:GLProgram):String { - - return limeContext.getProgramInfoLog(program); - - } - - - public static function getProgramParameter(program:GLProgram, pname:Int):Int { - - return limeContext.getProgramParameter(program, pname); - - } - - - public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic { - - return limeContext.getRenderbufferParameter(target, pname); - - } - - - public static function getShaderInfoLog(shader:GLShader):String { - - return limeContext.getShaderInfoLog(shader); - - } - - - public static function getShaderParameter(shader:GLShader, pname:Int):Int { - - return limeContext.getShaderParameter(shader, pname); - - } - - - public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat { - - // TODO - - return null; - //return limeContext.getShader - - } - - - public static function getShaderSource(shader:GLShader):String { - - return limeContext.getShaderSource(shader); - - } - - - public static function getSupportedExtensions():Array { - - // TODO - - return null; - //return limeContext.getSuppo - - } - - - public static function getTexParameter(target:Int, pname:Int):Dynamic { - - return limeContext.getTexParameter(target, pname); - - } - - - public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic { - - return limeContext.getUniform(program, location); - - } - - - public static function getUniformLocation(program:GLProgram, name:String):GLUniformLocation { - - return limeContext.getUniformLocation(program, name); - - } - - - public static function getVertexAttrib(index:Int, pname:Int):Dynamic { - - return limeContext.getVertexAttrib(index, pname); - - } - - - public static function getVertexAttribOffset(index:Int, pname:Int):Int { - - return limeContext.getVertexAttribOffset(index, pname); - - } - - - public static function hint(target:Int, mode:Int):Void { - - limeContext.hint(target, mode); - - } - - - public static function isBuffer(buffer:GLBuffer):Bool { - - return limeContext.isBuffer(buffer); - - } - - - // This is non-static - // public function isContextLost():Bool { return false; } - - - public static function isEnabled(cap:Int):Bool { - - return limeContext.isEnabled(cap); - - } - - - public static function isFramebuffer(framebuffer:GLFramebuffer):Bool { - - return limeContext.isFramebuffer(framebuffer); - - } - - - public static function isProgram(program:GLProgram):Bool { - - return limeContext.isProgram(program); - - } - - - public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool { - - return limeContext.isRenderbuffer(renderbuffer); - - } - - - public static function isShader(shader:GLShader):Bool { - - return limeContext.isShader(shader); - - } - - - public static function isTexture(texture:GLTexture):Bool { - - return limeContext.isTexture(texture); - - } - - - public static function lineWidth(width:Float):Void { - - limeContext.lineWidth(width); - - } - - - public static function linkProgram(program:GLProgram):Void { - - limeContext.linkProgram(program); - - } - - - public static function pixelStorei(pname:Int, param:Int):Void { - - limeContext.pixelStorei(pname, param); - - } - - - public static function polygonOffset(factor:Float, units:Float):Void { - - limeContext.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});) - - limeContext.readPixels(x, y, width, height, format, type, pixels); - - } - - - public static function renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void { - - limeContext.renderbufferStorage(target, internalformat, width, height); - - } - - - public static function sampleCoverage(value:Float, invert:Bool):Void { - - limeContext.sampleCoverage(value, invert); - - } - - - public static function scissor(x:Int, y:Int, width:Int, height:Int):Void { - - limeContext.scissor(x, y, width, height); - - } - - - public static function shaderSource(shader:GLShader, source:String):Void { - - limeContext.shaderSource(shader, source); - - } - - - public static function stencilFunc(func:Int, ref:Int, mask:Int):Void { - - limeContext.stencilFunc(func, ref, mask); - - } - - - public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void { - - limeContext.stencilFuncSeparate(face, func, ref, mask); - - } - - - public static function stencilMask(mask:Int):Void { - - limeContext.stencilMask(mask); - - } - - - public static function stencilMaskSeparate(face:Int, mask:Int):Void { - - limeContext.stencilMaskSeparate(face, mask); - - } - - - public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void { - - limeContext.stencilOp(fail, zfail, zpass); - - } - - - public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void { - - limeContext.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 { - - limeContext.texImage2D(target, level, internalformat, width, height, border, format, type, pixels); - - } - - - public static function texParameterf(target:Int, pname:Int, param:Float):Void { - - limeContext.texParameterf(target, pname, param); - - } - - - public static function texParameteri(target:Int, pname:Int, param:Int):Void { - - limeContext.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 { - - limeContext.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); - - } - - - public static function uniform1f(location:GLUniformLocation, x:Float):Void { - - limeContext.uniform1f(location, x); - - } - - - public static function uniform1fv(location:GLUniformLocation, x:Float32Array):Void { - - limeContext.uniform1fv(location, x); - - } - - - public static function uniform1i(location:GLUniformLocation, x:Int):Void { - - limeContext.uniform1i(location, x); - - } - - - public static function uniform1iv(location:GLUniformLocation, v:Int32Array):Void { - - limeContext.uniform1iv(location, v); - - } - - - public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void { - - limeContext.uniform2f(location, x, y); - - } - - - public static function uniform2fv(location:GLUniformLocation, v:Float32Array):Void { - - limeContext.uniform2fv(location, v); - - } - - - public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void { - - limeContext.uniform2i(location, x, y); - - } - - - public static function uniform2iv(location:GLUniformLocation, v:Int32Array):Void { - - limeContext.uniform2iv(location, v); - - } - - - public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void { - - limeContext.uniform3f(location, x, y, z); - - } - - - public static function uniform3fv(location:GLUniformLocation, v:Float32Array):Void { - - limeContext.uniform3fv(location, v); - - } - - - public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void { - - limeContext.uniform3i(location, x, y, z); - - } - - - public static function uniform3iv(location:GLUniformLocation, v:Int32Array):Void { - - limeContext.uniform3iv(location, v); - - } - - - public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void { - - limeContext.uniform4f(location, x, y, z, w); - - } - - - public static function uniform4fv(location:GLUniformLocation, v:Float32Array):Void { - - limeContext.uniform4fv(location, v); - - } - - - public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void { - - limeContext.uniform4i(location, x, y, z, w); - - } - - - public static function uniform4iv(location:GLUniformLocation, v:Int32Array):Void { - - limeContext.uniform4iv(location, v); - - } - - - public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { - - limeContext.uniformMatrix2fv(location, transpose, v); - - } - - - public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { - - limeContext.uniformMatrix3fv(location, transpose, v); - - } - - - public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { - - limeContext.uniformMatrix4fv(location, transpose, v); - - } - - - public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void { - - limeContext.uniformMatrix4fv(location, transpose, new Float32Array(matrix.rawData)); - - } - - - public static function useProgram(program:GLProgram):Void { - - limeContext.useProgram(program); - - } - - - public static function validateProgram(program:GLProgram):Void { - - limeContext.validateProgram(program); - - } - - - public static function vertexAttrib1f(indx:Int, x:Float):Void { - - limeContext.vertexAttrib1f(indx, x); - - } - - - public static function vertexAttrib1fv(indx:Int, values:Float32Array):Void { - - limeContext.vertexAttrib1fv(indx, values); - - } - - - public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void { - - limeContext.vertexAttrib2f(indx, x, y); - - } - - - public static function vertexAttrib2fv(indx:Int, values:Float32Array):Void { - - limeContext.vertexAttrib2fv(indx, values); - - } - - - public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void { - - limeContext.vertexAttrib3f(indx, x, y, z); - - } - - - public static function vertexAttrib3fv(indx:Int, values:Float32Array):Void { - - limeContext.vertexAttrib3fv(indx, values); - - } - - - public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void { - - limeContext.vertexAttrib4f(indx, x, y, z, w); - - } - - - public static function vertexAttrib4fv(indx:Int, values:Float32Array):Void { - - limeContext.vertexAttrib4fv(indx, values); - - } - - - public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void { - - limeContext.vertexAttribPointer(indx, size, type, normalized, stride, offset); - - } - - - public static function viewport(x:Int, y:Int, width:Int, height:Int):Void { - - limeContext.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, - -}; - diff --git a/lime/gl/native/Ext.hx b/lime/gl/native/Ext.hx deleted file mode 100644 index 45f1e7a41..000000000 --- a/lime/gl/native/Ext.hx +++ /dev/null @@ -1,63 +0,0 @@ -package lime.gl.native; - -import lime.utils.Libs; - -class Ext { - - public static function drawBuffers( n:Int, buffers:Int ){ - #if luxe_gl_extensions - return lime_gl_ext_draw_buffers( n, buffers ); - #end - } - - private static function load(inName:String, inArgCount:Int):Dynamic { - try { - return Libs.load("lime", inName, inArgCount); - } catch(e:Dynamic) { - trace(e); return null; - } - } //load - - public static inline var COLOR_ATTACHMENT0 = 0x8CE0; - public static inline var COLOR_ATTACHMENT1 = 0x8CE1; - public static inline var COLOR_ATTACHMENT2 = 0x8CE2; - public static inline var COLOR_ATTACHMENT3 = 0x8CE3; - public static inline var COLOR_ATTACHMENT4 = 0x8CE4; - public static inline var COLOR_ATTACHMENT5 = 0x8CE5; - public static inline var COLOR_ATTACHMENT6 = 0x8CE6; - public static inline var COLOR_ATTACHMENT7 = 0x8CE7; - public static inline var COLOR_ATTACHMENT8 = 0x8CE8; - public static inline var COLOR_ATTACHMENT9 = 0x8CE9; - public static inline var COLOR_ATTACHMENT10 = 0x8CEA; - public static inline var COLOR_ATTACHMENT11 = 0x8CEB; - public static inline var COLOR_ATTACHMENT12 = 0x8CEC; - public static inline var COLOR_ATTACHMENT13 = 0x8CED; - public static inline var COLOR_ATTACHMENT14 = 0x8CEE; - public static inline var COLOR_ATTACHMENT15 = 0x8CEF; - - public static inline var DRAW_BUFFER0 = 0x8825; - public static inline var DRAW_BUFFER1 = 0x8826; - public static inline var DRAW_BUFFER2 = 0x8827; - public static inline var DRAW_BUFFER3 = 0x8828; - public static inline var DRAW_BUFFER4 = 0x8829; - public static inline var DRAW_BUFFER5 = 0x882A; - public static inline var DRAW_BUFFER6 = 0x882B; - public static inline var DRAW_BUFFER7 = 0x882C; - public static inline var DRAW_BUFFER8 = 0x882D; - public static inline var DRAW_BUFFER9 = 0x882E; - public static inline var DRAW_BUFFER10 = 0x882F; - public static inline var DRAW_BUFFER11 = 0x8830; - public static inline var DRAW_BUFFER12 = 0x8831; - public static inline var DRAW_BUFFER13 = 0x8832; - public static inline var DRAW_BUFFER14 = 0x8833; - public static inline var DRAW_BUFFER15 = 0x8834; - - public static inline var MAX_COLOR_ATTACHMENTS = 0x8CDF; - public static inline var MAX_DRAW_BUFFERS = 0x8824; - -#if luxe_gl_extensions - private static var lime_gl_ext_draw_buffers = load("lime_gl_ext_draw_buffers", 2); -#end - -} - diff --git a/lime/gl/native/GL.hx b/lime/gl/native/GL.hx deleted file mode 100644 index 7240be58d..000000000 --- a/lime/gl/native/GL.hx +++ /dev/null @@ -1,1330 +0,0 @@ -package lime.gl.native; - -import lime.utils.Libs; -import lime.utils.Matrix3D; -import lime.utils.ArrayBuffer; -import lime.utils.ArrayBufferView; -import lime.utils.Float32Array; -import lime.utils.IMemoryRange; - -abstract LimeFloats(Dynamic) { - - public inline function new(d:Dynamic) { - this = d; - } - - @:to inline function toDynamic() { - return this; - } - - @:from inline static function fromFloat32Array( f:Float32Array ) { - return new LimeFloats(f.getByteBuffer()); - } - - @:from inline static function fromArrayFloat( f:Array ) { - return new LimeFloats(f); - } - -} //LimeFloats - -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 { lime_gl_active_texture(texture); } - - public static function attachShader(program:GLProgram, shader:GLShader):Void - { - program.attach(shader); - lime_gl_attach_shader(program.id, shader.id); - } - - public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void - { - lime_gl_bind_attrib_location(program.id, index, name); - } - - //note : This is flash api specific for nme/openfl and is not required for lime, - //but we can shield it out, except lime_native will be defined at all times - //so we need a cleaner way - // public static function bindBitmapDataTexture(texture:BitmapData):Void - // { - // lime_gl_bind_bitmap_data_texture(texture.__handle); - // } - - public static function bindBuffer(target:Int, buffer:GLBuffer):Void - { - lime_gl_bind_buffer(target, buffer == null ? null : buffer.id); - } - - public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void - { - lime_gl_bind_framebuffer(target, framebuffer == null ? null : framebuffer.id); - } - - public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void - { - lime_gl_bind_renderbuffer(target, renderbuffer == null ? null : renderbuffer.id); - } - - public static function bindTexture(target:Int, texture:GLTexture):Void - { - lime_gl_bind_texture(target, texture == null ? null : texture.id); - } - - public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void - { - lime_gl_blend_color(red, green, blue, alpha); - } - - public static function blendEquation(mode:Int):Void - { - lime_gl_blend_equation(mode); - } - - public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void - { - lime_gl_blend_equation_separate(modeRGB, modeAlpha); - } - - public static function blendFunc(sfactor:Int, dfactor:Int):Void - { - lime_gl_blend_func(sfactor, dfactor); - } - - public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void - { - lime_gl_blend_func_separate(srcRGB, dstRGB, srcAlpha, dstAlpha); - } - - public static function bufferData(target:Int, data:IMemoryRange, usage:Int):Void - { - lime_gl_buffer_data(target, data.getByteBuffer(), data.getStart(), data.getLength(), usage); - } - - public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange ):Void - { - lime_gl_buffer_sub_data( target, offset, data.getByteBuffer(), data.getStart(), data.getLength() ); - } - - public static function checkFramebufferStatus(target:Int):Int - { - return lime_gl_check_framebuffer_status(target); - } - - public static function clear(mask:Int):Void - { - lime_gl_clear(mask); - } - - public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void - { - lime_gl_clear_color(red, green, blue, alpha); - } - - public static function clearDepth(depth:Float):Void - { - lime_gl_clear_depth(depth); - } - - public static function clearStencil(s:Int):Void - { - lime_gl_clear_stencil(s); - } - - public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void - { - lime_gl_color_mask(red, green, blue, alpha); - } - - public static function compileShader(shader:GLShader):Void - { - lime_gl_compile_shader(shader.id); - } - - public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:IMemoryRange):Void - { - lime_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 - { - lime_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 - { - lime_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 - { - lime_gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height); - } - - public static function createBuffer():GLBuffer - { - return new GLBuffer(version, lime_gl_create_buffer()); - } - - public static function createFramebuffer():GLFramebuffer - { - return new GLFramebuffer(version, lime_gl_create_framebuffer()); - } - - public static function createProgram():GLProgram - { - return new GLProgram(version, lime_gl_create_program()); - } - - public static function createRenderbuffer():GLRenderbuffer - { - return new GLRenderbuffer(version, lime_gl_create_render_buffer()); - } - - public static function createShader(type:Int):GLShader - { - return new GLShader(version, lime_gl_create_shader(type)); - } - - public static function createTexture():GLTexture - { - return new GLTexture(version, lime_gl_create_texture()); - } - - public static function cullFace(mode:Int):Void - { - lime_gl_cull_face(mode); - } - - public static function deleteBuffer(buffer:GLBuffer):Void - { - lime_gl_delete_buffer(buffer.id); - buffer.invalidate(); - } - - public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void - { - lime_gl_delete_framebuffer(framebuffer.id); - framebuffer.invalidate(); - } - - public static function deleteProgram(program:GLProgram):Void - { - lime_gl_delete_program(program.id); - program.invalidate(); - } - - public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void - { - lime_gl_delete_render_buffer(renderbuffer.id); - renderbuffer.invalidate(); - } - - public static function deleteShader(shader:GLShader):Void - { - lime_gl_delete_shader(shader.id); - shader.invalidate(); - } - - public static function deleteTexture(texture:GLTexture):Void - { - lime_gl_delete_texture(texture.id); - texture.invalidate(); - } - - public static function depthFunc(func:Int):Void - { - lime_gl_depth_func(func); - } - - public static function depthMask(flag:Bool):Void - { - lime_gl_depth_mask(flag); - } - - public static function depthRange(zNear:Float, zFar:Float):Void - { - lime_gl_depth_range(zNear, zFar); - } - - public static function detachShader(program:GLProgram, shader:GLShader):Void - { - lime_gl_detach_shader(program.id, shader.id); - } - - public static function disable(cap:Int):Void - { - lime_gl_disable(cap); - } - - public static function disableVertexAttribArray(index:Int):Void - { - lime_gl_disable_vertex_attrib_array(index); - } - - public static function drawArrays(mode:Int, first:Int, count:Int):Void - { - lime_gl_draw_arrays(mode, first, count); - } - - public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void - { - lime_gl_draw_elements(mode, count, type, offset); - } - - public static function enable(cap:Int):Void - { - lime_gl_enable(cap); - } - - public static function enableVertexAttribArray(index:Int):Void - { - lime_gl_enable_vertex_attrib_array(index); - } - - public static function finish():Void - { - lime_gl_finish(); - } - - public static function flush():Void - { - lime_gl_flush(); - } - - public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void - { - lime_gl_framebuffer_renderbuffer(target, attachment, renderbuffertarget, renderbuffer.id); - } - - public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void - { - lime_gl_framebuffer_texture2D(target, attachment, textarget, texture.id, level); - } - - public static function frontFace(mode:Int):Void - { - lime_gl_front_face(mode); - } - - public static function generateMipmap(target:Int):Void - { - lime_gl_generate_mipmap(target); - } - - public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo - { - return lime_gl_get_active_attrib(program.id, index); - } - - public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo - { - return lime_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 lime_gl_get_attrib_location(program.id, name); - } - - public static function getBufferParameter(target:Int, pname:Int):Dynamic - { - return lime_gl_get_buffer_paramerter(target, pname); - } - - public static function getContextAttributes():GLContextAttributes - { - var base = lime_gl_get_context_attributes(); - base.premultipliedAlpha = false; - base.preserveDrawingBuffer = false; - return base; - } - - public static function getError():Int - { - return lime_gl_get_error(); - } - - public static function getExtension(name:String):Dynamic - { - //todo?! - return null; - // return lime_gl_get_extension(name); - } - - public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic - { - return lime_gl_get_framebuffer_attachment_parameter(target, attachment, pname); - } - - public static function getParameter(pname:Int):Dynamic - { - return lime_gl_get_parameter(pname); - } - - public static function getProgramInfoLog(program:GLProgram):String - { - return lime_gl_get_program_info_log(program.id); - } - - public static function getProgramParameter(program:GLProgram, pname:Int):Int - { - return lime_gl_get_program_parameter(program.id, pname); - } - - public static function getRenderbufferParameter(target:Int, pname:Int):Dynamic - { - return lime_gl_get_render_buffer_parameter(target, pname); - } - - public static function getShaderInfoLog(shader:GLShader):String - { - return lime_gl_get_shader_info_log(shader.id); - } - - public static function getShaderParameter(shader:GLShader, pname:Int):Int - { - return lime_gl_get_shader_parameter(shader.id, pname); - } - - public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat - { - return lime_gl_get_shader_precision_format(shadertype, precisiontype); - } - - public static function getShaderSource(shader:GLShader):String - { - return lime_gl_get_shader_source(shader.id); - } - - public static function getSupportedExtensions():Array - { - var result = new Array(); - lime_gl_get_supported_extensions(result); - return result; - } - - public static function getTexParameter(target:Int, pname:Int):Dynamic - { - return lime_gl_get_tex_parameter(target, pname); - } - - public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic - { - return lime_gl_get_uniform(program.id, location); - } - - public static function getUniformLocation(program:GLProgram, name:String):Dynamic - { - return lime_gl_get_uniform_location(program.id, name); - } - - public static function getVertexAttrib(index:Int, pname:Int):Dynamic - { - return lime_gl_get_vertex_attrib(index, pname); - } - - public static function getVertexAttribOffset(index:Int, pname:Int):Int - { - return lime_gl_get_vertex_attrib_offset(index, pname); - } - - public static function hint(target:Int, mode:Int):Void - { - lime_gl_hint(target, mode); - } - - public static function isBuffer(buffer:GLBuffer):Bool - { - return buffer != null && buffer.id > 0 && lime_gl_is_buffer(buffer.id); - } - - // This is non-static - // public function isContextLost():Bool { return false; } - public static function isEnabled(cap:Int):Bool - { - return lime_gl_is_enabled(cap); - } - - public static function isFramebuffer(framebuffer:GLFramebuffer):Bool - { - return framebuffer != null && framebuffer.id > 0 && lime_gl_is_framebuffer(framebuffer.id); - } - - public static function isProgram(program:GLProgram):Bool - { - return program != null && program.id > 0 && lime_gl_is_program(program.id); - } - - public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool - { - return renderbuffer != null && renderbuffer.id > 0 && lime_gl_is_renderbuffer(renderbuffer.id); - } - - public static function isShader(shader:GLShader):Bool - { - return shader != null && shader.id > 0 && lime_gl_is_shader(shader.id); - } - - public static function isTexture(texture:GLTexture):Bool - { - return texture != null && texture.id > 0 && lime_gl_is_texture(texture.id); - } - - public static function lineWidth(width:Float):Void - { - lime_gl_line_width(width); - } - - public static function linkProgram(program:GLProgram):Void - { - lime_gl_link_program(program.id); - } - - private static function load(inName:String, inArgCount:Int):Dynamic - { - try - { - return Libs.load("lime", inName, inArgCount); - - } catch(e:Dynamic) - { - trace(e); - return null; - } - } - - public static function pixelStorei(pname:Int, param:Int):Void - { - lime_gl_pixel_storei(pname, param); - } - - public static function polygonOffset(factor:Float, units:Float):Void - { - lime_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 - { - lime_gl_renderbuffer_storage(target, internalformat, width, height); - } - - public static function sampleCoverage(value:Float, invert:Bool):Void - { - lime_gl_sample_coverage(value, invert); - } - - public static function scissor(x:Int, y:Int, width:Int, height:Int):Void - { - lime_gl_scissor(x, y, width, height); - } - - public static function shaderSource(shader:GLShader, source:String):Void - { - lime_gl_shader_source(shader.id, source); - } - - public static function stencilFunc(func:Int, ref:Int, mask:Int):Void - { - lime_gl_stencil_func(func, ref, mask); - } - - public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void - { - lime_gl_stencil_func_separate(face, func, ref, mask); - } - - public static function stencilMask(mask:Int):Void - { - lime_gl_stencil_mask(mask); - } - - public static function stencilMaskSeparate(face:Int, mask:Int):Void - { - lime_gl_stencil_mask_separate(face, mask); - } - - public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void - { - lime_gl_stencil_op(fail, zfail, zpass); - } - - public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void - { - lime_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 - { - lime_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 - { - lime_gl_tex_parameterf(target, pname, param); - } - - public static function texParameteri(target:Int, pname:Int, param:Int):Void - { - lime_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 - { - lime_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 - { - lime_gl_uniform1f(location, x); - } - - public static function uniform1fv(location:GLUniformLocation, x:LimeFloats):Void - { - lime_gl_uniform1fv(location, x); - } - - public static function uniform1i(location:GLUniformLocation, x:Int):Void - { - lime_gl_uniform1i(location, x); - } - - public static function uniform1iv(location:GLUniformLocation, v:Array):Void - { - lime_gl_uniform1iv(location, v); - } - - public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void - { - lime_gl_uniform2f(location, x, y); - } - - public static function uniform2fv(location:GLUniformLocation, v:LimeFloats):Void - { - lime_gl_uniform2fv(location, v); - } - - public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void - { - lime_gl_uniform2i(location, x, y); - } - - public static function uniform2iv(location:GLUniformLocation, v:Array):Void - { - lime_gl_uniform2iv(location, v); - } - - public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void - { - lime_gl_uniform3f(location, x, y, z); - } - - public static function uniform3fv(location:GLUniformLocation, v:LimeFloats):Void - { - lime_gl_uniform3fv(location, v); - } - - public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void - { - lime_gl_uniform3i(location, x, y, z); - } - - public static function uniform3iv(location:GLUniformLocation, v:Array):Void - { - lime_gl_uniform3iv(location, v); - } - - public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void - { - lime_gl_uniform4f(location, x, y, z, w); - } - - public static function uniform4fv(location:GLUniformLocation, v:LimeFloats):Void - { - lime_gl_uniform4fv(location, v); - } - - public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void - { - lime_gl_uniform4i(location, x, y, z, w); - } - - public static function uniform4iv(location:GLUniformLocation, v:Array):Void - { - lime_gl_uniform4iv(location, v); - } - - public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 2); - } - - public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 3); - } - - public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 4); - } - - public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void - { - lime_gl_uniform_matrix(location, transpose, Float32Array.fromMatrix(matrix).getByteBuffer() , 4); - } - - public static function useProgram(program:GLProgram):Void - { - lime_gl_use_program(program == null ? null : program.id); - } - - public static function validateProgram(program:GLProgram):Void - { - lime_gl_validate_program(program.id); - } - - public static function vertexAttrib1f(indx:Int, x:Float):Void - { - lime_gl_vertex_attrib1f(indx, x); - } - - public static function vertexAttrib1fv(indx:Int, values:LimeFloats):Void - { - lime_gl_vertex_attrib1fv(indx, values); - } - - public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void - { - lime_gl_vertex_attrib2f(indx, x, y); - } - - public static function vertexAttrib2fv(indx:Int, values:LimeFloats):Void - { - lime_gl_vertex_attrib2fv(indx, values); - } - - public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void - { - lime_gl_vertex_attrib3f(indx, x, y, z); - } - - public static function vertexAttrib3fv(indx:Int, values:LimeFloats):Void - { - lime_gl_vertex_attrib3fv(indx, values); - } - - public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void - { - lime_gl_vertex_attrib4f(indx, x, y, z, w); - } - - public static function vertexAttrib4fv(indx:Int, values:LimeFloats):Void - { - lime_gl_vertex_attrib4fv(indx, values); - } - - public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void - { - lime_gl_vertex_attrib_pointer(indx, size, type, normalized, stride, offset); - } - - public static function viewport(x:Int, y:Int, width:Int, height:Int):Void - { - lime_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 lime_gl_version(); } - - - - - // Native Methods - - - - - private static var lime_gl_active_texture = load("lime_gl_active_texture", 1); - private static var lime_gl_attach_shader = load("lime_gl_attach_shader", 2); - private static var lime_gl_bind_attrib_location = load("lime_gl_bind_attrib_location", 3); - private static var lime_gl_bind_bitmap_data_texture = load("lime_gl_bind_bitmap_data_texture", 1); - private static var lime_gl_bind_buffer = load("lime_gl_bind_buffer", 2); - private static var lime_gl_bind_framebuffer = load("lime_gl_bind_framebuffer", 2); - private static var lime_gl_bind_renderbuffer = load("lime_gl_bind_renderbuffer", 2); - private static var lime_gl_bind_texture = load("lime_gl_bind_texture", 2); - private static var lime_gl_blend_color = load("lime_gl_blend_color", 4); - private static var lime_gl_blend_equation = load("lime_gl_blend_equation", 1); - private static var lime_gl_blend_equation_separate = load("lime_gl_blend_equation_separate", 2); - private static var lime_gl_blend_func = load("lime_gl_blend_func", 2); - private static var lime_gl_blend_func_separate = load("lime_gl_blend_func_separate", 4); - private static var lime_gl_buffer_data = load("lime_gl_buffer_data", 5); - private static var lime_gl_buffer_sub_data = load("lime_gl_buffer_sub_data", 5); - private static var lime_gl_check_framebuffer_status = load("lime_gl_check_framebuffer_status", 1); - private static var lime_gl_clear = load("lime_gl_clear", 1); - private static var lime_gl_clear_color = load("lime_gl_clear_color", 4); - private static var lime_gl_clear_depth = load("lime_gl_clear_depth", 1); - private static var lime_gl_clear_stencil = load("lime_gl_clear_stencil", 1); - private static var lime_gl_color_mask = load("lime_gl_color_mask", 4); - private static var lime_gl_compile_shader = load("lime_gl_compile_shader", 1); - private static var lime_gl_compressed_tex_image_2d = load("lime_gl_compressed_tex_image_2d", -1); - private static var lime_gl_compressed_tex_sub_image_2d = load("lime_gl_compressed_tex_sub_image_2d", -1); - private static var lime_gl_copy_tex_image_2d = load("lime_gl_copy_tex_image_2d", -1); - private static var lime_gl_copy_tex_sub_image_2d = load("lime_gl_copy_tex_sub_image_2d", -1); - private static var lime_gl_create_buffer = load("lime_gl_create_buffer", 0); - private static var lime_gl_create_framebuffer = load("lime_gl_create_framebuffer", 0); - private static var lime_gl_create_program = load("lime_gl_create_program", 0); - private static var lime_gl_create_render_buffer = load("lime_gl_create_render_buffer", 0); - private static var lime_gl_create_shader = load("lime_gl_create_shader", 1); - private static var lime_gl_create_texture = load("lime_gl_create_texture", 0); - private static var lime_gl_cull_face = load("lime_gl_cull_face", 1); - private static var lime_gl_delete_buffer = load("lime_gl_delete_buffer", 1); - private static var lime_gl_delete_framebuffer = load("lime_gl_delete_framebuffer", 1); - private static var lime_gl_delete_program = load("lime_gl_delete_program", 1); - private static var lime_gl_delete_render_buffer = load("lime_gl_delete_render_buffer", 1); - private static var lime_gl_delete_shader = load("lime_gl_delete_shader", 1); - private static var lime_gl_delete_texture = load("lime_gl_delete_texture", 1); - private static var lime_gl_depth_func = load("lime_gl_depth_func", 1); - private static var lime_gl_depth_mask = load("lime_gl_depth_mask", 1); - private static var lime_gl_depth_range = load("lime_gl_depth_range", 2); - private static var lime_gl_detach_shader = load("lime_gl_detach_shader", 2); - private static var lime_gl_disable = load("lime_gl_disable", 1); - private static var lime_gl_disable_vertex_attrib_array = load("lime_gl_disable_vertex_attrib_array", 1); - private static var lime_gl_draw_arrays = load("lime_gl_draw_arrays", 3); - private static var lime_gl_draw_elements = load("lime_gl_draw_elements", 4); - private static var lime_gl_enable = load("lime_gl_enable", 1); - private static var lime_gl_enable_vertex_attrib_array = load("lime_gl_enable_vertex_attrib_array", 1); - private static var lime_gl_finish = load("lime_gl_finish", 0); - private static var lime_gl_flush = load("lime_gl_flush", 0); - private static var lime_gl_framebuffer_renderbuffer = load("lime_gl_framebuffer_renderbuffer", 4); - private static var lime_gl_framebuffer_texture2D = load("lime_gl_framebuffer_texture2D", 5); - private static var lime_gl_front_face = load("lime_gl_front_face", 1); - private static var lime_gl_generate_mipmap = load("lime_gl_generate_mipmap", 1); - private static var lime_gl_get_active_attrib = load("lime_gl_get_active_attrib", 2); - private static var lime_gl_get_active_uniform = load("lime_gl_get_active_uniform", 2); - private static var lime_gl_get_attrib_location = load("lime_gl_get_attrib_location", 2); - private static var lime_gl_get_buffer_paramerter = load("lime_gl_get_buffer_paramerter", 2); - private static var lime_gl_get_context_attributes = load("lime_gl_get_context_attributes", 0); - private static var lime_gl_get_error = load("lime_gl_get_error", 0); - private static var lime_gl_get_framebuffer_attachment_parameter = load("lime_gl_get_framebuffer_attachment_parameter", 3); - private static var lime_gl_get_parameter = load("lime_gl_get_parameter", 1); - // private static var lime_gl_get_extension = load("lime_gl_get_extension", 1); - private static var lime_gl_get_program_info_log = load("lime_gl_get_program_info_log", 1); - private static var lime_gl_get_program_parameter = load("lime_gl_get_program_parameter", 2); - private static var lime_gl_get_render_buffer_parameter = load("lime_gl_get_render_buffer_parameter", 2); - private static var lime_gl_get_shader_info_log = load("lime_gl_get_shader_info_log", 1); - private static var lime_gl_get_shader_parameter = load("lime_gl_get_shader_parameter", 2); - private static var lime_gl_get_shader_precision_format = load("lime_gl_get_shader_precision_format", 2); - private static var lime_gl_get_shader_source = load("lime_gl_get_shader_source", 1); - private static var lime_gl_get_supported_extensions = load("lime_gl_get_supported_extensions", 1); - private static var lime_gl_get_tex_parameter = load("lime_gl_get_tex_parameter", 2); - private static var lime_gl_get_uniform = load("lime_gl_get_uniform", 2); - private static var lime_gl_get_uniform_location = load("lime_gl_get_uniform_location", 2); - private static var lime_gl_get_vertex_attrib = load("lime_gl_get_vertex_attrib", 2); - private static var lime_gl_get_vertex_attrib_offset = load("lime_gl_get_vertex_attrib_offset", 2); - private static var lime_gl_hint = load("lime_gl_hint", 2); - private static var lime_gl_is_buffer = load("lime_gl_is_buffer", 1); - private static var lime_gl_is_enabled = load("lime_gl_is_enabled", 1); - private static var lime_gl_is_framebuffer = load("lime_gl_is_framebuffer", 1); - private static var lime_gl_is_program = load("lime_gl_is_program", 1); - private static var lime_gl_is_renderbuffer = load("lime_gl_is_renderbuffer", 1); - private static var lime_gl_is_shader = load("lime_gl_is_shader", 1); - private static var lime_gl_is_texture = load("lime_gl_is_texture", 1); - private static var lime_gl_line_width = load("lime_gl_line_width", 1); - private static var lime_gl_link_program = load("lime_gl_link_program", 1); - private static var lime_gl_pixel_storei = load("lime_gl_pixel_storei", 2); - private static var lime_gl_polygon_offset = load("lime_gl_polygon_offset", 2); - private static var lime_gl_renderbuffer_storage = load("lime_gl_renderbuffer_storage", 4); - private static var lime_gl_sample_coverage = load("lime_gl_sample_coverage", 2); - private static var lime_gl_scissor = load("lime_gl_scissor", 4); - private static var lime_gl_shader_source = load("lime_gl_shader_source", 2); - private static var lime_gl_stencil_func = load("lime_gl_stencil_func", 3); - private static var lime_gl_stencil_func_separate = load("lime_gl_stencil_func_separate", 4); - private static var lime_gl_stencil_mask = load("lime_gl_stencil_mask", 1); - private static var lime_gl_stencil_mask_separate = load("lime_gl_stencil_mask_separate", 2); - private static var lime_gl_stencil_op = load("lime_gl_stencil_op", 3); - private static var lime_gl_stencil_op_separate = load("lime_gl_stencil_op_separate", 4); - private static var lime_gl_tex_image_2d = load("lime_gl_tex_image_2d", -1); - private static var lime_gl_tex_parameterf = load("lime_gl_tex_parameterf", 3); - private static var lime_gl_tex_parameteri = load("lime_gl_tex_parameteri", 3); - private static var lime_gl_tex_sub_image_2d = load("lime_gl_tex_sub_image_2d", -1); - private static var lime_gl_uniform1f = load("lime_gl_uniform1f", 2); - private static var lime_gl_uniform1fv = load("lime_gl_uniform1fv", 2); - private static var lime_gl_uniform1i = load("lime_gl_uniform1i", 2); - private static var lime_gl_uniform1iv = load("lime_gl_uniform1iv", 2); - private static var lime_gl_uniform2f = load("lime_gl_uniform2f", 3); - private static var lime_gl_uniform2fv = load("lime_gl_uniform2fv", 2); - private static var lime_gl_uniform2i = load("lime_gl_uniform2i", 3); - private static var lime_gl_uniform2iv = load("lime_gl_uniform2iv", 2); - private static var lime_gl_uniform3f = load("lime_gl_uniform3f", 4); - private static var lime_gl_uniform3fv = load("lime_gl_uniform3fv", 2); - private static var lime_gl_uniform3i = load("lime_gl_uniform3i", 4); - private static var lime_gl_uniform3iv = load("lime_gl_uniform3iv", 2); - private static var lime_gl_uniform4f = load("lime_gl_uniform4f", 5); - private static var lime_gl_uniform4fv = load("lime_gl_uniform4fv", 2); - private static var lime_gl_uniform4i = load("lime_gl_uniform4i", 5); - private static var lime_gl_uniform4iv = load("lime_gl_uniform4iv", 2); - private static var lime_gl_uniform_matrix = load("lime_gl_uniform_matrix", 4); - private static var lime_gl_use_program = load("lime_gl_use_program", 1); - private static var lime_gl_validate_program = load("lime_gl_validate_program", 1); - private static var lime_gl_version = load("lime_gl_version", 0); - private static var lime_gl_vertex_attrib1f = load("lime_gl_vertex_attrib1f", 2); - private static var lime_gl_vertex_attrib1fv = load("lime_gl_vertex_attrib1fv", 2); - private static var lime_gl_vertex_attrib2f = load("lime_gl_vertex_attrib2f", 3); - private static var lime_gl_vertex_attrib2fv = load("lime_gl_vertex_attrib2fv", 2); - private static var lime_gl_vertex_attrib3f = load("lime_gl_vertex_attrib3f", 4); - private static var lime_gl_vertex_attrib3fv = load("lime_gl_vertex_attrib3fv", 2); - private static var lime_gl_vertex_attrib4f = load("lime_gl_vertex_attrib4f", 5); - private static var lime_gl_vertex_attrib4fv = load("lime_gl_vertex_attrib4fv", 2); - private static var lime_gl_vertex_attrib_pointer = load("lime_gl_vertex_attrib_pointer", -1); - private static var lime_gl_viewport = load("lime_gl_viewport", 4); - - -} - - -typedef ShaderPrecisionFormat = -{ - rangeMin : Int, - rangeMax : Int, - precision : Int, - -}; - diff --git a/lime/helpers/AudioHelper.hx b/lime/helpers/AudioHelper.hx deleted file mode 100644 index 68314ddcf..000000000 --- a/lime/helpers/AudioHelper.hx +++ /dev/null @@ -1,291 +0,0 @@ -package lime.helpers; - -import lime.AudioHandler; -import lime.utils.Libs; - -#if lime_html5 - typedef AudioHelper = lime.helpers.html5.AudioHelper; -#else - typedef AudioHelper = lime.helpers.native.AudioHelper; -#end - -class Sound { - - public var name : String; - public var handle : Dynamic; - public var channel : Dynamic; - - public var looping : Bool = false; - public var playing : Bool = false; - public var ismusic : Bool = false; - - var on_complete_handler : Sound->Void; - - @:isVar public var volume(default, set) : Float = 1.0; - @:isVar public var pan(default, set) : Float = 0.0; - @:isVar public var position(get, set) : Float = 0.0; - - var plays_total : Int = 0; - var plays_remain : Int = 0; - - #if (!audio_thread_disabled && lime_native) - @:noCompletion private var added_to_thread:Bool; - #end - - private var transform:SoundTransform; - - public function new( _name:String, _handle:Dynamic, ?_music:Bool = false, ?_sound:Dynamic = null ) { - - name = _name; - handle = _handle; - channel = _sound; - ismusic = _music; - - //reuse. - transform = new SoundTransform(volume,pan); - - } - - public function play( ?_number_of_times:Int = 1, ?_start:Float = 0.0) { - - plays_total = _number_of_times; - plays_remain = _number_of_times; - - //don't try play 0 times for logical consistency - if(_number_of_times == 0) return; - - // -1 is commnly meant as infinite loop, - //but .loop() should be called instead since it will do the extra setup - if(_number_of_times == -1) { - looping = true; - } - - //set playing flag - playing = true; - - #if lime_native - - channel = null; - - if(_number_of_times == -1) { - _number_of_times = 1; - } - //on native, the sound api matches flash where loop is play, loop ... n so it's "one too many" - // for play (number of times). for this reason we send it in as number - 1 - channel = lime_sound_channel_create(handle, _start, _number_of_times - 1, transform); - - #end //lime_native - - #if lime_html5 - - AudioHelper.soundManager.play( name, { - onfinish : function(){ - do_on_complete(); - } - }); - - #end //lime_html5 - - } //play - - public function stop() { - - playing = false; - looping = false; - - #if lime_native - - if(channel != null) { - - #if (!audio_thread_disabled && lime_native) - if( ismusic ) { - AudioHelper.audio_state.remove(this); - } - #end - - lime_sound_channel_stop(channel); - - channel = null; - - } //channel != null - - #end //lime_native - - #if lime_html5 - - AudioHelper.soundManager.stop( name ); - - #end //lime_html5 - } - - @:noCompletion public function do_on_complete() { - - //looping is explicit so just keep playing - //until they call stop - if(looping) { - - play(); - return; - - } //looping - - #if lime_html5 - - if(!looping) { - plays_remain--; - if(plays_remain > 0) { - play( plays_remain ); - return; - } - } //looping - - #end //lime_html5 - - playing = false; - channel = null; - - if(on_complete_handler != null) { - on_complete_handler( this ); - } - - } //do_on_complete - - public function on_complete(_function:Sound->Void) { - on_complete_handler = _function; - } //on_complete setter - - @:noCompletion public function do_check_complete ():Bool { - - #if lime_native - - if( lime_sound_channel_is_complete(channel) ) { - return true; - } - - #end - - return false; - - } //do_check_complete - - @:noCompletion public function check_complete() { - - #if (!audio_thread_disabled && lime_native) - - if (added_to_thread || (channel != null && ismusic)) { - - if (!added_to_thread) { - AudioHelper.audio_state.add( this ); - added_to_thread = true; - } - - AudioHelper.audio_state.audio_thread.sendMessage( AudioHelper.audio_message_check_complete ); - - return false; - - } else { - if( do_check_complete() ) { - do_on_complete(); - return true; - } else { - return false; - } - } - - #else - - if( do_check_complete() ) { - do_on_complete(); - return true; - } - - #end - - return false; - - } //check_complete - - function set_volume(_v:Float) : Float { - - transform.volume = _v; - - #if lime_native - lime_sound_channel_set_transform(channel,transform); - #end //lime_native - - #if lime_html5 - AudioHelper.soundManager.setVolume(name, _v * 100); - #end //lime_html5 - - return volume = _v; - } - - function set_pan(_p:Float) : Float { - - transform.pan = _p; - - #if lime_native - lime_sound_channel_set_transform(channel,transform); - #end //lime_native - - #if lime_html5 - AudioHelper.soundManager.setPan(name, _p * 100); - #end //lime_html5 - - return pan = _p; - } - - function set_position(_p:Float) : Float { - - #if lime_native - lime_sound_channel_set_position(channel, _p); - #end //lime_native - - #if lime_html5 - AudioHelper.soundManager.setPosition(name, _p); - #end //lime_html5 - - return position = _p; - } - - function get_position() : Float { - - #if lime_native - position = lime_sound_channel_get_position(channel); - #end //lime_native - - #if lime_html5 - position = handle.position; - #end //lime_html5 - - return position; - } - -#if lime_native - - private static var lime_sound_channel_is_complete = Libs.load( "lime", "lime_sound_channel_is_complete", 1); - private static var lime_sound_channel_create = Libs.load( "lime", "lime_sound_channel_create", 4); - private static var lime_sound_channel_stop = Libs.load( "lime", "lime_sound_channel_stop", 1); - private static var lime_sound_channel_set_transform = Libs.load( "lime", "lime_sound_channel_set_transform", 2); - private static var lime_sound_channel_get_position = Libs.load( "lime", "lime_sound_channel_get_position", 1); - private static var lime_sound_channel_set_position = Libs.load( "lime", "lime_sound_channel_set_position", 2); - -#end //lime_native - -} - -class SoundTransform { - - public var pan:Float; - public var volume:Float; - - public function new(vol:Float = 1.0, panning:Float = 0.0) { - volume = vol; - pan = panning; - } - - public function clone() { - return new SoundTransform(volume, pan); - } - -} //SoundTransform diff --git a/lime/helpers/Gamepad.hx b/lime/helpers/Gamepad.hx deleted file mode 100644 index 0125f8df2..000000000 --- a/lime/helpers/Gamepad.hx +++ /dev/null @@ -1,100 +0,0 @@ -package lime.helpers; - -class Gamepad { - - public var max_buttons : Int = 16; - public var max_axis : Int = 8; - public var max_hats : Int = 8; - - public var button0 : Int = -1; - public var button1 : Int = -1; - public var button2 : Int = -1; - public var button3 : Int = -1; - public var button4 : Int = -1; - public var button5 : Int = -1; - public var button6 : Int = -1; - public var button7 : Int = -1; - public var button8 : Int = -1; - public var button9 : Int = -1; - public var button10 : Int = -1; - public var button11 : Int = -1; - public var button12 : Int = -1; - public var button13 : Int = -1; - public var button14 : Int = -1; - public var button15 : Int = -1; - - public var axis0 : Int = -1; - public var axis1 : Int = -1; - public var axis2 : Int = -1; - public var axis3 : Int = -1; - public var axis4 : Int = -1; - public var axis5 : Int = -1; - public var axis6 : Int = -1; - public var axis7 : Int = -1; - - public var hat0 : Int = -1; - public var hat1 : Int = -1; - public var hat2 : Int = -1; - public var hat3 : Int = -1; - public var hat4 : Int = -1; - public var hat5 : Int = -1; - public var hat6 : Int = -1; - public var hat7 : Int = -1; - - public function new() {} - public function set_profile(buttons:Array, axis:Array, hats:Array ) { - - for(i in 0 ... max_buttons) { - Reflect.setProperty(this, 'button' + i, buttons[i]); - } - - for(i in 0 ... max_axis) { - Reflect.setProperty(this, 'axis' + i, axis[i]); - } - - for(i in 0 ... max_hats) { - Reflect.setProperty(this, 'hat' + i, hats[i]); - } - - } //set_profile - - public function apply_360_profile() { - - var buttons : Array = []; - var axis : Array = []; - var hats : Array = []; - - #if mac - //A B X Y RB LB RS LS back start guide - buttons = [11,12,13,14,8,9,7,6,5,4,10,-1,-1,-1,-1,-1]; - //LSY LSX RSY RSX LT RT - axis = [0,1,2,3,4,5,-1,-1]; - //UP DOWN LEFT RIGHT - hats = [0,1,2,3,-1,-1,-1,-1]; - #end - #if windows - //A B X Y RB LB RS LS back start guide - buttons = [0,1,2,3, 5,4,9,8, 6,7,-1, -1,-1,-1,-1,-1]; - //LSY LSX RSY RSX LT RT - axis = [1,0,3,4,2,2,-1,-1]; - //0 0 0 0 - hats = [0,0,0,0,-1,-1,-1,-1]; - #end - #if linux - buttons = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]; - axis = [-1,-1,-1,-1,-1,-1,-1,-1]; - hats = [-1,-1,-1,-1,-1,-1,-1,-1]; - #end - #if lime_html5 - buttons = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]; - axis = [-1,-1,-1,-1,-1,-1,-1,-1]; - hats = [-1,-1,-1,-1,-1,-1,-1,-1]; - #end - - //apply it - set_profile(buttons, axis, hats); - - } // apply_360_profile - - -} \ No newline at end of file diff --git a/lime/helpers/InputHelper.hx b/lime/helpers/InputHelper.hx deleted file mode 100644 index 306571791..000000000 --- a/lime/helpers/InputHelper.hx +++ /dev/null @@ -1,7 +0,0 @@ -package lime.helpers; - -#if lime_html5 - typedef InputHelper = lime.helpers.html5.InputHelper; -#else - typedef InputHelper = lime.helpers.native.InputHelper; -#end //!lime_html5 \ No newline at end of file diff --git a/lime/helpers/Keys.hx b/lime/helpers/Keys.hx deleted file mode 100644 index 0c9bda946..000000000 --- a/lime/helpers/Keys.hx +++ /dev/null @@ -1,424 +0,0 @@ -package lime.helpers; - -enum KeyValue { - unknown; - backspace; - tab; - enter; - meta; - shift; - ctrl; - alt; - capslock; - escape; - space; - - left; - up; - right; - down; - - key_0; - key_1; - key_2; - key_3; - key_4; - key_5; - key_6; - key_7; - key_8; - key_9; - - key_A; - key_B; - key_C; - key_D; - key_E; - key_F; - key_G; - key_H; - key_I; - key_J; - key_K; - key_L; - key_M; - key_N; - key_O; - key_P; - key_Q; - key_R; - key_S; - key_T; - key_U; - key_V; - key_W; - key_X; - key_Y; - key_Z; - - equals; - minus; - tilde; - forward_slash; - back_slash; - semicolon; - single_quote; - comma; - period; - open_square_brace; - close_square_brace; - - f1; - f2; - f3; - f4; - f5; - f6; - f7; - f8; - f9; - f10; - f11; - f12; - f13; - f14; - f15; -} - -class Keys { - - static inline var _backspace: Int = 8; - static inline var _tab : Int = 9; - static inline var _enter : Int = 13; - static inline var _meta : Int = 15; - static inline var _shift : Int = 16; - static inline var _ctrl : Int = 17; - static inline var _alt : Int = 18; - static inline var _capslock : Int = 20; - static inline var _escape : Int = 27; - static inline var _space : Int = 32; - - static inline var _left : Int = 37; - static inline var _up : Int = 38; - static inline var _right : Int = 39; - static inline var _down : Int = 40; - - static inline var _key_0 : Int = 48; - static inline var _key_1 : Int = 49; - static inline var _key_2 : Int = 50; - static inline var _key_3 : Int = 51; - static inline var _key_4 : Int = 52; - static inline var _key_5 : Int = 53; - static inline var _key_6 : Int = 54; - static inline var _key_7 : Int = 55; - static inline var _key_8 : Int = 56; - static inline var _key_9 : Int = 57; - - static inline var _key_A : Int = 65; - static inline var _key_B : Int = 66; - static inline var _key_C : Int = 67; - static inline var _key_D : Int = 68; - static inline var _key_E : Int = 69; - static inline var _key_F : Int = 70; - static inline var _key_G : Int = 71; - static inline var _key_H : Int = 72; - static inline var _key_I : Int = 73; - static inline var _key_J : Int = 74; - static inline var _key_K : Int = 75; - static inline var _key_L : Int = 76; - static inline var _key_M : Int = 77; - static inline var _key_N : Int = 78; - static inline var _key_O : Int = 79; - static inline var _key_P : Int = 80; - static inline var _key_Q : Int = 81; - static inline var _key_R : Int = 82; - static inline var _key_S : Int = 83; - static inline var _key_T : Int = 84; - static inline var _key_U : Int = 85; - static inline var _key_V : Int = 86; - static inline var _key_W : Int = 87; - static inline var _key_X : Int = 88; - static inline var _key_Y : Int = 89; - static inline var _key_Z : Int = 90; - - static inline var _equals : Int = 187; - static inline var _minus : Int = 189; - static inline var _tilde : Int = 192; - static inline var _forward_slash : Int = 191; - static inline var _back_slash : Int = 220; - static inline var _semicolon : Int = 186; - static inline var _single_quote : Int = 222; - static inline var _comma : Int = 188; - static inline var _period : Int = 190; - static inline var _open_square_brace : Int = 219; - static inline var _close_square_brace : Int = 221; - - static inline var _f1 : Int = 112; - static inline var _f2 : Int = 113; - static inline var _f3 : Int = 114; - static inline var _f4 : Int = 115; - static inline var _f5 : Int = 116; - static inline var _f6 : Int = 117; - static inline var _f7 : Int = 118; - static inline var _f8 : Int = 119; - static inline var _f9 : Int = 120; - static inline var _f10 : Int = 121; - static inline var _f11 : Int = 122; - static inline var _f12 : Int = 123; - static inline var _f13 : Int = 124; - static inline var _f14 : Int = 125; - static inline var _f15 : Int = 126; - - public var tab : Int = _tab; - public var enter : Int = _enter; - public var meta : Int = _meta; - public var shift : Int = _shift; - public var ctrl : Int = _ctrl; - public var alt : Int = _alt; - public var capslock : Int = _capslock; - public var escape : Int = _escape; - public var space : Int = _space; - - public var left : Int = _left; - public var up : Int = _up; - public var right : Int = _right; - public var down : Int = _down; - - public var key_0 : Int = _key_0; - public var key_1 : Int = _key_1; - public var key_2 : Int = _key_2; - public var key_3 : Int = _key_3; - public var key_4 : Int = _key_4; - public var key_5 : Int = _key_5; - public var key_6 : Int = _key_6; - public var key_7 : Int = _key_7; - public var key_8 : Int = _key_8; - public var key_9 : Int = _key_9; - - public var key_A : Int = _key_A; - public var key_B : Int = _key_B; - public var key_C : Int = _key_C; - public var key_D : Int = _key_D; - public var key_E : Int = _key_E; - public var key_F : Int = _key_F; - public var key_G : Int = _key_G; - public var key_H : Int = _key_H; - public var key_I : Int = _key_I; - public var key_J : Int = _key_J; - public var key_K : Int = _key_K; - public var key_L : Int = _key_L; - public var key_M : Int = _key_M; - public var key_N : Int = _key_N; - public var key_O : Int = _key_O; - public var key_P : Int = _key_P; - public var key_Q : Int = _key_Q; - public var key_R : Int = _key_R; - public var key_S : Int = _key_S; - public var key_T : Int = _key_T; - public var key_U : Int = _key_U; - public var key_V : Int = _key_V; - public var key_W : Int = _key_W; - public var key_X : Int = _key_X; - public var key_Y : Int = _key_Y; - public var key_Z : Int = _key_Z; - - public var equals : Int = _equals; - public var minus : Int = _minus; - public var tilde : Int = _tilde; - public var forward_slash : Int = _forward_slash; - public var back_slash : Int = _back_slash; - public var semicolon : Int = _semicolon; - public var single_quote : Int = _single_quote; - public var comma : Int = _comma; - public var period : Int = _period; - public var open_square_brace : Int = _open_square_brace; - public var close_square_brace : Int = _close_square_brace; - - public var f1 : Int = _f1; - public var f2 : Int = _f2; - public var f3 : Int = _f3; - public var f4 : Int = _f4; - public var f5 : Int = _f5; - public var f6 : Int = _f6; - public var f7 : Int = _f7; - public var f8 : Int = _f8; - public var f9 : Int = _f9; - public var f10 : Int = _f10; - public var f11 : Int = _f11; - public var f12 : Int = _f12; - public var f13 : Int = _f13; - public var f14 : Int = _f14; - public var f15 : Int = _f15; - - public function new() {} - public static function toKeyValue(_event:Dynamic) : KeyValue { - - var _value = _event.value; - - switch(_value) { - case _backspace: - return KeyValue.backspace; - case _tab: - return KeyValue.tab; - case _enter: - return KeyValue.enter; - case _meta: - return KeyValue.meta; - case _shift: - return KeyValue.shift; - case _ctrl: - return KeyValue.ctrl; - case _alt: - return KeyValue.alt; - case _capslock: - return KeyValue.capslock; - case _escape: - return KeyValue.escape; - case _space: - return KeyValue.space; - - case _left: - return KeyValue.left; - case _up: - return KeyValue.up; - case _right: - return KeyValue.right; - case _down: - return KeyValue.down; - - case _key_0: - return KeyValue.key_0; - case _key_1: - return KeyValue.key_1; - case _key_2: - return KeyValue.key_2; - case _key_3: - return KeyValue.key_3; - case _key_4: - return KeyValue.key_4; - case _key_5: - return KeyValue.key_5; - case _key_6: - return KeyValue.key_6; - case _key_7: - return KeyValue.key_7; - case _key_8: - return KeyValue.key_8; - case _key_9: - return KeyValue.key_9; - - case _key_A: - return KeyValue.key_A; - case _key_B: - return KeyValue.key_B; - case _key_C: - return KeyValue.key_C; - case _key_D: - return KeyValue.key_D; - case _key_E: - return KeyValue.key_E; - case _key_F: - return KeyValue.key_F; - case _key_G: - return KeyValue.key_G; - case _key_H: - return KeyValue.key_H; - case _key_I: - return KeyValue.key_I; - case _key_J: - return KeyValue.key_J; - case _key_K: - return KeyValue.key_K; - case _key_L: - return KeyValue.key_L; - case _key_M: - return KeyValue.key_M; - case _key_N: - return KeyValue.key_N; - case _key_O: - return KeyValue.key_O; - case _key_P: - return KeyValue.key_P; - case _key_Q: - return KeyValue.key_Q; - case _key_R: - return KeyValue.key_R; - case _key_S: - return KeyValue.key_S; - case _key_T: - return KeyValue.key_T; - case _key_U: - return KeyValue.key_U; - case _key_V: - return KeyValue.key_V; - case _key_W: - return KeyValue.key_W; - case _key_X: - return KeyValue.key_X; - case _key_Y: - return KeyValue.key_Y; - case _key_Z: - return KeyValue.key_Z; - - case _equals: - return KeyValue.equals; - case _minus: - return KeyValue.minus; - case _tilde: - return KeyValue.tilde; - - case _forward_slash : - return KeyValue.forward_slash; - case _back_slash : - return KeyValue.back_slash; - case _semicolon : - return KeyValue.semicolon; - case _single_quote : - return KeyValue.single_quote; - case _comma : - return KeyValue.comma; - case _period : - return KeyValue.period; - case _open_square_brace : - return KeyValue.open_square_brace; - case _close_square_brace : - return KeyValue.close_square_brace; - - case _f1 : - return KeyValue.f1; - case _f2 : - return KeyValue.f2; - case _f3 : - return KeyValue.f3; - case _f4 : - return KeyValue.f4; - case _f5 : - return KeyValue.f5; - case _f6 : - return KeyValue.f6; - case _f7 : - return KeyValue.f7; - case _f8 : - return KeyValue.f8; - case _f9 : - return KeyValue.f9; - case _f10 : - return KeyValue.f10; - case _f11 : - return KeyValue.f11; - case _f12 : - return KeyValue.f12; - case _f13 : - return KeyValue.f13; - case _f14 : - return KeyValue.f14; - case _f15 : - return KeyValue.f15; - - } //switch - - return KeyValue.unknown; - - } //toKeyValue - -} //Keys \ No newline at end of file diff --git a/lime/helpers/html5/AudioHelper.hx b/lime/helpers/html5/AudioHelper.hx deleted file mode 100644 index 187784f9e..000000000 --- a/lime/helpers/html5/AudioHelper.hx +++ /dev/null @@ -1,64 +0,0 @@ -package lime.helpers.html5; - -import lime.Lime; - -import lime.helpers.AudioHelper.Sound; - -class AudioHelper { - - var lib : Lime; - - public var ready : Bool = false; - public static var soundManager : Dynamic; - - public function new( _lib:Lime ) { - - lib = _lib; - - } //new - - @:noCompletion public function startup() { - - //init sound manager - soundManager = untyped js.Browser.window.soundManager; - if(soundManager != null) { - soundManager.setup({ - url: './lib/soundmanager/swf/', - flashVersion: 9, - debugMode : false, - preferFlash: true, - onready : function() { ready = true; } - }); - } - - } - - public function create( _name:String, _file:String, ?_music:Bool = false ) : Sound { - - var _sound_handle = soundManager.createSound({ - - url: _file, - id: _name, - autoLoad : true, - autoPlay : false, - multiShot : !_music, - stream : _music - - }); - - return new Sound(_name, _sound_handle, _music); - - } //create - - @:noCompletion public function shutdown() { - - soundManager.stopAll(); - - } - - @:noCompletion public function update() { - - } - - -} //AudioHelper \ No newline at end of file diff --git a/lime/helpers/html5/InputHelper.hx b/lime/helpers/html5/InputHelper.hx deleted file mode 100644 index fdf7987ba..000000000 --- a/lime/helpers/html5/InputHelper.hx +++ /dev/null @@ -1,411 +0,0 @@ -package lime.helpers.html5; - -import lime.InputHandler.GamepadEvent; -import lime.InputHandler.GamepadButtonEvent; -import lime.InputHandler.GamepadAxisEvent; -import lime.InputHandler.ButtonState; -import lime.InputHandler.MouseButton; -import lime.InputHandler.MouseState; -import lime.RenderHandler.BrowserLike; - -import lime.Lime; - -class InputHelper { - - var lib : Lime; - - public function new( _lib:Lime ) { - - lib = _lib; - - } //new - - public function startup() { - - //right click on the canvas should be canceled on browser - lib.window_handle.addEventListener('contextmenu', on_contextmenu ); - - //mouse events bind to the lime element only, - //maybe this should be adjusted for mousemove? - lib.window_handle.addEventListener('mousedown', on_mousedown); - lib.window_handle.addEventListener('mousemove', on_mousemove); - lib.window_handle.addEventListener('mouseup', on_mouseup); - - //there are two kinds of scroll across browser, we handle both - lib.window_handle.addEventListener('mousewheel', on_mousewheel); - lib.window_handle.addEventListener('DOMMouseScroll', on_mousewheel); - - //key input should be page wide, not just the lime element - js.Browser.document.addEventListener('keydown', on_keydown); - js.Browser.document.addEventListener('keyup', on_keyup); - - //handle any gamepad information, if the browser supports it - startup_gamepads(); - - } //startup - - @:noCompletion public function update() { - if(gamepads_supported) { - poll_gamepads(); - } - } - - function fail_gamepads() { - gamepads_supported = false; - trace("lime : Gamepads are not supported in this browser :("); - } - - - //if gamepads are supported, the method to get them will - //be stored in this variable for reuse - var gamepads_supported : Bool = false; - - function startup_gamepads() { - - active_gamepads = new Map(); - gamepads_supported = (get_gamepad_list != null); - - } - - function poll_gamepads() { - - var list = get_gamepad_list(); - if(list != null) { - for(i in 0 ... list.length) { - if( untyped list[i] != null ) { - handle_gamepad( untyped list[i] ); - } - } - } - - } //poll_gamepads - - //this will take some liberties for now - //because chrome and firefox share the same spec for - //the most part and all future implementations should - //follow spec too. If the spec changes we can adjust if needed - var active_gamepads : Map; - - function handle_gamepad( _gamepad : Dynamic ) { - - //disconnected gamepads we don't need - if(_gamepad == null) return; - - //check if this gamepad exists already - if( !active_gamepads.exists( _gamepad.index ) ) { - - //if not we add it to the list - active_gamepads.set( _gamepad.index, { - id : _gamepad.id, - index : _gamepad.index, - axes : cast _gamepad.axes, - buttons : cast _gamepad.buttons, - timestamp : _gamepad.timestamp - }); - - //fire an on connected event - // :todo: - - } else { - - //found in the list so we can update it if anything changed - var gamepad = active_gamepads.get(_gamepad.index); - //but only if the timestamp differs - if(gamepad.timestamp != _gamepad.timestamp) { - - //update the id if it changed - if(gamepad.id != _gamepad.id) { gamepad.id = _gamepad.id; } - //update the timestamp - gamepad.timestamp = _gamepad.timestamp; - - //we store the list of changed indices - //so we can call the handler functions with each - var axes_changed : Array = []; - var buttons_changed : Array = []; - //the last known values - var last_axes = gamepad.axes; - var last_buttons = gamepad.buttons; - - //the new known values - var new_axes : Array = cast _gamepad.axes; - var new_buttons : Array = cast _gamepad.buttons; - - //check for axes changes - var axis_index : Int = 0; - for(axis in new_axes) { - - if(axis != last_axes[axis_index]) { - axes_changed.push(axis_index); - gamepad.axes[axis_index] = axis; - } - - axis_index++; - - } //axis in new_axes - - //check for button changes - var button_index : Int = 0; - for(button in new_buttons) { - - if(button != last_buttons[button_index]) { - buttons_changed.push(button_index); - gamepad.buttons[button_index] = button; - } - - button_index++; - - } //button in new_buttons - - - //now forward any axis changes to the wrapper - for(index in axes_changed) { - - lib.input.lime_gamepadaxis({ - raw : gamepad, - axis : index, - value : new_axes[index], - gamepad : gamepad.index - }, true); - - } //for each axis changed - - //then forward any button changes to the wrapper - for(index in buttons_changed) { - - var _state = (new_buttons[index] == 0) ? ButtonState.up : ButtonState.down; - var _gamepad_event : GamepadButtonEvent = { - raw : gamepad, - state : _state, - value : new_buttons[index], - button : index, - gamepad : gamepad.index - }; - - if(_state == ButtonState.up) { - lib.input.lime_gamepadbuttonup( _gamepad_event, true ); - } else { - lib.input.lime_gamepadbuttondown( _gamepad_event, true ); - } - - } //for each button change - - } //timestamp changed - - } //exists - - } //handle_gamepad - - //It's really early for gamepads in browser, - // but we can still support them where they exist - function get_gamepad_list() : Dynamic { - - //Modernizr is used to detect gamepad support - var modernizr = untyped js.Browser.window.Modernizr; - if(modernizr != null) { - - if(modernizr.gamepads == true) { - - //try official api first - if( untyped js.Browser.navigator.getGamepads != null ) { - return untyped js.Browser.navigator.getGamepads(); - } - - //try newer webkit GetGamepads() function - if( untyped js.Browser.navigator.webkitGetGamepads != null ) { - return untyped js.Browser.navigator.webkitGetGamepads(); - } - - //if we make it here we failed support so fail out - fail_gamepads(); - - } else { - - fail_gamepads(); - - } - - } //modernizr != null - - return null; - - } //get_gamepad_list - - function on_contextmenu( _event:Dynamic ) { - - _event.preventDefault(); - - } //on_contextmenu - - function translate_wheel_direction( _event:Dynamic ) : Int { - - //browser variations - var detail = _event.detail; - var wheelDelta = _event.wheelDelta; - - // :todo: make inverted for mac? - if(detail != null && detail != 0) return detail; - if(wheelDelta != null && wheelDelta != 0) return wheelDelta; - - //fallback - return 0; - - } //translate_wheel_direction - - function on_mousewheel( _event:Dynamic ) { - - //prevent page scroll when using the wheel - _event.preventDefault(); - //figure out what kind of event direction this is - var direction = translate_wheel_direction(_event); - //clamp to only one scroll at a time to handle discrepencies in browser - var delta = Math.max(-1, Math.min(1, direction)); - - var wheel_dir : MouseButton; - - if(delta < 1) { - wheel_dir = MouseButton.wheel_up; - } else { - wheel_dir = MouseButton.wheel_down; - } - - //pass the event to the lib - lib.input.lime_mousewheel({ - - raw : _event, - button : wheel_dir, - state : MouseState.wheel, - x : _event.pageX - lib.render.canvas_position.x, - y : _event.pageY - lib.render.canvas_position.y, - flags : 0, - ctrl_down : _event.ctrlKey, - alt_down : _event.altKey, - shift_down : _event.shiftKey, - meta_down : _event.metaKey - - }, true); - - } //on_mousewheel - - function on_mousedown( _event:Dynamic ){ - - _event.preventDefault(); - - lib.input.lime_mousedown({ - - raw : _event, - button : lib.input.mouse_button_from_id(_event.button), - state : MouseState.down, - x : _event.pageX - lib.render.canvas_position.x, - y : _event.pageY - lib.render.canvas_position.y, - flags : 0, - ctrl_down : _event.ctrlKey, - alt_down : _event.altKey, - shift_down : _event.shiftKey, - meta_down : _event.metaKey - - }, true); //mousedown, true to forward event directly - - } //on_mousedown - - function on_mousemove( _event:Dynamic ) { - - var deltaX = untyped _event.movementX; - var deltaY = untyped _event.movementY; - - switch(lib.render.browser) { - - case BrowserLike.chrome, BrowserLike.safari, BrowserLike.opera: - - deltaX = untyped _event.webkitMovementX; - deltaY = untyped _event.webkitMovementY; - - case BrowserLike.firefox: - - deltaX = untyped _event.mozMovementX; - deltaY = untyped _event.mozMovementY; - - case BrowserLike.ie: - //? - - default: - deltaX = 0; - deltaY = 0; - - } //switch brower type - - _event.preventDefault(); - - lib.input.lime_mousemove({ - - raw : _event, - button : MouseButton.move, - state : MouseState.move, - x : _event.pageX - lib.render.canvas_position.x, - y : _event.pageY - lib.render.canvas_position.y, - deltaX : deltaX, - deltaY : deltaY, - flags : 0, - ctrl_down : _event.ctrlKey, - alt_down : _event.altKey, - shift_down : _event.shiftKey, - meta_down : _event.metaKey - - }, true); - - } //on_mousemove - - function on_mouseup( _event:Dynamic ) { - - _event.preventDefault(); - - lib.input.lime_mouseup({ - - raw : _event, - button : lib.input.mouse_button_from_id(_event.button), - state : MouseState.up, - x : _event.pageX - lib.render.canvas_position.x, - y : _event.pageY - lib.render.canvas_position.y, - flags : 0, - ctrl_down : _event.ctrlKey, - alt_down : _event.altKey, - shift_down : _event.shiftKey, - meta_down : _event.metaKey - - }, true); - - } //on_mouseup - - function on_keydown( _event:Dynamic ) { - - if (_event.keyCode >= 65 && _event.keyCode <= 122) { - _event.value = _event.which; - } else { - _event.value = _event.which; - } - - lib.input.lime_onkeydown( _event ); - - } //on_keydown - - function on_keyup( _event:Dynamic ) { - - if( _event.keyCode >= 65 && _event.keyCode <= 122 ) { - _event.value = _event.which; - } else { - _event.value = _event.which; - } - - lib.input.lime_onkeyup( _event ); - - } //on_keyup - -} //InputHelper - - -typedef HTML5Gamepad = { - axes : Array, - index : Int, - buttons : Array, - id : String, - timestamp : Float -} \ No newline at end of file diff --git a/lime/helpers/native/AudioHelper.hx b/lime/helpers/native/AudioHelper.hx deleted file mode 100644 index 25efab0f6..000000000 --- a/lime/helpers/native/AudioHelper.hx +++ /dev/null @@ -1,194 +0,0 @@ -package lime.helpers.native; - -import lime.utils.Libs; -import lime.Lime; - -#if (!audio_thread_disabled) - #if neko - import neko.vm.Thread; - import neko.vm.Mutex; - #else - import cpp.vm.Thread; - import cpp.vm.Mutex; - #end -#end //audio_thread_disabled - -import lime.helpers.AudioHelper.Sound; - -class AudioHelper { - - var lib : Lime; - -#if (!audio_thread_disabled) - - @:noCompletion public static var audio_state:AudioThreadState; - @:noCompletion public static var audio_message_check_complete = 1; - @:noCompletion public static var audio_thread_is_idle:Bool = true; - @:noCompletion public static var audio_thread_running:Bool = false; - -#end - - public function new( _lib:Lime ) { - - lib = _lib; - - } //new - - @:noCompletion public function startup() { - - #if (!audio_thread_disabled) - - audio_state = new AudioThreadState (); - audio_thread_running = true; - audio_thread_is_idle = false; - audio_state.main_thread = Thread.current (); - audio_state.audio_thread = Thread.create( audio_thread_handler ); - - #end //#(!audio_thread_disabled && lime_native) - - } //startup - - @:noCompletion public function update() { - - - - } //update - - @:noCompletion public function shutdown() { - - #if (!audio_thread_disabled) - - audio_thread_running = false; - - #end //(!audio_thread_disabled && lime_native) - - } //shutdown - - public function create( _name:String, _file:String, ?_music:Bool = false ) { - - var _handle = lime_sound_from_file( lime.AssetData.path.get(_file), _music ); - - return new Sound(_name, _handle, _music); - - } //create - -#if (!audio_thread_disabled) - - public function audio_thread_handler() { - - #if debug - lib._debug("lime: Audio background thread started."); - #end //debug - - var thread_message : Dynamic; - while (audio_thread_running) { - - thread_message = Thread.readMessage (false); - - if (thread_message == audio_message_check_complete) { - audio_state.check(); - } - - if (!audio_thread_is_idle) { - audio_state.update(); - Sys.sleep (0.01); - } else { - Sys.sleep (0.2); - } - - } - - audio_thread_running = false; - audio_thread_is_idle = true; - - #if debug - lib._debug("lime: Audio background thread shutdown."); - #end //debug - - } - -#end //(!audio_thread_disabled) - -#if lime_native - private static var lime_sound_from_file = Libs.load("lime","lime_sound_from_file", 2); - private static var lime_sound_from_data = Libs.load("lime","lime_sound_from_data", 3); -#end //lime_native - -} //AudioHelper - - -#if (!audio_thread_disabled) - - class AudioThreadState { - - public var audio_thread:Thread; - public var sound_list:Map ; - public var main_thread:Thread; - public var mutex:Mutex; - - public function new () { - mutex = new Mutex (); - sound_list = new Map (); - } - - public function add (sound:Sound):Void { - - mutex.acquire (); - - if (!sound_list.exists(sound)) { - sound_list.set (sound, false); - AudioHelper.audio_thread_is_idle = false; - } - - mutex.release (); - - } - - public function check() { - - for (sound in sound_list.keys()) { - - var is_complete = sound_list.get(sound); - if (is_complete) { - sound.do_on_complete(); - - mutex.acquire (); - sound_list.remove( sound ); - mutex.release (); - - } //isComplete - } - - } - - public function remove( sound:Sound ):Void { - - mutex.acquire (); - - if( sound_list.exists(sound) ) { - sound_list.remove(sound); - if (Lambda.count (sound_list) == 0) { - AudioHelper.audio_thread_is_idle = true; - } - } - - mutex.release (); - - } - - public function update() { - - mutex.acquire (); - - for (sound in sound_list.keys()) { - var is_complete = sound.do_check_complete(); - sound_list.set( sound, is_complete ); - } - - mutex.release (); - - } - - } //AudioThreadState - -#end // (!audio_thread_disabled) \ No newline at end of file diff --git a/lime/helpers/native/InputHelper.hx b/lime/helpers/native/InputHelper.hx deleted file mode 100644 index 19bf584b9..000000000 --- a/lime/helpers/native/InputHelper.hx +++ /dev/null @@ -1,24 +0,0 @@ -package lime.helpers.native; - -import lime.Lime; - -class InputHelper { - - var lib : Lime; - - public function new( _lib:Lime ) { - - lib = _lib; - - } //new - - @:noCompletion public function startup() { - - } - - @:noCompletion public function update() { - - } - - -} //InputHelper diff --git a/lime/system/System.hx b/lime/system/System.hx new file mode 100644 index 000000000..644648966 --- /dev/null +++ b/lime/system/System.hx @@ -0,0 +1,222 @@ +package lime.system; + + +#if sys +import sys.io.Process; +#end + + +class System { + + + @:noCompletion private static var __moduleNames:Map = null; + + + static private function findHaxeLib (library:String):String { + + try { + + var proc = new Process ("haxelib", [ "path", library ]); + + if (proc != null) { + + var stream = proc.stdout; + + try { + + while (true) { + + var s = stream.readLine (); + + if (s.substr (0, 1) != "-") { + + stream.close (); + proc.close (); + loaderTrace ("Found haxelib " + s); + return s; + + } + + } + + } catch(e:Dynamic) { } + + stream.close (); + proc.close (); + + } + + } catch (e:Dynamic) { } + + return ""; + + } + + + public static function load (library:String, method:String, args:Int = 0):Dynamic { + + #if (iphone || emscripten || android) + return cpp.Lib.load (library, method, args); + #end + + if (__moduleNames == null) __moduleNames = new Map (); + if (__moduleNames.exists (library)) { + + #if cpp + return cpp.Lib.load (__moduleNames.get (library), method, args); + #elseif neko + return neko.Lib.load (__moduleNames.get (library), method, args); + #else + return null; + #end + + } + + #if waxe + if (library == "lime") { + + flash.Lib.load ("waxe", "wx_boot", 1); + + } + #end + + __moduleNames.set (library, library); + + var result:Dynamic = tryLoad ("./" + library, library, method, args); + + if (result == null) { + + result = tryLoad (".\\" + library, library, method, args); + + } + + if (result == null) { + + result = tryLoad (library, library, method, args); + + } + + if (result == null) { + + var slash = (sysName ().substr (7).toLowerCase () == "windows") ? "\\" : "/"; + var haxelib = findHaxeLib ("lime"); + + if (haxelib != "") { + + result = tryLoad (haxelib + slash + "ndll" + slash + sysName () + slash + library, library, method, args); + + if (result == null) { + + result = tryLoad (haxelib + slash + "ndll" + slash + sysName() + "64" + slash + library, library, method, args); + + } + + } + + } + + loaderTrace ("Result : " + result); + + #if neko + if (library == "lime") { + + loadNekoAPI (); + + } + #end + + return result; + + } + + + private static function sysName ():String { + + #if cpp + var sys_string = cpp.Lib.load ("std", "sys_string", 0); + return sys_string (); + #else + return Sys.systemName (); + #end + + } + + + 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 + var result = null; + #end + + if (result != null) { + + loaderTrace ("Got result " + name); + __moduleNames.set (library, name); + return result; + + } + + } catch (e:Dynamic) { + + loaderTrace ("Failed to load : " + name); + + } + + return null; + + } + + + 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 neko + + private static function loadNekoAPI ():Void { + + if (!__loadedNekoAPI) { + + var init = load ("lime", "neko_init", 5); + + if (init != null) { + + loaderTrace ("Found nekoapi @ " + __moduleNames.get ("lime")); + init (function(s) return new String (s), function (len:Int) { var r = []; if (len > 0) r[len - 1] = null; return r; }, null, true, false); + + } else { + + throw ("Could not find NekoAPI interface."); + + } + + __loadedNekoAPI = true; + + } + + } + + #end + + +} \ No newline at end of file diff --git a/lime/ui/IMouseEventListener.hx b/lime/ui/IMouseEventListener.hx new file mode 100644 index 000000000..6757cf978 --- /dev/null +++ b/lime/ui/IMouseEventListener.hx @@ -0,0 +1,12 @@ +package lime.ui; + + +interface IMouseEventListener { + + + function onMouseDown (event:MouseEvent):Void; + function onMouseMove (event:MouseEvent):Void; + function onMouseUp (event:MouseEvent):Void; + + +} \ No newline at end of file diff --git a/lime/ui/ITouchEventListener.hx b/lime/ui/ITouchEventListener.hx new file mode 100644 index 000000000..a94ae5922 --- /dev/null +++ b/lime/ui/ITouchEventListener.hx @@ -0,0 +1,12 @@ +package lime.ui; + + +interface ITouchEventListener { + + + function onTouchEnd (event:TouchEvent):Void; + function onTouchMove (event:TouchEvent):Void; + function onTouchStart (event:TouchEvent):Void; + + +} \ No newline at end of file diff --git a/lime/ui/MouseEvent.hx b/lime/ui/MouseEvent.hx new file mode 100644 index 000000000..b668d1978 --- /dev/null +++ b/lime/ui/MouseEvent.hx @@ -0,0 +1,14 @@ +package lime.ui; + + +class MouseEvent { + + + public function new () { + + + + } + + +} \ No newline at end of file diff --git a/lime/ui/TouchEvent.hx b/lime/ui/TouchEvent.hx new file mode 100644 index 000000000..cfd99a976 --- /dev/null +++ b/lime/ui/TouchEvent.hx @@ -0,0 +1,14 @@ +package lime.ui; + + +class TouchEvent { + + + public function new () { + + + + } + + +} \ No newline at end of file diff --git a/lime/utils/ArrayBuffer.hx b/lime/utils/ArrayBuffer.hx deleted file mode 100644 index 1a18721ed..000000000 --- a/lime/utils/ArrayBuffer.hx +++ /dev/null @@ -1,4 +0,0 @@ -package lime.utils; - - -typedef ArrayBuffer = lime.utils.ByteArray; \ No newline at end of file diff --git a/lime/utils/ArrayBufferView.hx b/lime/utils/ArrayBufferView.hx deleted file mode 100644 index 1e19bb835..000000000 --- a/lime/utils/ArrayBufferView.hx +++ /dev/null @@ -1,197 +0,0 @@ -package lime.utils; - -#if lime_html5 - - typedef ArrayBufferView = js.html.ArrayBufferView; - -#else - - 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)) { - - 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 - - } - } - -#end //lime_native \ No newline at end of file diff --git a/lime/utils/Assets.hx b/lime/utils/Assets.hx deleted file mode 100644 index f7c0134ba..000000000 --- a/lime/utils/Assets.hx +++ /dev/null @@ -1,230 +0,0 @@ -package lime.utils; - -#if !macro - -import haxe.Unserializer; -import lime.utils.ByteArray; - -#if (tools && !display) - import lime.AssetData; -#end - -#if swf - #if js - import format.swf.lite.SWFLite; - #else - import format.SWF; - import lime.utils.UInt8Array; - #end //js -#end //swf - - - /** - *

The Assets class provides a cross-platform interface to access - * embedded images, fonts, sounds and other resource files.

- * - *

The contents are populated automatically when an application - * is compiled using the lime command-line tools, based on the - * contents of the *.nmml project file.

- * - *

For most platforms, the assets are included in the same directory - * or package as the application, and the paths are handled - * automatically. For web content, the assets are preloaded before - * the start of the rest of the application. You can customize the - * preloader by extending the NMEPreloader class, - * and specifying a custom preloader using - * in the project file.

- */ - class Assets { - - private static var initialized = false; - - public static var id (get, null) : Array; - public static var library (get, null) : Map; - public static var path (get, null) : Map; - public static var type (get, null) : Map; - - #if swf private static var cachedSWFLibraries = new Map(); #end - - private static function initialize():Void { - - if(!initialized) { - - #if (tools && !display) - AssetData.initialize(); - #end //(tools && !display) - - initialized = true; - - } //if(!initialized) - - } //initialize - - /** - * Gets an instance of an embedded binary asset - * @usage var bytes = Assets.getBytes("file.zip"); - * @param id The ID or asset path for the file - * @return A new ByteArray object - */ - public static function getBytes(id:String):ByteArray { - - initialize(); - - if (AssetData.type.exists(id)) { - - #if lime_html5 - - var req = new haxe.Http(id); - var results : Dynamic = null; - - req.async = false; - req.onData = function(e) { - results = e; - } - req.request(); - req = null; - - var len : Int = results.length; - var bytearray : ByteArray = new ByteArray(); - for( i in 0 ... len ) { - bytearray.writeByte(results.charCodeAt(i)); - } - - bytearray.position = 0; - return bytearray; - - #else //lime_html5 - - return ByteArray.readFile(AssetData.path.get(id)); - - #end - - } else { - trace("[lime.utils.Assets] There is no String or ByteArray asset with an ID of \"" + id + "\""); - } - - return null; - - } //getBytes - - - /** - * Gets an instance of an embedded text asset - * @usage var text = Assets.getText("text.txt"); - * @param id The ID or asset path for the file - * @return A new String object - */ - public static function getText(id:String):String { - - #if lime_native - var bytes = getBytes(id); - if (bytes == null) { - return null; - } else { - return bytes.readUTFBytes(bytes.length); - } - #end //lime_native - - #if lime_html5 - - var req = new haxe.Http(id); - var results : Dynamic; - - req.async = false; - req.onData = function(e) { results = e; } - req.request(); - req = null; - - return results; - - #end //lime_html5 - - } - - - #if js - - 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); - } - - #end //js - - - // Getters & Setters - private static function get_id():Array { - - initialize (); - - var ids = []; - - #if (tools && !display) - for (key in AssetData.type.keys ()) { - ids.push (key); - } - #end - - return ids; - - } //get_id - - private static function get_library():Map { - - initialize (); - - #if (tools && !display) - return AssetData.library; - #else - return new Map(); - #end - - } //get_library - - - private static function get_path():Map { - - initialize (); - - #if ((tools && !display) && !flash) - return AssetData.path; - #else - return new Map (); - #end - - } //get_path - - - private static function get_type():Map { - - initialize (); - - #if (tools && !display) - return AssetData.type; - #else - return new Map (); - #end - - } //get_type - - - } //Assets - - - enum AssetType { - BINARY; - TEXT; - } - - - enum LibraryType { - SWF; - } - -#end //!macro \ No newline at end of file diff --git a/lime/utils/ByteArray.hx b/lime/utils/ByteArray.hx deleted file mode 100644 index 3ef607d63..000000000 --- a/lime/utils/ByteArray.hx +++ /dev/null @@ -1,7 +0,0 @@ -package lime.utils; - -#if lime_html5 - typedef ByteArray = lime.utils.html5.ByteArray; -#else - typedef ByteArray = lime.utils.native.ByteArray; -#end //lime_html5 diff --git a/lime/utils/CompressionAlgorithm.hx b/lime/utils/CompressionAlgorithm.hx deleted file mode 100644 index 4087e8c56..000000000 --- a/lime/utils/CompressionAlgorithm.hx +++ /dev/null @@ -1,14 +0,0 @@ -package lime.utils; -#if (lime_native || lime_html5) -// #if (cpp || neko) - -enum CompressionAlgorithm { - DEFLATE; - ZLIB; - LZMA; - GZIP; -} - -#else -typedef CompressionAlgorithm = flash.utils.CompressionAlgorithm; -#end \ No newline at end of file diff --git a/lime/utils/Endian.hx b/lime/utils/Endian.hx deleted file mode 100644 index 9c5d7db34..000000000 --- a/lime/utils/Endian.hx +++ /dev/null @@ -1,9 +0,0 @@ -package lime.utils; - - -class Endian { - - public static inline var BIG_ENDIAN : String = "bigEndian"; - public static inline var LITTLE_ENDIAN : String = "littleEndian"; - -} \ No newline at end of file diff --git a/lime/utils/Float32Array.hx b/lime/utils/Float32Array.hx deleted file mode 100644 index a19856e95..000000000 --- a/lime/utils/Float32Array.hx +++ /dev/null @@ -1,93 +0,0 @@ -package lime.utils; - -#if lime_html5 - - typedef Float32Array = js.html.Float32Array; - -#else - - import lime.utils.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) { - - BYTES_PER_ELEMENT = 4; - - if (Std.is (bufferOrArray, Int)) { - - super (Std.int (bufferOrArray) * BYTES_PER_ELEMENT); - this.length = bufferOrArray; - - } 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 { - - super (bufferOrArray, start, length << 2 ); - - if ((byteLength & 0x03) > 0) { - - throw("Invalid array size"); - - } - - this.length = byteLength >> 2; - - if ((this.length << 2) != byteLength) { - - throw "Invalid length multiple"; - - } - } - } - - - public function clear() { - length = 0; - } - - 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); } - - - } - -#end //lime_native diff --git a/lime/utils/IDataInput.hx b/lime/utils/IDataInput.hx deleted file mode 100644 index ea2c32f31..000000000 --- a/lime/utils/IDataInput.hx +++ /dev/null @@ -1,35 +0,0 @@ -package lime.utils; -// #if (cpp || neko) -#if (lime_native || lime_html5) - -interface IDataInput -{ - public var bytesAvailable(get_bytesAvailable, null):Int; - public var endian(get_endian, set_endian):String; - - public function readBoolean():Bool; - public function readByte():Int; - public function readBytes(outData:ByteArray, inOffset:Int = 0, inLen:Int = 0):Void; - public function readDouble():Float; - public function readFloat():Float; - public function readInt():Int; - - // not implemented ... - //var objectEncoding : UInt; - //public function readMultiByte(length : Int, charSet:String):String; - //public function readObject():Dynamic; - public function readShort():Int; - public function readUnsignedByte():Int; - public function readUnsignedInt():Int; - public function readUnsignedShort():Int; - public function readUTF():String; - public function readUTFBytes(inLen:Int):String; - - private function get_bytesAvailable():Int; - private function get_endian():String; - private function set_endian(s:String):String; -} - -#else -typedef IDataInput = flash.utils.IDataInput; -#end \ No newline at end of file diff --git a/lime/utils/IMemoryRange.hx b/lime/utils/IMemoryRange.hx deleted file mode 100644 index 4924a0014..000000000 --- a/lime/utils/IMemoryRange.hx +++ /dev/null @@ -1,13 +0,0 @@ -package lime.utils; - - -import lime.utils.ByteArray; - - -interface IMemoryRange { - - public function getByteBuffer ():ByteArray; - public function getStart ():Int; - public function getLength ():Int; - -} \ No newline at end of file diff --git a/lime/utils/Int16Array.hx b/lime/utils/Int16Array.hx deleted file mode 100644 index 666efd2ac..000000000 --- a/lime/utils/Int16Array.hx +++ /dev/null @@ -1,88 +0,0 @@ -package lime.utils; - - -#if lime_html5 - - typedef Int16Array = js.html.Int16Array; - -#end //lime_html5 - -#if lime_native - - class Int16Array extends ArrayBufferView implements ArrayAccess { - - - static public inline var SBYTES_PER_ELEMENT = 2; - - 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) { - - BYTES_PER_ELEMENT = 2; - - if (Std.is (bufferOrArray, Int)) { - - super (Std.int (bufferOrArray) << 1); - - } 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 << 1); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i16 (bytes, (i << 1), ints[i]); - #else - buffer.writeShort (ints[i + start]); - #end - - } - - } else { - - super (bufferOrArray, start, length); - - if ((byteLength & 0x01) > 0) { - - throw ("Invalid array size"); - - } - - this.length = byteLength >> 1; - - if ((this.length << 1) != byteLength) { - - throw "Invalid length multiple"; - - } - - } - - } - - - @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt16 (index << 1); } - @:noCompletion @:keep inline public function __set (index:Int, value:Int):Void { setInt16 (index << 1, value); } - - - } - -#end //lime_native diff --git a/lime/utils/Int32Array.hx b/lime/utils/Int32Array.hx deleted file mode 100644 index 9170fde12..000000000 --- a/lime/utils/Int32Array.hx +++ /dev/null @@ -1,88 +0,0 @@ -package lime.utils; - -#if lime_html5 - - typedef Int32Array = js.html.Int32Array; - -#end //lime_html5 - -#if lime_native - - @: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) { - - BYTES_PER_ELEMENT = 4; - - if (Std.is (bufferOrArray, Int)) { - - 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 { - - 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"; - - } - - } - - } - - - @: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); } - - - } - -#end //lime_native \ No newline at end of file diff --git a/lime/utils/JNI.hx b/lime/utils/JNI.hx deleted file mode 100644 index 3dfdea31c..000000000 --- a/lime/utils/JNI.hx +++ /dev/null @@ -1,150 +0,0 @@ -package lime.utils; -#if (android) - -import lime.utils.Libs; - -import cpp.zip.Uncompress; -import haxe.crypto.BaseCode; -import haxe.io.Bytes; - - -class JNI { - - - private static var initialized = false; - - - private static function init ():Void { - - if (!initialized) { - - initialized = true; - var method = Libs.load ("lime", "lime_jni_init_callback", 1); - method (onCallback); - - } - - } - - - private static function onCallback (object:Dynamic, method:Dynamic, args:Dynamic):Dynamic { - - var field = Reflect.field (object, method); - - if (field != null) { - - return Reflect.callMethod (object, field, args); - - } - - trace ("onCallback - unknown field " + method); - return null; - - } - - - public static function createMemberMethod (className:String, memberName:String, signature:String, useArray:Bool = false):Dynamic { - - init (); - - var method = new JNIMethod (lime_jni_create_method (className, memberName, signature, false)); - return method.getMemberMethod (useArray); - - } - - - public static function createStaticMethod (className:String, memberName:String, signature:String, useArray:Bool = false):Dynamic { - - init (); - - var method = new JNIMethod (lime_jni_create_method (className, memberName, signature, true)); - return method.getStaticMethod (useArray); - - } - - - - - // Native Methods - - - - - private static var lime_jni_create_method = Libs.load ("lime", "lime_jni_create_method", 4); - - -} - - -class JNIMethod { - - - private var method:Dynamic; - - - public function new (method:Dynamic) { - - this.method = method; - - } - - public function callMember (args:Array):Dynamic { - - var jobject = args.shift (); - return lime_jni_call_member (method, jobject, args); - - } - - - public function callStatic (args:Array):Dynamic { - - return lime_jni_call_static (method, args); - - } - - - public function getMemberMethod (useArray:Bool):Dynamic { - - if (useArray) { - - return callMember; - - } else { - - return Reflect.makeVarArgs (callMember); - - } - - } - - - public function getStaticMethod (useArray:Bool):Dynamic { - - if (useArray) { - - return callStatic; - - } else { - - return Reflect.makeVarArgs (callStatic); - - } - - } - - - - - // Native Methods - - - - - private static var lime_jni_call_member = Libs.load ("lime", "lime_jni_call_member", 3); - private static var lime_jni_call_static = Libs.load ("lime", "lime_jni_call_static", 2); - - -} - - -#end \ No newline at end of file diff --git a/lime/utils/Libs.hx b/lime/utils/Libs.hx deleted file mode 100644 index a5ef0e723..000000000 --- a/lime/utils/Libs.hx +++ /dev/null @@ -1,256 +0,0 @@ -package lime.utils; - -class Libs { - - //for Load function - @:noCompletion private static var __moduleNames:Map = null; - -// -//todo clean this up a bit -// - - private static function tryLoad (name:String, library:String, func:String, args:Int):Dynamic { - - - #if lime_native - - 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) { - - loaderTrace ("Got result " + name); - __moduleNames.set (library, name); - return result; - - } - - } catch (e:Dynamic) { - - loaderTrace ("Failed to load : " + name); - - } - - #end //lime_native - - return null; - - } - -//neko only - #if neko - private static function loadNekoAPI ():Void { - - var init = load ("lime", "neko_init", 5); - - if (init != null) { - - loaderTrace ("Found nekoapi @ " + __moduleNames.get ("lime")); - init (function(s) return new String (s), function (len:Int) { var r = []; if (len > 0) r[len - 1] = null; return r; }, null, true, false); - - } else { - - throw ("Could not find NekoAPI interface."); - - } - - } - #end -//neko only end - - static private function findHaxeLib (library:String):String { - - try { - - #if lime_native - - var proc = new sys.io.Process ("haxelib", [ "path", library ]); - - if (proc != null) { - - var stream = proc.stdout; - - try { - - while (true) { - - var s = stream.readLine (); - - if (s.substr (0, 1) != "-") { - - stream.close (); - proc.close (); - loaderTrace ("Found haxelib " + s); - return s; - - } - - } - - } catch(e:Dynamic) { } - - stream.close (); - proc.close (); - - } - - #end //lime_native - - } catch (e:Dynamic) { } - - return ""; - - } - - private static function sysName ():String { - - #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 - - } - -#if lime_html5 - - public static var _html5_libs:Map; - - public static function html5_add_lib( library:String, root:Dynamic ) { - - if(_html5_libs == null) { - _html5_libs = new Map(); - } - - _html5_libs.set( library, root ); - - return true; - } - - public static function html5_lib_load(library:String, method:String) { - - if(_html5_libs == null) { - _html5_libs = new Map(); - } - - var _root = _html5_libs.get(library); - if(_root != null) { - return Reflect.field(_root, method); - } - - return null; - - } //html5_lib_load - -#end //lime_html5 - - public static function load (library:String, method:String, args:Int = 0):Dynamic { - - #if (iphone || emscripten || android) - return cpp.Lib.load (library, method, args); - #end - - #if lime_html5 - var found_in_html5_libs = html5_lib_load( library, method ); - if(found_in_html5_libs) return found_in_html5_libs; - #end //lime_html5 - - if (__moduleNames == null) __moduleNames = new Map (); - if (__moduleNames.exists (library)) { - - #if cpp - return cpp.Lib.load (__moduleNames.get (library), method, args); - #elseif neko - return neko.Lib.load (__moduleNames.get (library), method, args); - #end - - } - - __moduleNames.set (library, library); - - var result:Dynamic = tryLoad ("./" + library, library, method, args); - - if (result == null) { - - result = tryLoad (".\\" + library, library, method, args); - - } - - if (result == null) { - - result = tryLoad (library, library, method, args); - - } - - if (result == null) { - - var slash = (sysName ().substr (7).toLowerCase () == "windows") ? "\\" : "/"; - var haxelib = findHaxeLib ("lime"); - - if (haxelib != "") { - result = tryLoad (haxelib + slash + "ndll" + slash + sysName () + slash + library, library, method, args); - if (result == null) { - result = tryLoad (haxelib + slash + "ndll" + slash + sysName() + "64" + slash + library, library, method, args); - } - } - - } - - loaderTrace ("Result : " + result); - - #if neko - if (library == "lime") { - loadNekoAPI (); - } - #end - - return result; - - } - - private static function loaderTrace (message:String) { - - #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/Matrix3D.hx b/lime/utils/Matrix3D.hx deleted file mode 100644 index eb60965ce..000000000 --- a/lime/utils/Matrix3D.hx +++ /dev/null @@ -1,494 +0,0 @@ -package lime.utils; - -// #if (cpp || neko) -#if (lime_native || lime_html5) - -import lime.utils.Vector; -import lime.utils.Vector3D; - -class Matrix3D -{ - public var determinant(get_determinant, null):Float; - public var position(get_position, set_position):Vector3D; - public var rawData:Vector; - - public function new(?v:Vector) - { - if (v != null && v.length == 16) - { - rawData = v; - - } else - { - rawData = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]; - } - } - - public function append(lhs:Matrix3D):Void - { - var m111:Float = this.rawData[0], m121:Float = this.rawData[4], m131:Float = this.rawData[8], m141:Float = this.rawData[12], - m112:Float = this.rawData[1], m122:Float = this.rawData[5], m132:Float = this.rawData[9], m142:Float = this.rawData[13], - m113:Float = this.rawData[2], m123:Float = this.rawData[6], m133:Float = this.rawData[10], m143:Float = this.rawData[14], - m114:Float = this.rawData[3], m124:Float = this.rawData[7], m134:Float = this.rawData[11], m144:Float = this.rawData[15], - m211:Float = lhs.rawData[0], m221:Float = lhs.rawData[4], m231:Float = lhs.rawData[8], m241:Float = lhs.rawData[12], - m212:Float = lhs.rawData[1], m222:Float = lhs.rawData[5], m232:Float = lhs.rawData[9], m242:Float = lhs.rawData[13], - m213:Float = lhs.rawData[2], m223:Float = lhs.rawData[6], m233:Float = lhs.rawData[10], m243:Float = lhs.rawData[14], - m214:Float = lhs.rawData[3], m224:Float = lhs.rawData[7], m234:Float = lhs.rawData[11], m244:Float = lhs.rawData[15]; - - rawData[0] = m111 * m211 + m112 * m221 + m113 * m231 + m114 * m241; - rawData[1] = m111 * m212 + m112 * m222 + m113 * m232 + m114 * m242; - rawData[2] = m111 * m213 + m112 * m223 + m113 * m233 + m114 * m243; - rawData[3] = m111 * m214 + m112 * m224 + m113 * m234 + m114 * m244; - - rawData[4] = m121 * m211 + m122 * m221 + m123 * m231 + m124 * m241; - rawData[5] = m121 * m212 + m122 * m222 + m123 * m232 + m124 * m242; - rawData[6] = m121 * m213 + m122 * m223 + m123 * m233 + m124 * m243; - rawData[7] = m121 * m214 + m122 * m224 + m123 * m234 + m124 * m244; - - rawData[8] = m131 * m211 + m132 * m221 + m133 * m231 + m134 * m241; - rawData[9] = m131 * m212 + m132 * m222 + m133 * m232 + m134 * m242; - rawData[10] = m131 * m213 + m132 * m223 + m133 * m233 + m134 * m243; - rawData[11] = m131 * m214 + m132 * m224 + m133 * m234 + m134 * m244; - - rawData[12] = m141 * m211 + m142 * m221 + m143 * m231 + m144 * m241; - rawData[13] = m141 * m212 + m142 * m222 + m143 * m232 + m144 * m242; - rawData[14] = m141 * m213 + m142 * m223 + m143 * m233 + m144 * m243; - rawData[15] = m141 * m214 + m142 * m224 + m143 * m234 + m144 * m244; - } - - public function appendRotation(degrees:Float, axis:Vector3D, ?pivotPoint:Vector3D):Void - { - var m = getAxisRotation(axis.x, axis.y, axis.z, degrees); - - if (pivotPoint != null) - { - var p = pivotPoint; - m.appendTranslation(p.x, p.y, p.z); - } - - this.append(m); - } - - inline public function appendScale(xScale:Float, yScale:Float, zScale:Float):Void - { - this.append(new Matrix3D([xScale, 0.0, 0.0, 0.0, 0.0, yScale, 0.0, 0.0, 0.0, 0.0, zScale, 0.0, 0.0, 0.0, 0.0, 1.0])); - } - - inline public function appendTranslation(x:Float, y:Float, z:Float):Void - { - rawData[12] += x; - rawData[13] += y; - rawData[14] += z; - } - - inline public function clone():Matrix3D - { - return new Matrix3D(this.rawData.copy()); - } - - public static function create2D(x:Float, y:Float, scale:Float = 1, rotation:Float = 0) - { - var theta = rotation * Math.PI / 180.0; - var c = Math.cos(theta); - var s = Math.sin(theta); - - return new Matrix3D([ - c*scale, -s*scale, 0, 0, - s*scale, c*scale, 0, 0, - 0, 0, 1, 0, - x, y, 0, 1 - ]); - } - - public static function createABCD(a:Float, b:Float, c:Float, d:Float, tx:Float, ty:Float) - { - return new Matrix3D([ - a, b, 0, 0, - c, d, 0, 0, - 0, 0, 1, 0, - tx,ty,0, 1 - ]); - } - - public static function createOrtho(x0:Float, x1:Float, y0:Float, y1:Float, zNear:Float, zFar:Float) - { - var sx = 1.0 / (x1 - x0); - var sy = 1.0 / (y1 - y0); - var sz = 1.0 / (zFar - zNear); - - return new Matrix3D([ - 2.0*sx, 0, 0, 0, - 0, 2.0*sy, 0, 0, - 0, 0, -2.0*sz, 0, - - (x0+x1)*sx, - (y0+y1)*sy, - (zNear+zFar)*sz, 1, - ]); - } - - public function decompose():Vector - { - var vec = new Vector(); - var m = this.clone(); - var mr = m.rawData; - - var pos = new Vector3D(mr[12], mr[13], mr[14]); - mr[12] = 0; - mr[13] = 0; - mr[14] = 0; - - var scale = new Vector3D(); - - scale.x = Math.sqrt(mr[0] * mr[0] + mr[1] * mr[1] + mr[2] * mr[2]); - scale.y = Math.sqrt(mr[4] * mr[4] + mr[5] * mr[5] + mr[6] * mr[6]); - scale.z = Math.sqrt(mr[8] * mr[8] + mr[9] * mr[9] + mr[10] * mr[10]); - - if (mr[0] * (mr[5] * mr[10] - mr[6] * mr[9]) - mr[1] * (mr[4] * mr[10] - mr[6] * mr[8]) + mr[2] * (mr[4] * mr[9] - mr[5] * mr[8]) < 0) - { - scale.z = -scale.z; - } - - mr[0] /= scale.x; - mr[1] /= scale.x; - mr[2] /= scale.x; - mr[4] /= scale.y; - mr[5] /= scale.y; - mr[6] /= scale.y; - mr[8] /= scale.z; - mr[9] /= scale.z; - mr[10] /= scale.z; - - var rot = new Vector3D(); - - rot.y = Math.asin( -mr[2]); - - var C = Math.cos(rot.y); - if (C > 0) - { - rot.x = Math.atan2(mr[6], mr[10]); - rot.z = Math.atan2(mr[1], mr[0]); - - } else - { - rot.z = 0; - rot.x = Math.atan2(mr[4], mr[5]); - } - - vec.push(pos); - vec.push(rot); - vec.push(scale); - - return vec; - } - - inline public function deltaTransformVector(v:Vector3D):Vector3D - { - var x:Float = v.x, y:Float = v.y, z:Float = v.z; - return new Vector3D( - (x * rawData[0] + y * rawData[1] + z * rawData[2] + rawData[3]), - (x * rawData[4] + y * rawData[5] + z * rawData[6] + rawData[7]), - (x * rawData[8] + y * rawData[9] + z * rawData[10] + rawData[11]), - 0); - } - - inline static public function getAxisRotation(x:Float, y:Float, z:Float, degrees:Float):Matrix3D - { - var m = new Matrix3D(); - - var a1 = new Vector3D(x, y, z); - var rad = -degrees * (Math.PI / 180); - var c:Float = Math.cos(rad); - var s:Float = Math.sin(rad); - var t:Float = 1.0 - c; - - m.rawData[0] = c + a1.x * a1.x * t; - m.rawData[5] = c + a1.y * a1.y * t; - m.rawData[10] = c + a1.z * a1.z * t; - - var tmp1 = a1.x * a1.y * t; - var tmp2 = a1.z * s; - m.rawData[4] = tmp1 + tmp2; - m.rawData[1] = tmp1 - tmp2; - tmp1 = a1.x * a1.z * t; - tmp2 = a1.y * s; - m.rawData[8] = tmp1 - tmp2; - m.rawData[2] = tmp1 + tmp2; - tmp1 = a1.y * a1.z * t; - tmp2 = a1.x*s; - m.rawData[9] = tmp1 + tmp2; - m.rawData[6] = tmp1 - tmp2; - - return m; - } - - inline public function identity():Void - { - rawData[0] = 1; - rawData[1] = 0; - rawData[2] = 0; - rawData[3] = 0; - rawData[4] = 0; - rawData[5] = 1; - rawData[6] = 0; - rawData[7] = 0; - rawData[8] = 0; - rawData[9] = 0; - rawData[10] = 1; - rawData[11] = 0; - rawData[12] = 0; - rawData[13] = 0; - rawData[14] = 0; - rawData[15] = 1; - } - - inline public static function interpolate(thisMat:Matrix3D, toMat:Matrix3D, percent:Float):Matrix3D - { - var m = new Matrix3D(); - - for(i in 0...16) - { - m.rawData[i] = thisMat.rawData[i] + (toMat.rawData[i] - thisMat.rawData[i]) * percent; - } - - return m; - } - - inline public function interpolateTo(toMat:Matrix3D, percent:Float):Void - { - for(i in 0...16) - { - rawData[i] = rawData[i] + (toMat.rawData[i] - rawData[i]) * percent; - } - } - - inline public function invert():Bool - { - var d = determinant; - var invertable = Math.abs(d) > 0.00000000001; - - if (invertable) - { - d = -1 / d; - var m11:Float = rawData[0]; var m21:Float = rawData[4]; var m31:Float = rawData[8]; var m41:Float = rawData[12]; - var m12:Float = rawData[1]; var m22:Float = rawData[5]; var m32:Float = rawData[9]; var m42:Float = rawData[13]; - var m13:Float = rawData[2]; var m23:Float = rawData[6]; var m33:Float = rawData[10]; var m43:Float = rawData[14]; - var m14:Float = rawData[3]; var m24:Float = rawData[7]; var m34:Float = rawData[11]; var m44:Float = rawData[15]; - - rawData[0] = d * (m22 * (m33 * m44 - m43 * m34) - m32 * (m23 * m44 - m43 * m24) + m42 * (m23 * m34 - m33 * m24)); - rawData[1] = -d * (m12 * (m33 * m44 - m43 * m34) - m32 * (m13 * m44 - m43 * m14) + m42 * (m13 * m34 - m33 * m14)); - rawData[2] = d * (m12 * (m23 * m44 - m43 * m24) - m22 * (m13 * m44 - m43 * m14) + m42 * (m13 * m24 - m23 * m14)); - rawData[3] = -d * (m12 * (m23 * m34 - m33 * m24) - m22 * (m13 * m34 - m33 * m14) + m32 * (m13 * m24 - m23 * m14)); - rawData[4] = -d * (m21 * (m33 * m44 - m43 * m34) - m31 * (m23 * m44 - m43 * m24) + m41 * (m23 * m34 - m33 * m24)); - rawData[5] = d * (m11 * (m33 * m44 - m43 * m34) - m31 * (m13 * m44 - m43 * m14) + m41 * (m13 * m34 - m33 * m14)); - rawData[6] = -d * (m11 * (m23 * m44 - m43 * m24) - m21 * (m13 * m44 - m43 * m14) + m41 * (m13 * m24 - m23 * m14)); - rawData[7] = d * (m11 * (m23 * m34 - m33 * m24) - m21 * (m13 * m34 - m33 * m14) + m31 * (m13 * m24 - m23 * m14)); - rawData[8] = d * (m21 * (m32 * m44 - m42 * m34) - m31 * (m22 * m44 - m42 * m24) + m41 * (m22 * m34 - m32 * m24)); - rawData[9] = -d * (m11 * (m32 * m44 - m42 * m34) - m31 * (m12 * m44 - m42 * m14) + m41 * (m12 * m34 - m32 * m14)); - rawData[10] = d * (m11 * (m22 * m44 - m42 * m24) - m21 * (m12 * m44 - m42 * m14) + m41 * (m12 * m24 - m22 * m14)); - rawData[11] = -d * (m11 * (m22 * m34 - m32 * m24) - m21 * (m12 * m34 - m32 * m14) + m31 * (m12 * m24 - m22 * m14)); - rawData[12] = -d * (m21 * (m32 * m43 - m42 * m33) - m31 * (m22 * m43 - m42 * m23) + m41 * (m22 * m33 - m32 * m23)); - rawData[13] = d * (m11 * (m32 * m43 - m42 * m33) - m31 * (m12 * m43 - m42 * m13) + m41 * (m12 * m33 - m32 * m13)); - rawData[14] = -d * (m11 * (m22 * m43 - m42 * m23) - m21 * (m12 * m43 - m42 * m13) + m41 * (m12 * m23 - m22 * m13)); - rawData[15] = d * (m11 * (m22 * m33 - m32 * m23) - m21 * (m12 * m33 - m32 * m13) + m31 * (m12 * m23 - m22 * m13)); - } - - return invertable; - } -/* - public function pointAt(pos:phoenix.Vector, ?at:phoenix.Vector, ?up:phoenix.Vector):Matrix3D { - if (at == null) at = new phoenix.Vector(0,0,-1); - if (up == null) up = new phoenix.Vector(0,-1,0); - - //pos.x*=-1; - //pos.y*=-1; - //pos.z*=-1; - //at.x*=-1; - //at.y*=-1; - //at.z*=-1; - //up.x*=-1; - //up.y*=-1; - //up.z*=-1; - var dir:phoenix.Vector = at.subtract(pos); - var vup:phoenix.Vector = up.clone(); - var right:phoenix.Vector; - - dir.normalized; - vup.normalized; - - var dir2 = dir.clone(); - dir2.multiply_(vup.dot(dir)); - - vup = vup.subtract(dir2); - - if (vup.length > 0) - { - vup.normalized; - } else - { - vup = dir.x != 0 ? new phoenix.Vector(-dir.y,dir.x,0) : new phoenix.Vector(1,0,0); - } - - right = phoenix.Vector.Cross(vup, dir); - right.normalized; - - rawData[0] = right.x; - rawData[4] = right.y; - rawData[8] = right.z; - rawData[12] = 0.0; - rawData[1] = vup.x; - rawData[5] = vup.y; - rawData[9] = vup.z; - rawData[13] = 0.0; - rawData[2] = dir.x; - rawData[6] = dir.y; - rawData[10] = dir.z; - rawData[14] = 0.0; - rawData[3] = pos.x; - rawData[7] = pos.y; - rawData[11] = pos.z; - rawData[15] = 1.0; - - return this; - } -*/ - inline public function prepend(rhs:Matrix3D):Void - { - var m111:Float = rhs.rawData[0], m121:Float = rhs.rawData[4], m131:Float = rhs.rawData[8], m141:Float = rhs.rawData[12], - m112:Float = rhs.rawData[1], m122:Float = rhs.rawData[5], m132:Float = rhs.rawData[9], m142:Float = rhs.rawData[13], - m113:Float = rhs.rawData[2], m123:Float = rhs.rawData[6], m133:Float = rhs.rawData[10], m143:Float = rhs.rawData[14], - m114:Float = rhs.rawData[3], m124:Float = rhs.rawData[7], m134:Float = rhs.rawData[11], m144:Float = rhs.rawData[15], - m211:Float = this.rawData[0], m221:Float = this.rawData[4], m231:Float = this.rawData[8], m241:Float = this.rawData[12], - m212:Float = this.rawData[1], m222:Float = this.rawData[5], m232:Float = this.rawData[9], m242:Float = this.rawData[13], - m213:Float = this.rawData[2], m223:Float = this.rawData[6], m233:Float = this.rawData[10], m243:Float = this.rawData[14], - m214:Float = this.rawData[3], m224:Float = this.rawData[7], m234:Float = this.rawData[11], m244:Float = this.rawData[15]; - - rawData[0] = m111 * m211 + m112 * m221 + m113 * m231 + m114 * m241; - rawData[1] = m111 * m212 + m112 * m222 + m113 * m232 + m114 * m242; - rawData[2] = m111 * m213 + m112 * m223 + m113 * m233 + m114 * m243; - rawData[3] = m111 * m214 + m112 * m224 + m113 * m234 + m114 * m244; - - rawData[4] = m121 * m211 + m122 * m221 + m123 * m231 + m124 * m241; - rawData[5] = m121 * m212 + m122 * m222 + m123 * m232 + m124 * m242; - rawData[6] = m121 * m213 + m122 * m223 + m123 * m233 + m124 * m243; - rawData[7] = m121 * m214 + m122 * m224 + m123 * m234 + m124 * m244; - - rawData[8] = m131 * m211 + m132 * m221 + m133 * m231 + m134 * m241; - rawData[9] = m131 * m212 + m132 * m222 + m133 * m232 + m134 * m242; - rawData[10] = m131 * m213 + m132 * m223 + m133 * m233 + m134 * m243; - rawData[11] = m131 * m214 + m132 * m224 + m133 * m234 + m134 * m244; - - rawData[12] = m141 * m211 + m142 * m221 + m143 * m231 + m144 * m241; - rawData[13] = m141 * m212 + m142 * m222 + m143 * m232 + m144 * m242; - rawData[14] = m141 * m213 + m142 * m223 + m143 * m233 + m144 * m243; - rawData[15] = m141 * m214 + m142 * m224 + m143 * m234 + m144 * m244; - } - - inline public function prependRotation(degrees:Float, axis:Vector3D, ?pivotPoint:Vector3D):Void - { - var m = getAxisRotation(axis.x, axis.y, axis.z, degrees); - - if (pivotPoint != null) - { - var p = pivotPoint; - m.appendTranslation(p.x, p.y, p.z); - } - - this.prepend(m); - } - - inline public function prependScale(xScale:Float, yScale:Float, zScale:Float):Void - { - this.prepend(new Matrix3D([xScale, 0.0, 0.0, 0.0, 0.0, yScale, 0.0, 0.0, 0.0, 0.0, zScale, 0.0, 0.0, 0.0, 0.0, 1.0])); - } - - inline public function prependTranslation(x:Float, y:Float, z:Float):Void - { - var m = new Matrix3D(); - m.position = new Vector3D(x, y, z); - this.prepend(m); - } - - public function recompose(components:Vector):Bool - { - if (components.length < 3 || components[2].x == 0 || components[2].y == 0 || components[2].z == 0) return false; - - this.identity(); - this.appendScale(components[2].x, components[2].y, components[2].z); - - var angle:Float; - angle = -components[1].x; - this.append(new Matrix3D([1, 0, 0, 0, 0, Math.cos(angle), -Math.sin(angle), 0, 0, Math.sin(angle), Math.cos(angle), 0, 0, 0, 0 , 0])); - angle = -components[1].y; - this.append(new Matrix3D([Math.cos(angle), 0, Math.sin(angle), 0, 0, 1, 0, 0, -Math.sin(angle), 0, Math.cos(angle), 0, 0, 0, 0, 0])); - angle = -components[1].z; - this.append(new Matrix3D([Math.cos(angle), -Math.sin(angle), 0, 0, Math.sin(angle), Math.cos(angle), 0, 0, 0, 0, 1, 0, 0, 0, 0, 0])); - - this.position = components[0]; - this.rawData[15] = 1; - - return true; - } - - inline public function transformVector(v:Vector3D):Vector3D - { - var x:Float = v.x, y:Float = v.y, z:Float = v.z; - return new Vector3D( - (x * rawData[0] + y * rawData[4] + z * rawData[8] + rawData[12]), - (x * rawData[1] + y * rawData[5] + z * rawData[9] + rawData[13]), - (x * rawData[2] + y * rawData[6] + z * rawData[10] + rawData[14]), - 1); - } - - public function transformVectors(vin:Vector, vout:Vector):Void - { - var i = 0; - while(i + 3 <= vin.length) - { - var x:Float = vin[i], y:Float = vin[i + 1], z:Float = vin[i + 2]; - vout[i] = x * rawData[0] + y * rawData[4] + z * rawData[8] + rawData[12]; - vout[i + 1] = x * rawData[1] + y * rawData[5] + z * rawData[9] + rawData[13]; - vout[i + 2] = x * rawData[2] + y * rawData[6] + z * rawData[10] + rawData[14]; - i += 3; - } - } - - inline public function transpose():Void - { - var oRawData = rawData.copy(); - rawData[1] = oRawData[4]; - rawData[2] = oRawData[8]; - rawData[3] = oRawData[12]; - rawData[4] = oRawData[1]; - rawData[6] = oRawData[9]; - rawData[7] = oRawData[13]; - rawData[8] = oRawData[2]; - rawData[9] = oRawData[6]; - rawData[11] = oRawData[14]; - rawData[12] = oRawData[3]; - rawData[13] = oRawData[7]; - rawData[14] = oRawData[11]; - } - - // Getters & Setters - /** @private */ inline public function get_determinant():Float { - return -1 * ((rawData[0] * rawData[5] - rawData[4] * rawData[1]) * (rawData[10] * rawData[15] - rawData[14] * rawData[11]) - - (rawData[0] * rawData[9] - rawData[8] * rawData[1]) * (rawData[6] * rawData[15] - rawData[14] * rawData[7]) - + (rawData[0] * rawData[13] - rawData[12] * rawData[1]) * (rawData[6] * rawData[11] - rawData[10] * rawData[7]) - + (rawData[4] * rawData[9] - rawData[8] * rawData[5]) * (rawData[2] * rawData[15] - rawData[14] * rawData[3]) - - (rawData[4] * rawData[13] - rawData[12] * rawData[5]) * (rawData[2] * rawData[11] - rawData[10] * rawData[3]) - + (rawData[8] * rawData[13] - rawData[12] * rawData[9]) * (rawData[2] * rawData[7] - rawData[6] * rawData[3])); - } - - /** @private */ inline public function get_position():Vector3D { - return new Vector3D(rawData[12], rawData[13], rawData[14]); - } - - /** @private */ inline public function set_position(val:Vector3D):Vector3D { - rawData[12] = val.x; - rawData[13] = val.y; - rawData[14] = val.z; - return val; - } -} - -#else -typedef Matrix3D = Dynamic; //todo ; flash.geom.Matrix3D; -#end diff --git a/lime/utils/UInt8Array.hx b/lime/utils/UInt8Array.hx deleted file mode 100644 index e8c8f1808..000000000 --- a/lime/utils/UInt8Array.hx +++ /dev/null @@ -1,72 +0,0 @@ -package lime.utils; - -#if lime_html5 - - typedef UInt8Array = js.html.Uint8Array; - -#else - - 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) { - - BYTES_PER_ELEMENT = 1; - - if (Std.is (bufferOrArray, Int)) { - - 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 { - - 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); } - - - } - -#end //lime_native \ No newline at end of file diff --git a/lime/utils/Vector.hx b/lime/utils/Vector.hx deleted file mode 100644 index 91c98bbec..000000000 --- a/lime/utils/Vector.hx +++ /dev/null @@ -1,205 +0,0 @@ -package lime.utils; - - -@:arrayAccess abstract Vector(Array) { - - - public var length (get, set):Int; - public var fixed (get, set):Bool; - - - public function new (?length:Int, ?fixed:Bool):Void { - - this = new Array (); - - } - - - public function concat (?a:Array):Vector { - - return cast this.concat (a); - - } - - - public function copy ():Vector { - - return this.copy (); - - } - - - public function iterator ():Iterator { - - return this.iterator (); - - } - - - public function join (sep:String):String { - - return this.join (sep); - - } - - - public function pop ():Null { - - return this.pop (); - - } - - - public function push (x:T):Int { - - return this.push (x); - - } - - - public function reverse ():Void { - - this.reverse (); - - } - - - public function shift ():Null { - - return this.shift (); - - } - - - public function unshift (x:T):Void { - - this.unshift (x); - - } - - - public function slice (?pos:Int, ?end:Int):Vector { - - return cast this.slice (pos, end); - - } - - - public function sort (f:T -> T -> Int):Void { - - this.sort (f); - - } - - - public function splice (pos:Int, len:Int):Vector { - - return cast this.splice (pos, len); - - } - - - public function toString ():String { - - return this.toString (); - - } - - - public function indexOf (x:T, ?from:Int = 0):Int { - - for (i in from...this.length) { - - if (this[i] == x) { - - return i; - - } - - } - - return -1; - - } - - - public function lastIndexOf (x:T, ?from:Int = 0):Int { - - var i = this.length - 1; - - while (i >= from) { - - if (this[i] == x) return i; - i--; - - } - - return -1; - - } - - - public inline static function ofArray (a:Array):Vector { - - return new Vector ().concat (cast a); - - } - - - public inline static function convert (v:Array):Vector { - - return cast v; - - } - - - @:from static public inline function fromArray (a:Array):Vector { - - return cast a; - - } - - - @:to public inline function toArray ():Array { - - return this; - - } - - - - - // Getters & Setters - - - - - private function get_length ():Int { - - return this.length; - - } - - - private function set_length (value:Int):Int { - - return value; - - } - - - private function get_fixed ():Bool { - - return false; - - } - - - private function set_fixed (value:Bool):Bool { - - return value; - - } - - -} diff --git a/lime/utils/Vector3D.hx b/lime/utils/Vector3D.hx deleted file mode 100644 index 33199511a..000000000 --- a/lime/utils/Vector3D.hx +++ /dev/null @@ -1,155 +0,0 @@ -package lime.utils; -// #if (cpp || neko) -#if (lime_native || lime_html5) - -class Vector3D -{ - public static var X_AXIS(get_X_AXIS, null):Vector3D; - public static var Y_AXIS(get_Y_AXIS, null):Vector3D; - public static var Z_AXIS(get_Z_AXIS, null):Vector3D; - - public var length(get_length, null):Float; - public var lengthSquared(get_lengthSquared, null):Float; - public var w:Float; - public var x:Float; - public var y:Float; - public var z:Float; - - public function new(?x:Float = 0., ?y:Float = 0., ?z:Float = 0., ?w:Float = 0.) - { - this.w = w; - this.x = x; - this.y = y; - this.z = z; - } - - inline public function add(a:Vector3D):Vector3D - { - return new Vector3D(this.x + a.x, this.y + a.y, this.z + a.z); - } - - inline public static function angleBetween(a:Vector3D, b:Vector3D):Float - { - var a0 = a.clone(); - a0.normalize(); - var b0 = b.clone(); - b0.normalize(); - return Math.acos(a0.dotProduct(b0)); - } - - inline public function clone():Vector3D - { - return new Vector3D(x, y, z, w); - } - - inline public function copyFrom(sourceVector3D:Vector3D): Void { - x = sourceVector3D.x; - y = sourceVector3D.y; - z = sourceVector3D.z; - } - - inline public function crossProduct(a:Vector3D):Vector3D - { - return new Vector3D(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x, 1); - } - - inline public function decrementBy(a:Vector3D):Void - { - x -= a.x; - y -= a.y; - z -= a.z; - } - - inline public static function distance(pt1:Vector3D, pt2:Vector3D):Float - { - var x:Float = pt2.x - pt1.x; - var y:Float = pt2.y - pt1.y; - var z:Float = pt2.z - pt1.z; - - return Math.sqrt(x * x + y * y + z * z); - } - - inline public function dotProduct(a:Vector3D):Float - { - return x * a.x + y * a.y + z * a.z; - } - - inline public function equals(toCompare:Vector3D, ?allFour:Bool = false):Bool - { - return x == toCompare.x && y == toCompare.y && z == toCompare.z && (!allFour || w == toCompare.w); - } - - inline public function incrementBy(a:Vector3D):Void - { - x += a.x; - y += a.y; - z += a.z; - } - - inline public function nearEquals(toCompare:Vector3D, tolerance:Float, ?allFour:Bool = false):Bool - { - return Math.abs(x - toCompare.x) < tolerance && Math.abs(y - toCompare.y) < tolerance && Math.abs(z - toCompare.z) < tolerance && (!allFour || Math.abs(w - toCompare.w) < tolerance); - } - - inline public function negate():Void - { - x *= -1; - y *= -1; - z *= -1; - } - - inline public function normalize():Float - { - var l = length; - - if (l != 0) - { - x /= l; - y /= l; - z /= l; - } - - return l; - } - - inline public function project():Void - { - x /= w; - y /= w; - z /= w; - } - - inline public function setTo(xa:Float, ya:Float, za:Float):Void { - x = xa; - y = ya; - z = za; - } - - inline public function scaleBy(s:Float):Void - { - x *= s; - y *= s; - z *= s; - } - - inline public function subtract(a:Vector3D):Vector3D - { - return new Vector3D(x - a.x, y - a.y, z - a.z); - } - - inline public function toString():String - { - return "Vector3D(" + x + ", " + y + ", " + z + ")"; - } - - // Getters & Setters - inline private function get_length():Float { return Math.sqrt(x * x + y * y + z * z); } - inline private function get_lengthSquared():Float { return x * x + y * y + z * z; } - inline private static function get_X_AXIS():Vector3D { return new Vector3D(1, 0, 0); } - inline private static function get_Y_AXIS():Vector3D { return new Vector3D(0, 1, 0); } - inline private static function get_Z_AXIS():Vector3D { return new Vector3D(0, 0, 1); } -} - -#else -// typedef Vector3D = flash.geom.Vector3D; -#end \ No newline at end of file diff --git a/lime/utils/WeakRef.hx b/lime/utils/WeakRef.hx deleted file mode 100644 index 661357e37..000000000 --- a/lime/utils/WeakRef.hx +++ /dev/null @@ -1,78 +0,0 @@ -package lime.utils; - - -import lime.core.Libs; - - -class WeakRef { - - - private var hardRef:T; - private var weakRef:Int; - - - public function new (object:T, makeWeak:Bool = true) { - - if (makeWeak) { - - weakRef = lime_weak_ref_create (this, object); - hardRef = null; - - } else { - - weakRef = -1; - hardRef = object; - - } - - } - - - public function get ():T { - - if (hardRef != null) { - - return hardRef; - - } - - if (weakRef < 0) { - - return null; - - } - - var result = lime_weak_ref_get (weakRef); - if (result == null) { - - weakRef = -1; - - } - - return result; - - } - - - public function toString ():String { - - if (hardRef == null) { - - return "" + hardRef; - - } - - return "WeakRef(" + weakRef + ")"; - - } - - - - - // Native Methods - - private static var lime_weak_ref_create:Dynamic = Libs.load ("lime", "lime_weak_ref_create", 2); - private static var lime_weak_ref_get:Dynamic = Libs.load ("lime", "lime_weak_ref_get", 1); - - -} \ No newline at end of file diff --git a/lime/utils/html5/ByteArray.hx b/lime/utils/html5/ByteArray.hx deleted file mode 100644 index 1f1dc11ce..000000000 --- a/lime/utils/html5/ByteArray.hx +++ /dev/null @@ -1,516 +0,0 @@ -package lime.utils.html5; -#if js - - -// import flash.errors.IOError; -// import flash.utils.UInt; -import haxe.io.Bytes; -import haxe.io.BytesBuffer; -import haxe.io.BytesData; -import haxe.io.Input; -import js.html.DataView; -import js.html.Uint8Array; - -#if format -import format.tools.Inflate; -#end - - -@:autoBuild(openfl.Assets.embedFile()) -class ByteArray implements ArrayAccess { - - - public var bytesAvailable(get_bytesAvailable, null):Int; - public var endian(get_endian, set_endian):String; - public var length(default, set_length):Int = 0; - public var objectEncoding:Int; - public var position:Int = 0; - - private var allocated:Int = 0; - public var byteView:Uint8Array; - private var data:DataView; - // NOTE: default ByteArray endian is BIG_ENDIAN - private var littleEndian:Bool = false; - - - public function new():Void { - - _limeResizeBuffer(allocated); - //this.byteView = untyped __new__("Uint8Array", allocated); - //this.data = untyped __new__("DataView", this.byteView.buffer); - - } - - - public function __get(pos:Int):Int { return data.getUint8(pos); } - public function __set(pos:Int, v:Int):Void { data.setUint8(pos, v); } - - - private function _getUTFBytesCount(value:String):Int { - - var count:Int = 0; - // utf8-decode - - for (i in 0...value.length) { - - var c = StringTools.fastCodeAt(value, i); - - if (c <= 0x7F) { - - count += 1; - - } else if (c <= 0x7FF) { - - count += 2; - - } else if (c <= 0xFFFF) { - - count += 3; - - } else { - - count += 4; - - } - - } - - return count; - - } - - - private function _limeResizeBuffer(len:Int):Void { - - var oldByteView:Uint8Array = this.byteView; - var newByteView:Uint8Array = untyped __new__("Uint8Array", len); - - if (oldByteView != null) - { - if (oldByteView.length <= len) newByteView.set(oldByteView); - else newByteView.set(oldByteView.subarray(0, len)); - } - - this.byteView = newByteView; - this.data = untyped __new__("DataView", newByteView.buffer); - - } - - - public function clear() { - - length = 0; - - } - - - @:extern private inline function ensureWrite(lengthToEnsure:Int):Void { - - if (this.length < lengthToEnsure) this.length = lengthToEnsure; - } - - - static public function fromBytes(inBytes:Bytes) - { - var result = new ByteArray(); - result.limeFromBytes(inBytes); - return result; - } - - public function getData() { - return data.buffer; - } - - private inline function limeFromBytes(inBytes:Bytes):Void - { - byteView = untyped __new__("Uint8Array", inBytes.getData()); - length = byteView.length; - allocated = length; - } - - - public inline function limeGet(pos:Int):Int { - - var data:Dynamic = data; - return data.getUint8(pos); - - } - - - public inline function limeGetBuffer() { - - return data.buffer; - - } - - - public static function limeOfBuffer(buffer:ArrayBuffer):ByteArray { - - var bytes = new ByteArray(); - bytes.length = bytes.allocated ;//= buffer.byteLength; todo - bytes.data = untyped __new__("DataView", buffer); - bytes.byteView = untyped __new__("Uint8Array", buffer); - return bytes; - - } - - - public inline function limeSet(pos:Int, v:Int):Void { - - var data:Dynamic = data; - data.setUint8(pos, v); - - } - - - public inline function readBoolean():Bool { - - return (this.readByte() != 0); - - } - - - public inline function readByte():Int { - - var data:Dynamic = data; - return data.getUint8(this.position++); - - } - - - public function readBytes(bytes:ByteArray, ?offset:Int, ?length:Int):Void { - - if (offset < 0 || length < 0) { - throw ("Read error - Out of bounds"); - } - - if (offset == null) offset = 0; - if (length == null) length = this.length; - - bytes.ensureWrite(offset + length); - - bytes.byteView.set(byteView.subarray(this.position, this.position + length), offset); - bytes.position = offset; - - this.position += length; - if (bytes.position + length > bytes.length) bytes.length = bytes.position + length; - - } - - - public function readDouble():Float { - - var double = data.getFloat64(this.position, littleEndian); - this.position += 8; - return double; - - } - - - public function readFloat():Float { - - var float = data.getFloat32(this.position, littleEndian); - this.position += 4; - return float; - - } - - - private function readFullBytes(bytes:Bytes, pos:Int, len:Int):Void { - - // NOTE: It is used somewhere? - - ensureWrite(len); - - for (i in pos...(pos + len)) { - - var data:Dynamic = data; - data.setInt8(this.position++, bytes.get(i)); - - } - - } - - - public function readInt():Int { - - var int = data.getInt32(this.position, littleEndian); - this.position += 4; - return int; - - } - - - public function readShort():Int { - - var short = data.getInt16(this.position, littleEndian); - this.position += 2; - return short; - - } - - - public inline function readUnsignedByte():Int { - - var data:Dynamic = data; - return data.getUint8(this.position++); - - } - - - public function readUnsignedInt():Int { - - var uInt = data.getUint32(this.position, littleEndian); - this.position += 4; - return uInt; - - } - - - public function readUnsignedShort():Int { - - var uShort = data.getUint16(this.position, littleEndian); - this.position += 2; - return uShort; - - } - - - public function readUTF():String { - - var bytesCount = readUnsignedShort(); - return readUTFBytes(bytesCount); - - } - - - public function readUTFBytes(len:Int):String { - - var value = ""; - var max = this.position + len; - - // utf8-encode - while (this.position < max) { - - var data:Dynamic = data; - var c = data.getUint8(this.position++); - - if (c < 0x80) { - - if (c == 0) break; - value += String.fromCharCode(c); - - } else if (c < 0xE0) { - - value += String.fromCharCode(((c & 0x3F) << 6) |(data.getUint8(this.position++) & 0x7F)); - - } else if (c < 0xF0) { - - var c2 = data.getUint8(this.position++); - value += String.fromCharCode(((c & 0x1F) << 12) |((c2 & 0x7F) << 6) |(data.getUint8(this.position++) & 0x7F)); - - } else { - - var c2 = data.getUint8(this.position++); - var c3 = data.getUint8(this.position++); - value += String.fromCharCode(((c & 0x0F) << 18) |((c2 & 0x7F) << 12) |((c3 << 6) & 0x7F) |(data.getUint8(this.position++) & 0x7F)); - - } - - } - - return value; - - } - - - public function toString ():String { - - var cachePosition = position; - position = 0; - var value = readUTFBytes (length); - position = cachePosition; - return value; - - } - - - #if format - public function uncompress():Void { - - var bytes = Bytes.ofData(cast byteView); - var buf = Inflate.run(bytes).getData(); - this.byteView = untyped __new__("Uint8Array", buf); - this.data = untyped __new__("DataView", byteView.buffer); - this.length = this.allocated = byteView.buffer.byteLength; - - } - #end - - - public inline function writeBoolean(value:Bool):Void { - - this.writeByte(value ? 1 : 0); - - } - - - public function writeByte(value:Int):Void { - - ensureWrite(this.position + 1); - var data:Dynamic = data; - data.setInt8(this.position, value); - this.position += 1; - - } - - - public function writeBytes(bytes:ByteArray, ?offset:Int, ?length:Int):Void { - - if (offset < 0 || length < 0) throw ("Write error - Out of bounds"); - - ensureWrite(this.position + length); - byteView.set(bytes.byteView.subarray(offset, offset + length), this.position); - this.position += length; - - } - - - public function writeDouble(x:Float):Void { - - ensureWrite(this.position + 8); - data.setFloat64(this.position, x, littleEndian); - this.position += 8; - - } - - - public function writeFloat(x:Float):Void { - - ensureWrite(this.position + 4); - data.setFloat32(this.position, x, littleEndian); - this.position += 4; - - } - - - public function writeInt(value:Int):Void { - - ensureWrite(this.position + 4); - data.setInt32(this.position, value, littleEndian); - this.position += 4; - - } - - - public function writeShort(value:Int):Void { - - ensureWrite(this.position + 2); - data.setInt16(this.position, value, littleEndian); - this.position += 2; - - } - - - public function writeUnsignedInt(value:Int):Void { - - ensureWrite(this.position + 4); - data.setUint32(this.position, value, littleEndian); - this.position += 4; - - } - - - public function writeUnsignedShort(value:Int):Void { - - ensureWrite(this.position + 2); - data.setUint16(this.position, value, littleEndian); - this.position += 2; - - } - - - public function writeUTF(value:String):Void { - - writeUnsignedShort(_getUTFBytesCount(value)); - writeUTFBytes(value); - - } - - - public function writeUTFBytes(value:String):Void { - - // utf8-decode - for (i in 0...value.length) { - - var c = StringTools.fastCodeAt(value, i); - - if (c <= 0x7F) { - - writeByte(c); - - } else if (c <= 0x7FF) { - - writeByte(0xC0 |(c >> 6)); - writeByte(0x80 |(c & 63)); - - } else if (c <= 0xFFFF) { - - writeByte(0xE0 |(c >> 12)); - writeByte(0x80 |((c >> 6) & 63)); - writeByte(0x80 |(c & 63)); - - } else { - - writeByte(0xF0 |(c >> 18)); - writeByte(0x80 |((c >> 12) & 63)); - writeByte(0x80 |((c >> 6) & 63)); - writeByte(0x80 |(c & 63)); - - } - - } - - } - - - - - // Getters & Setters - - - - - inline private function get_bytesAvailable():Int { return length - position; } - - - inline function get_endian():String { - - return littleEndian ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN; - - } - - - inline function set_endian(endian:String):String { - - littleEndian = (endian == Endian.LITTLE_ENDIAN); - return endian; - - } - - - private inline function set_length(value:Int):Int { - - if (allocated < value) - _limeResizeBuffer(allocated = Std.int(Math.max(value, allocated * 2))); - else if (allocated > value) - _limeResizeBuffer(allocated = value); - length = value; - return value; - } - - -} - - -#end diff --git a/lime/utils/html5/URLLoader.hx b/lime/utils/html5/URLLoader.hx deleted file mode 100644 index 804aec8e5..000000000 --- a/lime/utils/html5/URLLoader.hx +++ /dev/null @@ -1,324 +0,0 @@ -package lime.utils.html5; -#if js - - -// import flash.events.Event; -// import flash.events.EventDispatcher; -import lime.utils.html5.HTTPStatusEvent; -// import flash.events.IOErrorEvent; -import lime.utils.html5.ProgressEvent; -// import flash.errors.IOError; -// import flash.events.SecurityErrorEvent; - -import flash.utils.ByteArray; -import js.html.EventTarget; -import js.html.XMLHttpRequest; -import js.Browser; -import js.Lib; - - -class URLLoader { //extends EventDispatcher { - - - public var bytesLoaded:Int; - public var bytesTotal:Int; - public var data:Dynamic; - public var dataFormat(default, set):Dynamic; - private function set_dataFormat(inputVal:Dynamic):Dynamic { - // prevent inadvertently using typed arrays when they are unsupported - // @todo move these sorts of tests somewhere common in the vein of Modernizr - - // if (inputVal == URLLoaderDataFormat.BINARY - // && !Reflect.hasField(Browser.window, "ArrayBuffer")) { - // dataFormat = URLLoaderDataFormat.TEXT; - // } else { - // dataFormat = inputVal; - // } - - return dataFormat; - } - - - public function new(request){//:URLRequest = null) { - - super(); - - bytesLoaded = 0; - bytesTotal = 0; - dataFormat = URLLoaderDataFormat.TEXT; - - if (request != null) { - - load(request); - - } - - } - - - public function close():Void { - - - - } - - - private dynamic function getData():Dynamic { - - return null; - - } - - - public function load(request) {//:URLRequest):Void { - - requestUrl(request.url, request.method, request.data, request.formatRequestHeaders()); - - } - - - private function registerEvents(subject:EventTarget):Void { - - var self = this; - if (untyped __js__("typeof XMLHttpRequestProgressEvent") != __js__('"undefined"')) { - - subject.addEventListener("progress", onProgress, false); - - } - - untyped subject.onreadystatechange = function() { - - if (subject.readyState != 4) return; - - var s = try subject.status catch( e : Dynamic ) null; - - if (s == untyped __js__("undefined")) { - - s = null; - - } - - if (s != null) { - - self.onStatus(s); - - } - - //js.Lib.alert (s); - - if (s != null && s >= 200 && s < 400) { - - self.onData(subject.response); - - } else { - - if (s == null) { - - self.onError("Failed to connect or resolve host"); - - } else if (s == 12029) { - - self.onError("Failed to connect to host"); - - } else if (s == 12007) { - - self.onError("Unknown host"); - - } else if (s == 0) { - - self.onError("Unable to make request (may be blocked due to cross-domain permissions)"); - self.onSecurityError("Unable to make request (may be blocked due to cross-domain permissions)"); - - } else { - - self.onError("Http Error #" + subject.status); - - } - - } - - }; - - } - - - private function requestUrl(url:String, method:String, data:Dynamic, requestHeaders:Array):Void { - - var xmlHttpRequest:XMLHttpRequest = untyped __new__("XMLHttpRequest"); - registerEvents(cast xmlHttpRequest); - var uri:Dynamic = ""; - - if (Std.is(data, ByteArray)) { - - var data:ByteArray = cast data; - - switch (dataFormat) { - - case BINARY: uri = data.limeGetBuffer(); - default: uri = data.readUTFBytes(data.length); - - } - - } else if (Std.is(data, URLVariables)) { - - var data:URLVariables = cast data; - - for (p in Reflect.fields(data)) { - - if (uri.length != 0) uri += "&"; - uri += StringTools.urlEncode(p) + "=" + StringTools.urlEncode(Reflect.field(data, p)); - - } - - } else { - - if (data != null) { - - uri = data.toString(); - - } - - } - - try { - - if (method == "GET" && uri != null && uri != "") { - - var question = url.split("?").length <= 1; - xmlHttpRequest.open(method, url + (if (question) "?" else "&") + uri, true); - uri = ""; - - } else { - - //js.Lib.alert ("open: " + method + ", " + url + ", true"); - xmlHttpRequest.open(method, url, true); - - } - - } catch(e:Dynamic) { - - onError(e.toString()); - return; - - } - - //js.Lib.alert ("dataFormat: " + dataFormat); - - switch (dataFormat) { - - case BINARY: untyped xmlHttpRequest.responseType = 'arraybuffer'; - default: - - } - - for (header in requestHeaders) { - - //js.Lib.alert ("setRequestHeader: " + header.name + ", " + header.value); - xmlHttpRequest.setRequestHeader(header.name, header.value); - - } - - //js.Lib.alert ("uri: " + uri); - - xmlHttpRequest.send(uri); - onOpen(); - - getData = function() { - - if (xmlHttpRequest.response != null) { - - return xmlHttpRequest.response; - - } else { - - return xmlHttpRequest.responseText; - - } - - }; - - } - - - - - // Event Handlers - - - - - private function onData(_):Void { - - var content:Dynamic = getData(); - - switch (dataFormat) { - - case BINARY: this.data = ByteArray.limeOfBuffer(content); - default: this.data = Std.string(content); - - } - - var evt = new Event(Event.COMPLETE); - evt.currentTarget = this; - dispatchEvent(evt); - - } - - - private function onError(msg:String):Void { - - var evt = new IOErrorEvent(IOErrorEvent.IO_ERROR); - evt.text = msg; - evt.currentTarget = this; - dispatchEvent(evt); - - } - - - private function onOpen():Void { - - var evt = new Event(Event.OPEN); - evt.currentTarget = this; - dispatchEvent(evt); - - } - - - private function onProgress(event:XMLHttpRequestProgressEvent):Void { - - var evt = new ProgressEvent(ProgressEvent.PROGRESS); - evt.currentTarget = this; - evt.bytesLoaded = event.loaded; - evt.bytesTotal = event.total; - dispatchEvent(evt); - - } - - - private function onSecurityError(msg:String):Void { - - var evt = new SecurityErrorEvent(SecurityErrorEvent.SECURITY_ERROR); - evt.text = msg; - evt.currentTarget = this; - dispatchEvent(evt); - - } - - - private function onStatus(status:Int):Void { - - // todo: - // var evt = new HTTPStatusEvent(HTTPStatusEvent.HTTP_STATUS, false, false, status); - // evt.currentTarget = this; - // dispatchEvent(evt); - - } - - -} - - -typedef XMLHttpRequestProgressEvent = Dynamic; - - -#end \ No newline at end of file diff --git a/lime/utils/native/ByteArray.hx b/lime/utils/native/ByteArray.hx deleted file mode 100644 index ac780db05..000000000 --- a/lime/utils/native/ByteArray.hx +++ /dev/null @@ -1,634 +0,0 @@ -package lime.utils.native; -// #if (cpp || neko) -#if (lime_native || lime_html5) - -import lime.utils.Libs; - -import haxe.io.Bytes; -import haxe.io.BytesData; -// import lime.errors.EOFError; // Ensure that the neko->haxe callbacks are initialized -import lime.utils.CompressionAlgorithm; -import lime.utils.IDataInput; - -#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 -{ - - public var bigEndian:Bool; - public var bytesAvailable(get_bytesAvailable, null):Int; - public var endian(get_endian, set_endian):String; - public var position:Int; - public var byteLength(get_byteLength,null):Int; - - #if neko - /** @private */ private var alloced:Int; - #end - - public function new(inSize = 0) - { - bigEndian = true; - position = 0; - - if (inSize >= 0) - { - #if neko - alloced = inSize < 16 ? 16 : inSize; - var bytes = untyped __dollar__smake(alloced); - super(inSize, bytes); - #else - var data = new BytesData(); - if (inSize > 0) - untyped data[inSize - 1] = 0; - super(inSize, data); - #end - } - } - - @:keep - inline public function __get(pos:Int):Int - { - // Neko/cpp pseudo array accessors... - // No bounds checking is done in the cpp case - #if cpp - return untyped b[pos]; - #else - return get(pos); - #end - } - - #if !no_lime_io - /** @private */ static function __init__() { - var factory = function(inLen:Int) { return new ByteArray(inLen); }; - var resize = function(inArray:ByteArray, inLen:Int) - { - if (inLen > 0) - inArray.ensureElem(inLen - 1, true); - inArray.length = inLen; - - }; - - var bytes = function(inArray:ByteArray) { return inArray==null ? null : inArray.b; } - var slen = function(inArray:ByteArray) { return inArray == null ? 0 : inArray.length; } - - #if !lime_html5 - var init = Libs.load("lime", "lime_byte_array_init", 4); - init(factory, slen, resize, bytes); - #end //lime_html5 - } - #end - - @:keep - inline public function __set(pos:Int, v:Int):Void - { - // No bounds checking is done in the cpp case - #if cpp - untyped b[pos] = v; - #else - set(pos, v); - #end - } - - public function asString():String - { - return readUTFBytes(length); - } - - public function checkData(inLength:Int) - { - if (inLength + position > length) - ThrowEOFi(); - } - - public function clear() - { - position = 0; - length = 0; - } - -#if !lime_html5 - //todo- sven - - public function compress(algorithm:CompressionAlgorithm = null) - { - #if neko - var src = alloced == length ? this : sub(0, length); - #else - var src = this; - #end - - var result:Bytes; - - if (algorithm == CompressionAlgorithm.LZMA) - { - result = Bytes.ofData(lime_lzma_encode( cast src.getData()) ); - - } else - { - var windowBits = switch(algorithm) - { - case DEFLATE: -15; - case GZIP: 31; - default: 15; - } - - #if enable_deflate - result = Compress.run(src, 8, windowBits); - #else - result = Compress.run(src, 8); - #end - } - - b = result.b; - length = result.length; - position = length; - #if neko - alloced = length; - #end - } - - public function deflate() - { - compress(CompressionAlgorithm.DEFLATE); - } - -#end //!lime_html5 - - /** @private */ private function ensureElem(inSize:Int, inUpdateLenght:Bool) { - var len = inSize + 1; - - #if neko - if (alloced < len) - { - alloced =((len+1) * 3) >> 1; - var new_b = untyped __dollar__smake(alloced); - untyped __dollar__sblit(new_b, 0, b, 0, length); - b = new_b; - } - #else - if (b.length < len) - untyped b.__SetSize(len); - #end - - if (inUpdateLenght && length < len) - length = len; - } - - static public function fromBytes(inBytes:Bytes) - { - var result = new ByteArray( -1); - result.limeFromBytes(inBytes); - return result; - } - - public function getLength():Int { return length; } - - // IMemoryRange - public function getByteBuffer():ByteArray { return this; } - public function getStart():Int { return 0; } - -#if !lime_html5 - - public function inflate() { - - uncompress(CompressionAlgorithm.DEFLATE); - - } - -#end //!lime_html5 - - private inline function limeFromBytes(inBytes:Bytes):Void - { - b = inBytes.b; - length = inBytes.length; - - #if neko - alloced = length; - #end - } - - public inline function readBoolean():Bool - { - return(position < length) ? __get(position++) != 0 : ThrowEOFi() != 0; - } - - public inline function readByte():Int - { - var val:Int = readUnsignedByte(); - return((val & 0x80) != 0) ?(val - 0x100) : val; - } - - public function readBytes(outData:ByteArray, inOffset:Int = 0, inLen:Int = 0):Void - { - if (inLen == 0) - inLen = length - position; - - if (position + inLen > length) - ThrowEOFi(); - - if (outData.length < inOffset + inLen) - outData.ensureElem(inOffset + inLen - 1, true); - - #if neko - outData.blit(inOffset, this, position, inLen); - #else - var b1 = b; - var b2 = outData.b; - var p = position; - for(i in 0...inLen) - b2[inOffset + i] = b1[p + i]; - #end - - position += inLen; - } - - public function readDouble():Float - { - #if !lime_html5 - - if (position + 8 > length) - ThrowEOFi(); - - #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_lime_io - static public function readFile(inString:String):ByteArray - { - return lime_byte_array_read_file(inString); - } - #end - - public function readFloat():Float - { - #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 - - position += 4; - return _float_of_bytes(bytes.b, bigEndian); - - #end //!lime_html5 - - return 0.0; - } - - public function readInt():Int - { - var ch1 = readUnsignedByte(); - var ch2 = readUnsignedByte(); - var ch3 = readUnsignedByte(); - var ch4 = readUnsignedByte(); - - return bigEndian ?(ch1 << 24) |(ch2 << 16) |(ch3 << 8) | ch4 :(ch4 << 24) |(ch3 << 16) |(ch2 << 8) | ch1; - } - - public inline function readMultiByte(inLen:Int, charSet:String):String - { - // TODO - use code page - return readUTFBytes(inLen); - } - - public function readShort():Int - { - var ch1 = readUnsignedByte(); - var ch2 = readUnsignedByte(); - - var val = bigEndian ?((ch1 << 8) | ch2) :((ch2 << 8) | ch1); - - return((val & 0x8000) != 0) ?(val - 0x10000) : val; - } - - inline public function readUnsignedByte():Int - { - return(position < length) ? __get(position++) : ThrowEOFi(); - } - - public function readUnsignedInt():Int - { - var ch1 = readUnsignedByte(); - var ch2 = readUnsignedByte(); - var ch3 = readUnsignedByte(); - var ch4 = readUnsignedByte(); - - return bigEndian ?(ch1 << 24) |(ch2 << 16) |(ch3 << 8) | ch4 :(ch4 << 24) |(ch3 << 16) |(ch2 << 8) | ch1; - } - - public function readUnsignedShort():Int - { - var ch1 = readUnsignedByte(); - var ch2 = readUnsignedByte(); - - return bigEndian ?(ch1 << 8) | ch2 :(ch2 << 8) + ch1; - } - - public function readUTF():String - { - var len = readUnsignedShort(); - return readUTFBytes(len); - } - - public function readUTFBytes(inLen:Int):String - { - if (position + inLen > length) - ThrowEOFi(); - - var p = position; - position += inLen; - - #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 - { - if (inLength > 0) - ensureElem(inLength - 1, false); - length = inLength; - } - - // ArrayBuffer interface - public function slice(inBegin:Int, ?inEnd:Int):ByteArray - { - var begin = inBegin; - - if (begin < 0) - { - begin += length; - if (begin < 0) - begin = 0; - } - - var end:Int = inEnd == null ? length : inEnd; - - if (end < 0) - { - end += length; - - if (end < 0) - end = 0; - } - - if (begin >= end) - return new ByteArray(); - - var result = new ByteArray(end - begin); - - var opos = position; - result.blit(0, this, begin, end - begin); - - return result; - } - - /** @private */ private function ThrowEOFi():Int { - throw "new EOFError();"; //todo sven - return 0; - } - -#if !lime_html5 -//todo sven - - public function uncompress(algorithm:CompressionAlgorithm = null):Void - { - if (algorithm == null) algorithm = CompressionAlgorithm.GZIP; - - #if neko - var src = alloced == length ? this : sub(0, length); - #else - var src = this; - #end - - var result:Bytes; - - if (algorithm == CompressionAlgorithm.LZMA) - { - result = Bytes.ofData(lime_lzma_decode(src.getData())); - - } else - { - var windowBits = switch(algorithm) - { - case DEFLATE: -15; - case GZIP: 31; - default: 15; - } - - #if enable_deflate - result = Uncompress.run(src, null, windowBits); - #else - result = Uncompress.run(src, null); - #end - } - - b = result.b; - length = result.length; - position = 0; - #if neko - alloced = length; - #end - } - -#end //!lime_html5 - - /** @private */ inline function write_uncheck(inByte:Int) { - #if cpp - untyped b.__unsafe_set(position++, inByte); - #else - untyped __dollar__sset(b, position++, inByte & 0xff); - #end - } - - public function writeBoolean(value:Bool) - { - writeByte(value ? 1 : 0); - } - - inline public function writeByte(value:Int) - { - ensureElem(position, true); - - #if cpp - b[position++] = untyped value; - #else - untyped __dollar__sset(b, position++, value & 0xff); - #end - } - - public function writeBytes(bytes:Bytes, inOffset:Int = 0, inLength:Int = 0) - { - if (inLength == 0) inLength = bytes.length - inOffset; - ensureElem(position + inLength - 1, true); - var opos = position; - position += inLength; - blit(opos, bytes, inOffset, inLength); - } - - public function writeDouble(x:Float) - { - #if !lime_html5 - - #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_lime_io - public function writeFile(inString:String):Void - { - lime_byte_array_overwrite_file(inString, this); - } - #end - - public function writeFloat(x:Float) - { - #if !lime_html5 - - #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) - { - ensureElem(position + 3, true); - - if (bigEndian) - { - write_uncheck(value >> 24); - write_uncheck(value >> 16); - write_uncheck(value >> 8); - write_uncheck(value); - - } else - { - write_uncheck(value); - write_uncheck(value >> 8); - write_uncheck(value >> 16); - write_uncheck(value >> 24); - } - } - - // public function writeMultiByte(value:String, charSet:String) - // public function writeObject(object:*) - public function writeShort(value:Int) - { - ensureElem(position + 1, true); - - if (bigEndian) - { - write_uncheck(value >> 8); - write_uncheck(value); - - } else - { - write_uncheck(value); - write_uncheck(value >> 8); - } - } - - public function writeUnsignedInt(value:Int) - { - writeInt(value); - } - - public function writeUTF(s:String) - { - #if neko - var bytes = new Bytes(s.length, untyped s.__s); - #else - var bytes = Bytes.ofString(s); - #end - - writeShort(bytes.length); - writeBytes(bytes); - } - - public function writeUTFBytes(s:String) - { - #if neko - var bytes = new Bytes(s.length, untyped s.__s); - #else - var bytes = Bytes.ofString(s); - #end - - writeBytes(bytes); - } - - // Getters & Setters - private function get_bytesAvailable():Int { return length - position; } - private function get_byteLength():Int { return length; } - private function get_endian():String { return bigEndian ? Endian.BIG_ENDIAN : Endian.LITTLE_ENDIAN; } - private function set_endian(s:String):String { bigEndian =(s == Endian.BIG_ENDIAN); return s; } - - // Native Methods - /** @private */ private static var _double_bytes = Libs.load("std", "double_bytes", 2); - /** @private */ private static var _double_of_bytes = Libs.load("std", "double_of_bytes", 2); - /** @private */ private static var _float_bytes = Libs.load("std", "float_bytes", 2); - /** @private */ private static var _float_of_bytes = Libs.load("std", "float_of_bytes", 2); - #if !no_lime_io - private static var lime_byte_array_overwrite_file = Libs.load("lime","lime_byte_array_overwrite_file", 2); - private static var lime_byte_array_read_file = Libs.load("lime", "lime_byte_array_read_file", 1); - #end - private static var lime_lzma_encode = Libs.load("lime", "lime_lzma_encode", 1); - private static var lime_lzma_decode = Libs.load("lime", "lime_lzma_decode", 1); -} - -#else -typedef ByteArray = Dynamic;//todo ; flash.utils.ByteArray; -#end diff --git a/project/Build.xml b/project/Build.xml index 097c1bf25..efdfe7e4c 100644 --- a/project/Build.xml +++ b/project/Build.xml @@ -21,6 +21,29 @@ + + + + + + + +
+ + + + + + + + + + + +
+ +
+ @@ -32,6 +55,8 @@ + + diff --git a/project/include/Application.h b/project/include/Application.h new file mode 100644 index 000000000..48f6ab0be --- /dev/null +++ b/project/include/Application.h @@ -0,0 +1,25 @@ +#ifndef LIME_APPLICATION_H +#define LIME_APPLICATION_H + + +namespace lime { + + + class Application { + + + public: + + virtual int Exec () = 0; + + + }; + + + Application* CreateApplication (); + + +} + + +#endif \ No newline at end of file diff --git a/project/include/Renderer.h b/project/include/Renderer.h new file mode 100644 index 000000000..fd56d728b --- /dev/null +++ b/project/include/Renderer.h @@ -0,0 +1,28 @@ +#ifndef LIME_RENDERER_H +#define LIME_RENDERER_H + + +#include "Window.h" + + +namespace lime { + + + class Renderer { + + + public: + + Window* currentWindow; + + + }; + + + Renderer* CreateRenderer (Window* window); + + +} + + +#endif \ No newline at end of file diff --git a/project/include/Window.h b/project/include/Window.h new file mode 100644 index 000000000..2aa3fbfd3 --- /dev/null +++ b/project/include/Window.h @@ -0,0 +1,28 @@ +#ifndef LIME_WINDOW_H +#define LIME_WINDOW_H + + +#include "Application.h" + + +namespace lime { + + + class Window { + + + public: + + Application* currentApplication; + + + }; + + + Window* CreateWindow (Application* application); + + +} + + +#endif \ No newline at end of file diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 3fc30e3fd..20e2b9709 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1,572 +1,64 @@ +#ifndef STATIC_LINK +#define IMPLEMENT_API +#endif + +#if defined(HX_WINDOWS) || defined(HX_MACOS) || defined(HX_LINUX) +#define NEKO_COMPATIBLE +#endif + + #include +#include "Application.h" +#include "Window.h" +#include "Renderer.h" -// Custom DEFINE_PRIM macro when calls are the same as NME - -#ifdef STATIC_LINK - -#define DEFINE_LIME_PRIM_MULT(func) value nme_##func(value *arg, int args); \ -int __reg_lime_##func = hx_register_prim("lime_" #func "__MULT",(void *)(&nme_##func)); \ - -#define DEFINE_LIME_PRIM(func,nargs) \ -int __reg_lime_##func = hx_register_prim("lime_" #func "__" #nargs,(void *)(&nme_##func)); \ - -#define DEFINE_LIME_PRIM_MULT_NATIVE(func,ext) \ -int __reg_lime_##func = hx_register_prim("lime_" #func "__" MULT,(void *)(&nme_##func)) + \ - hx_register_prim("lime_" #func "__" #ext,(void *)(&nme_##func##_##ext)) ; - -#define DEFINE_LIME_PRIM_NATIVE(func,nargs,ext) \ -int __reg_lime_##func = hx_register_prim("lime_" #func "__" #nargs,(void *)(&nme_##func)) + \ - hx_register_prim("lime_" #func "__" #ext,(void *)(&nme_##func##_##ext)) ; - -#else - -#define DEFINE_LIME_PRIM_MULT(func) value nme_##func(value *arg, int args); \ -extern "C" { \ - EXPORT void *lime_##func##__MULT() { return (void*)(&nme_##func); } \ -} - -#define DEFINE_LIME_PRIM(func,nargs) extern "C" { \ - EXPORT void *lime_##func##__##nargs() { return (void*)(&nme_##func); } \ -} - -#define DEFINE_LIME_PRIM_MULT_NATIVE(func,ext) extern "C" { \ - EXPORT void *lime_##func##__MULT() { return (void*)(&nme_##func); } \ - EXPORT void *lime_##func##__##ext() { return (void*)(&nme_##func##_##ext); } \ -} - -#define DEFINE_LIME_PRIM_NATIVE(func,nargs,ext) extern "C" { \ - EXPORT void *lime_##func##__##nargs() { return (void*)(&nme_##func); } \ - EXPORT void *lime_##func##__##ext() { return (void*)(&nme_##func##_##ext); } \ -} - -#endif - - -// Forward declare common CFFI calls, and expose to Haxe - -#define DEFINE_LIME_PRIM_0(func) value nme_##func(); \ - DEFINE_LIME_PRIM(func,0) - -#define DEFINE_LIME_PRIM_1(func) value nme_##func(value p1); \ - DEFINE_LIME_PRIM(func,1) - -#define DEFINE_LIME_PRIM_2(func) value nme_##func(value p1, value p2); \ - DEFINE_LIME_PRIM(func,2) - -#define DEFINE_LIME_PRIM_3(func) value nme_##func(value p1, value p2, value p3); \ - DEFINE_LIME_PRIM(func,3) - -#define DEFINE_LIME_PRIM_4(func) value nme_##func(value p1, value p2, value p3, value p4); \ - DEFINE_LIME_PRIM(func,4) - -#define DEFINE_LIME_PRIM_5(func) value nme_##func(value p1, value p2, value p3, value p4, value p5); \ - DEFINE_LIME_PRIM(func,5) - -#define DEFINE_LIME_PRIM_6(func) value nme_##func(value p1, value p2, value p3, value p4, value p5, value p6); \ - DEFINE_LIME_PRIM(func,6) - -#define DEFINE_LIME_PROP_READ(obj,prop) DEFINE_LIME_PRIM_1(obj##_get_##prop) - -#define DEFINE_LIME_PROP(obj,prop) DEFINE_LIME_PRIM_1(obj##_get_##prop) \ - DEFINE_LIME_PRIM_2(obj##_set_##prop) - - -// Define common CFFI NME calls - -#ifdef ANDROID -DEFINE_LIME_PRIM_1(jni_init_callback); -DEFINE_LIME_PRIM_4(jni_create_field); -DEFINE_LIME_PRIM_1(jni_get_static); -DEFINE_LIME_PRIM_2(jni_set_static); -DEFINE_LIME_PRIM_2(jni_get_member); -DEFINE_LIME_PRIM_3(jni_set_member); -DEFINE_LIME_PRIM_5(jni_create_method); -DEFINE_LIME_PRIM_2(jni_call_static); -DEFINE_LIME_PRIM_3(jni_call_member); -DEFINE_LIME_PRIM_0(jni_get_env); -DEFINE_LIME_PRIM_1(jni_get_jobject); -DEFINE_LIME_PRIM_1(post_ui_callback); -#endif -DEFINE_LIME_PRIM_0(time_stamp); -DEFINE_LIME_PRIM_1(error_output); -DEFINE_LIME_PRIM_0(get_ndll_version); -DEFINE_LIME_PRIM_0(get_nme_state_version); -DEFINE_LIME_PRIM_0(get_bits); -DEFINE_LIME_PRIM_4(byte_array_init); -DEFINE_LIME_PRIM_2(byte_array_overwrite_file); -DEFINE_LIME_PRIM_1(byte_array_read_file); -DEFINE_LIME_PRIM_1(byte_array_get_native_pointer); -DEFINE_LIME_PRIM_2(weak_ref_create); -DEFINE_LIME_PRIM_1(weak_ref_get); -DEFINE_LIME_PRIM_0(get_unique_device_identifier); -DEFINE_LIME_PRIM_1(set_icon); -DEFINE_LIME_PRIM_0(sys_get_exe_name); -DEFINE_LIME_PRIM_0(capabilities_get_screen_resolutions); -DEFINE_LIME_PRIM_0(capabilities_get_screen_modes); -DEFINE_LIME_PRIM_0(capabilities_get_pixel_aspect_ratio); -DEFINE_LIME_PRIM_0(capabilities_get_screen_dpi); -DEFINE_LIME_PRIM_0(capabilities_get_screen_resolution_x); -DEFINE_LIME_PRIM_0(capabilities_get_screen_resolution_y); -DEFINE_LIME_PRIM_0(capabilities_get_language); -DEFINE_LIME_PRIM_0(get_resource_path); -DEFINE_LIME_PRIM_1(filesystem_get_special_dir); -DEFINE_LIME_PRIM_2(filesystem_get_volumes); -DEFINE_LIME_PRIM_1(get_url); -DEFINE_LIME_PRIM_2(haptic_vibrate); -DEFINE_LIME_PRIM_2(set_user_preference); -DEFINE_LIME_PRIM_1(get_user_preference); -DEFINE_LIME_PRIM_1(clear_user_preference); -DEFINE_LIME_PRIM_1(stage_set_fixed_orientation); -//DEFINE_LIME_PRIM_0(init_sdl_audio); -DEFINE_LIME_PRIM_1(get_frame_stage); -DEFINE_LIME_PRIM_4(set_package); -DEFINE_LIME_PRIM_MULT(create_main_frame); -DEFINE_LIME_PRIM_1(set_asset_base); -DEFINE_LIME_PRIM_0(terminate); -DEFINE_LIME_PRIM_0(close); -DEFINE_LIME_PRIM_0(start_animation); -DEFINE_LIME_PRIM_0(pause_animation); -DEFINE_LIME_PRIM_0(resume_animation); -DEFINE_LIME_PRIM_0(stop_animation); -DEFINE_LIME_PRIM_2(stage_set_next_wake); -DEFINE_LIME_PRIM_4(set_stage_handler); -DEFINE_LIME_PRIM_1(render_stage); -DEFINE_LIME_PRIM_1(set_render_gc_free); -DEFINE_LIME_PRIM_3(stage_resize_window); -DEFINE_LIME_PRIM_3(stage_set_resolution); -DEFINE_LIME_PRIM_5(stage_set_screenmode); -DEFINE_LIME_PRIM_2(stage_set_fullscreen); -DEFINE_LIME_PRIM_1(stage_get_focus_id); -DEFINE_LIME_PRIM_3(stage_set_focus); -DEFINE_LIME_PRIM_2(stage_get_joystick_name); -DEFINE_LIME_PRIM_1(stage_is_opengl); -DEFINE_LIME_PRIM_0(stage_request_render); -DEFINE_LIME_PRIM_2(stage_show_cursor); -DEFINE_LIME_PRIM_2(stage_constrain_cursor_to_window_frame); -DEFINE_LIME_PRIM_3(stage_set_cursor_position_in_window); -DEFINE_LIME_PRIM_3(stage_set_window_position); -DEFINE_LIME_PRIM_0(stage_get_orientation); -DEFINE_LIME_PRIM_0(stage_get_normal_orientation); -DEFINE_LIME_PROP(stage,focus_rect); -DEFINE_LIME_PROP(stage,scale_mode); -#ifdef NME_S3D -DEFINE_LIME_PROP(stage,autos3d); -#else -value nme_stage_get_autos3d(value inHandle) { return alloc_bool(false); } -value nme_stage_set_autos3d(value inHandle, value inVal) { return inVal; } -DEFINE_LIME_PRIM(stage_get_autos3d,1); -DEFINE_LIME_PRIM(stage_set_autos3d,2); -#endif -DEFINE_LIME_PROP(stage,align); -DEFINE_LIME_PROP(stage,quality); -DEFINE_LIME_PROP(stage,display_state); -DEFINE_LIME_PROP(stage,multitouch_active); -DEFINE_LIME_PROP_READ(stage,stage_width); -DEFINE_LIME_PROP_READ(stage,stage_height); -DEFINE_LIME_PROP_READ(stage,dpi_scale); -DEFINE_LIME_PROP_READ(stage,multitouch_supported); -DEFINE_LIME_PRIM_2(sv_create); -DEFINE_LIME_PRIM_1(sv_destroy); -DEFINE_LIME_PRIM_2(sv_action); -DEFINE_LIME_PRIM_4(sv_play); -DEFINE_LIME_PRIM_2(sv_seek); -DEFINE_LIME_PRIM_1(sv_get_time); -DEFINE_LIME_PRIM_5(sv_viewport); -DEFINE_LIME_PRIM_3(sv_pan); -DEFINE_LIME_PRIM_3(sv_zoom); -DEFINE_LIME_PRIM_3(sv_set_sound_transform); -DEFINE_LIME_PRIM_1(sv_get_buffered_percent); -DEFINE_LIME_PRIM_3(managed_stage_create); -DEFINE_LIME_PRIM_2(managed_stage_pump_event); -DEFINE_LIME_PRIM_0(input_get_acceleration); -DEFINE_LIME_PRIM_0(create_display_object); -DEFINE_LIME_PRIM_1(display_object_get_graphics); -DEFINE_LIME_PRIM_MULT(display_object_draw_to_surface); -DEFINE_LIME_PRIM_1(display_object_get_id); -DEFINE_LIME_PRIM_2(display_object_global_to_local); -DEFINE_LIME_PRIM_1(type); -DEFINE_LIME_PRIM_2(display_object_local_to_global); -DEFINE_LIME_PRIM_5(display_object_hit_test_point); -DEFINE_LIME_PRIM_2(display_object_set_filters); -DEFINE_LIME_PRIM_2(display_object_set_scale9_grid); -DEFINE_LIME_PRIM_2(display_object_set_scroll_rect); -DEFINE_LIME_PRIM_2(display_object_set_mask); -DEFINE_LIME_PRIM_2(display_object_set_matrix); -DEFINE_LIME_PRIM_3(display_object_get_matrix); -DEFINE_LIME_PRIM_2(display_object_set_color_transform); -DEFINE_LIME_PRIM_3(display_object_get_color_transform); -DEFINE_LIME_PRIM_2(display_object_get_pixel_bounds); -DEFINE_LIME_PRIM_4(display_object_get_bounds); -DEFINE_LIME_PRIM_1(display_object_request_soft_keyboard); -DEFINE_LIME_PRIM_1(display_object_dismiss_soft_keyboard); -DEFINE_LIME_PROP(display_object,x); -DEFINE_LIME_PROP(display_object,y); -#ifdef NME_S3D -DEFINE_LIME_PROP(display_object,z); -#else -value nme_display_object_get_z(value inHandle) { return alloc_int(0); } -value nme_display_object_set_z(value inHandle, value inVal) { return inVal; } -DEFINE_LIME_PRIM(display_object_get_z,1); -DEFINE_LIME_PRIM(display_object_set_z,2); -#endif -DEFINE_LIME_PROP(display_object,scale_x); -DEFINE_LIME_PROP(display_object,scale_y); -DEFINE_LIME_PROP(display_object,rotation); -DEFINE_LIME_PROP(display_object,width); -DEFINE_LIME_PROP(display_object,height); -DEFINE_LIME_PROP(display_object,alpha); -DEFINE_LIME_PROP(display_object,bg); -DEFINE_LIME_PROP(display_object,mouse_enabled); -DEFINE_LIME_PROP(display_object,cache_as_bitmap); -DEFINE_LIME_PROP(display_object,pedantic_bitmap_caching); -DEFINE_LIME_PROP(display_object,pixel_snapping); -DEFINE_LIME_PROP(display_object,visible); -DEFINE_LIME_PROP(display_object,name); -DEFINE_LIME_PROP(display_object,blend_mode); -DEFINE_LIME_PROP(display_object,needs_soft_keyboard); -DEFINE_LIME_PROP(display_object,moves_for_soft_keyboard); -DEFINE_LIME_PROP_READ(display_object,mouse_x); -DEFINE_LIME_PROP_READ(display_object,mouse_y); -DEFINE_LIME_PRIM_0(direct_renderer_create); -DEFINE_LIME_PRIM_2(direct_renderer_set); -DEFINE_LIME_PRIM_0(simple_button_create); -DEFINE_LIME_PRIM_3(simple_button_set_state); -DEFINE_LIME_PROP(simple_button,enabled); -DEFINE_LIME_PROP(simple_button,hand_cursor); -DEFINE_LIME_PRIM_0(create_display_object_container); -DEFINE_LIME_PRIM_2(doc_add_child); -DEFINE_LIME_PRIM_3(doc_swap_children); -DEFINE_LIME_PRIM_2(doc_remove_child); -DEFINE_LIME_PRIM_3(doc_set_child_index); -DEFINE_LIME_PROP(doc,mouse_children); -DEFINE_LIME_PRIM_2(external_interface_add_callback); -DEFINE_LIME_PRIM_0(external_interface_available); -DEFINE_LIME_PRIM_2(external_interface_call); -DEFINE_LIME_PRIM_0(external_interface_register_callbacks); -DEFINE_LIME_PRIM_1(gfx_clear); -DEFINE_LIME_PRIM_3(gfx_begin_fill); -DEFINE_LIME_PRIM_5(gfx_begin_bitmap_fill); -DEFINE_LIME_PRIM_5(gfx_line_bitmap_fill); -DEFINE_LIME_PRIM_MULT(gfx_begin_gradient_fill); -DEFINE_LIME_PRIM_MULT(gfx_line_gradient_fill); -DEFINE_LIME_PRIM_1(gfx_end_fill); -DEFINE_LIME_PRIM_MULT(gfx_line_style); -DEFINE_LIME_PRIM_3(gfx_move_to); -DEFINE_LIME_PRIM_3(gfx_line_to); -DEFINE_LIME_PRIM_5(gfx_curve_to); -DEFINE_LIME_PRIM_5(gfx_arc_to); -DEFINE_LIME_PRIM_5(gfx_draw_ellipse); -DEFINE_LIME_PRIM_5(gfx_draw_rect); -DEFINE_LIME_PRIM_4(gfx_draw_path); -DEFINE_LIME_PRIM_MULT(gfx_draw_round_rect); -DEFINE_LIME_PRIM_MULT(gfx_draw_triangles); -DEFINE_LIME_PRIM_2(gfx_draw_data); -DEFINE_LIME_PRIM_2(gfx_draw_datum); -DEFINE_LIME_PRIM_5(gfx_draw_tiles); -DEFINE_LIME_PRIM_MULT(gfx_draw_points); -DEFINE_LIME_PRIM_3(graphics_path_create); -DEFINE_LIME_PRIM_5(graphics_path_curve_to); -DEFINE_LIME_PRIM_3(graphics_path_line_to); -DEFINE_LIME_PRIM_3(graphics_path_move_to); -DEFINE_LIME_PRIM_3(graphics_path_wline_to); -DEFINE_LIME_PRIM_3(graphics_path_wmove_to); -DEFINE_LIME_PRIM_2(graphics_path_get_commands); -DEFINE_LIME_PRIM_2(graphics_path_set_commands); -DEFINE_LIME_PRIM_2(graphics_path_get_data); -DEFINE_LIME_PRIM_2(graphics_path_set_data); -DEFINE_LIME_PRIM_2(graphics_solid_fill_create); -DEFINE_LIME_PRIM_0(graphics_end_fill_create); -DEFINE_LIME_PRIM_MULT(graphics_stroke_create); -DEFINE_LIME_PRIM_0(text_field_create); -DEFINE_LIME_PRIM_2(text_field_set_def_text_format); -DEFINE_LIME_PRIM_4(text_field_get_text_format); -DEFINE_LIME_PRIM_4(text_field_set_text_format); -DEFINE_LIME_PRIM_2(text_field_get_def_text_format); -DEFINE_LIME_PRIM_3(text_field_get_line_metrics); -DEFINE_LIME_PRIM_2(text_field_get_line_text); -DEFINE_LIME_PRIM_2(text_field_get_line_offset); -DEFINE_LIME_PROP(text_field,text); -DEFINE_LIME_PROP(text_field,html_text); -DEFINE_LIME_PROP(text_field,text_color); -DEFINE_LIME_PROP(text_field,selectable); -DEFINE_LIME_PROP(text_field,display_as_password); -DEFINE_LIME_PROP(text_field,type); -DEFINE_LIME_PROP(text_field,multiline); -DEFINE_LIME_PROP(text_field,word_wrap); -DEFINE_LIME_PROP(text_field,background); -DEFINE_LIME_PROP(text_field,background_color); -DEFINE_LIME_PROP(text_field,border); -DEFINE_LIME_PROP(text_field,border_color); -DEFINE_LIME_PROP(text_field,embed_fonts); -DEFINE_LIME_PROP(text_field,auto_size); -DEFINE_LIME_PROP(text_field,scroll_h); -DEFINE_LIME_PROP(text_field,scroll_v); -DEFINE_LIME_PROP(text_field,max_chars); -DEFINE_LIME_PROP_READ(text_field,text_width); -DEFINE_LIME_PROP_READ(text_field,text_height); -DEFINE_LIME_PROP_READ(text_field,max_scroll_h); -DEFINE_LIME_PROP_READ(text_field,max_scroll_v); -DEFINE_LIME_PROP_READ(text_field,bottom_scroll_v); -DEFINE_LIME_PROP_READ(text_field,num_lines); -DEFINE_LIME_PRIM_MULT(bitmap_data_create); -DEFINE_LIME_PRIM_1(bitmap_data_width); -DEFINE_LIME_PRIM_1(bitmap_data_height); -DEFINE_LIME_PRIM_1(bitmap_data_get_prem_alpha); -DEFINE_LIME_PRIM_2(bitmap_data_set_prem_alpha); -DEFINE_LIME_PRIM_2(bitmap_data_clear); -DEFINE_LIME_PRIM_1(bitmap_data_get_transparent); -DEFINE_LIME_PRIM_2(bitmap_data_set_flags); -DEFINE_LIME_PRIM_4(bitmap_data_fill); -DEFINE_LIME_PRIM_2(bitmap_data_load); -DEFINE_LIME_PRIM_2(bitmap_data_set_format); -DEFINE_LIME_PRIM_2(bitmap_data_from_bytes); -DEFINE_LIME_PRIM_3(bitmap_data_encode); -DEFINE_LIME_PRIM_1(bitmap_data_clone); -DEFINE_LIME_PRIM_3(bitmap_data_color_transform); -DEFINE_LIME_PRIM_5(bitmap_data_apply_filter); -DEFINE_LIME_PRIM_5(bitmap_data_copy); -DEFINE_LIME_PRIM_MULT(bitmap_data_copy_channel); -DEFINE_LIME_PRIM_2(bitmap_data_get_pixels); -DEFINE_LIME_PRIM_3(bitmap_data_get_array); -DEFINE_LIME_PRIM_5(bitmap_data_get_color_bounds_rect); -DEFINE_LIME_PRIM_3(bitmap_data_get_pixel); -DEFINE_LIME_PRIM_3(bitmap_data_get_pixel32); -DEFINE_LIME_PRIM_3(bitmap_data_get_pixel_rgba); -DEFINE_LIME_PRIM_3(bitmap_data_scroll); -DEFINE_LIME_PRIM_4(bitmap_data_set_pixel); -DEFINE_LIME_PRIM_4(bitmap_data_set_pixel32); -DEFINE_LIME_PRIM_4(bitmap_data_set_pixel_rgba); -DEFINE_LIME_PRIM_4(bitmap_data_set_bytes); -DEFINE_LIME_PRIM_3(bitmap_data_set_array); -DEFINE_LIME_PRIM_3(bitmap_data_generate_filter_rect); -DEFINE_LIME_PRIM_MULT(bitmap_data_noise); -DEFINE_LIME_PRIM_4(bitmap_data_flood_fill); -DEFINE_LIME_PRIM_1(bitmap_data_unmultiply_alpha); -DEFINE_LIME_PRIM_1(bitmap_data_multiply_alpha); -DEFINE_LIME_PRIM_MULT(render_surface_to_surface); -DEFINE_LIME_PRIM_1(bitmap_data_dispose); -DEFINE_LIME_PRIM_1(bitmap_data_destroy_hardware_surface); -DEFINE_LIME_PRIM_1(bitmap_data_create_hardware_surface); -DEFINE_LIME_PRIM_1(bitmap_data_dump_bits); -DEFINE_LIME_PRIM_2(video_create); -DEFINE_LIME_PRIM_2(video_load); -DEFINE_LIME_PRIM_1(video_play); -DEFINE_LIME_PRIM_1(video_clear); -DEFINE_LIME_PRIM_2(video_set_smoothing); -DEFINE_LIME_PRIM_2(sound_from_file); -DEFINE_LIME_PRIM_3(sound_from_data); -DEFINE_LIME_PRIM_2(sound_get_id3); -DEFINE_LIME_PRIM_1(sound_get_length); -DEFINE_LIME_PRIM_1(sound_close); -DEFINE_LIME_PRIM_1(sound_get_status); -DEFINE_LIME_PRIM_1(sound_channel_is_complete); -DEFINE_LIME_PRIM_1(sound_channel_get_left); -DEFINE_LIME_PRIM_1(sound_channel_get_right); -DEFINE_LIME_PRIM_1(sound_channel_get_position); -DEFINE_LIME_PRIM_2(sound_channel_set_position); -DEFINE_LIME_PRIM_1(sound_channel_stop); -DEFINE_LIME_PRIM_2(sound_channel_set_transform); -DEFINE_LIME_PRIM_4(sound_channel_create); -DEFINE_LIME_PRIM_1(sound_channel_needs_data); -DEFINE_LIME_PRIM_2(sound_channel_add_data); -DEFINE_LIME_PRIM_1(sound_channel_get_data_position); -DEFINE_LIME_PRIM_2(sound_channel_create_dynamic); -DEFINE_LIME_PRIM_1(tilesheet_create); -DEFINE_LIME_PRIM_3(tilesheet_add_rect); -DEFINE_LIME_PRIM_1(curl_initialize); -DEFINE_LIME_PRIM_1(curl_create); -DEFINE_LIME_PRIM_0(curl_process_loaders); -DEFINE_LIME_PRIM_2(curl_update_loader); -DEFINE_LIME_PRIM_1(curl_get_error_message); -DEFINE_LIME_PRIM_1(curl_get_code); -DEFINE_LIME_PRIM_1(curl_get_data); -DEFINE_LIME_PRIM_1(curl_get_cookies); -DEFINE_LIME_PRIM_1(curl_get_headers); -DEFINE_LIME_PRIM_1(lzma_encode); -DEFINE_LIME_PRIM_1(lzma_decode); -DEFINE_LIME_PRIM_2(file_dialog_folder); -DEFINE_LIME_PRIM_3(file_dialog_open); -DEFINE_LIME_PRIM_3(file_dialog_save); -DEFINE_LIME_PRIM_1(font_iterate_device_fonts); - - -namespace nme { - - DEFINE_LIME_PRIM_1(font_set_factory); - DEFINE_LIME_PRIM_2(font_register_font); - DEFINE_LIME_PRIM_0(gl_get_error); - DEFINE_LIME_PRIM_0(gl_finish); - DEFINE_LIME_PRIM_0(gl_flush); - DEFINE_LIME_PRIM_0(gl_version); - DEFINE_LIME_PRIM_1(gl_enable); - DEFINE_LIME_PRIM_1(gl_disable); - DEFINE_LIME_PRIM_2(gl_hint); - DEFINE_LIME_PRIM_1(gl_line_width); - DEFINE_LIME_PRIM_0(gl_get_context_attributes); - DEFINE_LIME_PRIM_1(gl_get_supported_extensions); - DEFINE_LIME_PRIM_1(gl_front_face); - DEFINE_LIME_PRIM_1(gl_get_parameter); - DEFINE_LIME_PRIM_1(gl_is_enabled); - DEFINE_LIME_PRIM_0(gl_create_program); - DEFINE_LIME_PRIM_1(gl_create_shader); - DEFINE_LIME_PRIM_3(gl_stencil_func); - DEFINE_LIME_PRIM_4(gl_stencil_func_separate); - DEFINE_LIME_PRIM_1(gl_stencil_mask); - DEFINE_LIME_PRIM_2(gl_stencil_mask_separate); - DEFINE_LIME_PRIM_3(gl_stencil_op); - DEFINE_LIME_PRIM_4(gl_stencil_op_separate); - DEFINE_LIME_PRIM_4(gl_blend_color); - DEFINE_LIME_PRIM_1(gl_blend_equation); - DEFINE_LIME_PRIM_2(gl_blend_equation_separate); - DEFINE_LIME_PRIM_2(gl_blend_func); - DEFINE_LIME_PRIM_4(gl_blend_func_separate); - DEFINE_LIME_PRIM_1(gl_link_program); - DEFINE_LIME_PRIM_1(gl_validate_program); - DEFINE_LIME_PRIM_1(gl_get_program_info_log); - DEFINE_LIME_PRIM_3(gl_bind_attrib_location); - DEFINE_LIME_PRIM_2(gl_get_attrib_location); - DEFINE_LIME_PRIM_2(gl_get_uniform_location); - DEFINE_LIME_PRIM_2(gl_get_uniform); - DEFINE_LIME_PRIM_2(gl_get_program_parameter); - DEFINE_LIME_PRIM_1(gl_use_program); - DEFINE_LIME_PRIM_2(gl_get_active_attrib); - DEFINE_LIME_PRIM_2(gl_get_active_uniform); - DEFINE_LIME_PRIM_4(gl_uniform_matrix); - DEFINE_LIME_PRIM_2(gl_uniform1iv); - DEFINE_LIME_PRIM_2(gl_uniform2iv); - DEFINE_LIME_PRIM_2(gl_uniform3iv); - DEFINE_LIME_PRIM_2(gl_uniform4iv); - DEFINE_LIME_PRIM_2(gl_uniform1fv); - DEFINE_LIME_PRIM_2(gl_uniform2fv); - DEFINE_LIME_PRIM_2(gl_uniform3fv); - DEFINE_LIME_PRIM_2(gl_uniform4fv); - DEFINE_LIME_PRIM_2(gl_vertex_attrib1f); - DEFINE_LIME_PRIM_3(gl_vertex_attrib2f); - DEFINE_LIME_PRIM_4(gl_vertex_attrib3f); - DEFINE_LIME_PRIM_5(gl_vertex_attrib4f); - DEFINE_LIME_PRIM_2(gl_vertex_attrib1fv); - DEFINE_LIME_PRIM_2(gl_vertex_attrib2fv); - DEFINE_LIME_PRIM_2(gl_vertex_attrib3fv); - DEFINE_LIME_PRIM_2(gl_vertex_attrib4fv); - DEFINE_LIME_PRIM_2(gl_shader_source); - DEFINE_LIME_PRIM_2(gl_attach_shader); - DEFINE_LIME_PRIM_2(gl_detach_shader); - DEFINE_LIME_PRIM_1(gl_compile_shader); - DEFINE_LIME_PRIM_2(gl_get_shader_parameter); - DEFINE_LIME_PRIM_1(gl_get_shader_info_log); - DEFINE_LIME_PRIM_1(gl_get_shader_source); - DEFINE_LIME_PRIM_2(gl_get_shader_precision_format); - DEFINE_LIME_PRIM_2(gl_bind_buffer); - DEFINE_LIME_PRIM_5(gl_buffer_data); - DEFINE_LIME_PRIM_5(gl_buffer_sub_data); - DEFINE_LIME_PRIM_2(gl_get_vertex_attrib_offset); - DEFINE_LIME_PRIM_2(gl_get_vertex_attrib); - DEFINE_LIME_PRIM_MULT(gl_vertex_attrib_pointer); - DEFINE_LIME_PRIM_1(gl_enable_vertex_attrib_array); - DEFINE_LIME_PRIM_1(gl_disable_vertex_attrib_array); - DEFINE_LIME_PRIM_2(gl_get_buffer_paramerter); - DEFINE_LIME_PRIM_2(gl_get_buffer_parameter); - DEFINE_LIME_PRIM_2(gl_bind_framebuffer); - DEFINE_LIME_PRIM_2(gl_bind_renderbuffer); - DEFINE_LIME_PRIM_1(gl_delete_render_buffer); - DEFINE_LIME_PRIM_4(gl_framebuffer_renderbuffer); - DEFINE_LIME_PRIM_5(gl_framebuffer_texture2D); - DEFINE_LIME_PRIM_4(gl_renderbuffer_storage); - DEFINE_LIME_PRIM_1(gl_check_framebuffer_status); - DEFINE_LIME_PRIM_3(gl_get_framebuffer_attachment_parameter); - DEFINE_LIME_PRIM_2(gl_get_render_buffer_parameter); - DEFINE_LIME_PRIM_3(gl_draw_arrays); - DEFINE_LIME_PRIM_4(gl_draw_elements); - DEFINE_LIME_PRIM_4(gl_viewport); - DEFINE_LIME_PRIM_4(gl_scissor); - DEFINE_LIME_PRIM_1(gl_clear); - DEFINE_LIME_PRIM_4(gl_clear_color); - DEFINE_LIME_PRIM_1(gl_clear_depth); - DEFINE_LIME_PRIM_1(gl_clear_stencil); - DEFINE_LIME_PRIM_4(gl_color_mask); - DEFINE_LIME_PRIM_1(gl_depth_func); - DEFINE_LIME_PRIM_1(gl_depth_mask); - DEFINE_LIME_PRIM_2(gl_depth_range); - DEFINE_LIME_PRIM_1(gl_cull_face); - DEFINE_LIME_PRIM_2(gl_polygon_offset); - DEFINE_LIME_PRIM_MULT(gl_read_pixels); - DEFINE_LIME_PRIM_2(gl_pixel_storei); - DEFINE_LIME_PRIM_2(gl_sample_coverage); - DEFINE_LIME_PRIM_1(gl_active_texture); - DEFINE_LIME_PRIM_2(gl_bind_texture); - DEFINE_LIME_PRIM_1(gl_bind_bitmap_data_texture); - DEFINE_LIME_PRIM_MULT(gl_tex_image_2d); - DEFINE_LIME_PRIM_MULT(gl_tex_sub_image_2d); - DEFINE_LIME_PRIM_MULT(gl_compressed_tex_image_2d); - DEFINE_LIME_PRIM_MULT(gl_compressed_tex_sub_image_2d); - DEFINE_LIME_PRIM_3(gl_tex_parameterf); - DEFINE_LIME_PRIM_3(gl_tex_parameteri); - DEFINE_LIME_PRIM_MULT(gl_copy_tex_image_2d); - DEFINE_LIME_PRIM_MULT(gl_copy_tex_sub_image_2d); - DEFINE_LIME_PRIM_1(gl_generate_mipmap); - DEFINE_LIME_PRIM_2(gl_get_tex_parameter); - DEFINE_LIME_PRIM_1(gl_is_buffer); - DEFINE_LIME_PRIM_1(gl_is_program); - DEFINE_LIME_PRIM_1(gl_is_renderbuffer); - DEFINE_LIME_PRIM_1(gl_is_framebuffer); - DEFINE_LIME_PRIM_1(gl_is_shader); - DEFINE_LIME_PRIM_1(gl_is_texture); - DEFINE_LIME_PRIM_1(gl_delete_texture); - DEFINE_LIME_PRIM_1(gl_delete_shader); - DEFINE_LIME_PRIM_1(gl_delete_program); - DEFINE_LIME_PRIM_1(gl_delete_framebuffer); - DEFINE_LIME_PRIM_1(gl_delete_renderbuffer); - DEFINE_LIME_PRIM_1(gl_delete_buffer); - DEFINE_LIME_PRIM_0(gl_create_texture); - DEFINE_LIME_PRIM_0(gl_create_buffer); - DEFINE_LIME_PRIM_0(gl_create_framebuffer); - DEFINE_LIME_PRIM_0(gl_create_render_buffer); - DEFINE_LIME_PRIM_2(gl_uniform1i); - DEFINE_LIME_PRIM_2(gl_uniform1f); - DEFINE_LIME_PRIM_3(gl_uniform2i); - DEFINE_LIME_PRIM_3(gl_uniform2f); - DEFINE_LIME_PRIM_4(gl_uniform3i); - DEFINE_LIME_PRIM_4(gl_uniform3f); - DEFINE_LIME_PRIM_5(gl_uniform4i); - DEFINE_LIME_PRIM_5(gl_uniform4f); +namespace lime { - namespace S3D { + value lime_application_create () { - - #ifdef NME_S3D - DEFINE_LIME_PRIM_0(get_s3d_enabled); - DEFINE_LIME_PRIM_1(set_s3d_enabled); - DEFINE_LIME_PRIM_0(get_s3d_supported); - #else - value nme_get_s3d_enabled() { return alloc_bool(false); } - value nme_set_s3d_enabled(value inVal) { return inVal; } - value nme_get_s3d_supported() { return alloc_bool(false); } - DEFINE_LIME_PRIM_0(get_s3d_enabled); - DEFINE_LIME_PRIM_1(set_s3d_enabled); - DEFINE_LIME_PRIM_0(get_s3d_supported); - #endif - + Application* app = CreateApplication (); + return alloc_int ((intptr_t)app); } - #ifdef NME_S3D - DEFINE_LIME_PRIM_0(gl_s3d_get_eye_separation); - DEFINE_LIME_PRIM_1(gl_s3d_set_eye_separation); - DEFINE_LIME_PRIM_0(gl_s3d_get_focal_length); - DEFINE_LIME_PRIM_1(gl_s3d_set_focal_length); - #endif + value lime_application_exec (value application) { + + Application* app = (Application*)(intptr_t)val_int (application); + return alloc_int (app->Exec ()); + + } + + + value lime_renderer_create (value window) { + + Renderer* renderer = CreateRenderer ((Window*)(intptr_t)val_int (window)); + return alloc_int ((intptr_t)renderer); + + } + + + value lime_window_create (value application) { + + Window* window = CreateWindow ((Application*)(intptr_t)val_int (application)); + return alloc_int ((intptr_t)window); + + } + + + DEFINE_PRIM (lime_application_create, 0); + DEFINE_PRIM (lime_application_exec, 1); + DEFINE_PRIM (lime_renderer_create, 1); + DEFINE_PRIM (lime_window_create, 1); } -extern "C" int nme_register_prims(); - -extern "C" int lime_register_prims() -{ - nme_register_prims(); +extern "C" int lime_register_prims () { + return 0; + } \ No newline at end of file diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp new file mode 100644 index 000000000..f639a175f --- /dev/null +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -0,0 +1,66 @@ +#include "SDLApplication.h" + + +namespace lime { + + + SDLApplication::SDLApplication () { + + SDL_Init (SDL_INIT_VIDEO); + + } + + + SDLApplication::~SDLApplication () { + + + + } + + + int SDLApplication::Exec () { + + SDL_Event event; + bool active = true; + + while (active) { + + while (active && SDL_WaitEvent (&event)) { + + if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) { + + active = false; + break; + + } + + } + + while (active && SDL_PollEvent (&event)) { + + if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) { + + active = false; + break; + + } + + } + + } + + SDL_Quit (); + + return 0; + + } + + + Application* CreateApplication () { + + return new SDLApplication (); + + } + + +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLApplication.h b/project/src/backend/sdl/SDLApplication.h new file mode 100644 index 000000000..2b6401a64 --- /dev/null +++ b/project/src/backend/sdl/SDLApplication.h @@ -0,0 +1,27 @@ +#ifndef LIME_SDL_APPLICATION_H +#define LIME_SDL_APPLICATION_H + + +#include +#include "Application.h" + + +namespace lime { + + + class SDLApplication : public Application { + + public: + + SDLApplication (); + ~SDLApplication (); + + virtual int Exec (); + + }; + + +} + + +#endif \ No newline at end of file diff --git a/project/src/backend/sdl/SDLRenderer.cpp b/project/src/backend/sdl/SDLRenderer.cpp new file mode 100644 index 000000000..78ca7db62 --- /dev/null +++ b/project/src/backend/sdl/SDLRenderer.cpp @@ -0,0 +1,30 @@ +#include "SDLWindow.h" +#include "SDLRenderer.h" + + +namespace lime { + + + SDLRenderer::SDLRenderer (Window* window) { + + currentWindow = window; + sdlRenderer = SDL_CreateRenderer (((SDLWindow*)window)->sdlWindow, -1, 0); + + } + + + SDLRenderer::~SDLRenderer () { + + + + } + + + Renderer* CreateRenderer (Window* window) { + + return new SDLRenderer (window); + + } + + +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLRenderer.h b/project/src/backend/sdl/SDLRenderer.h new file mode 100644 index 000000000..821a9c48f --- /dev/null +++ b/project/src/backend/sdl/SDLRenderer.h @@ -0,0 +1,27 @@ +#ifndef LIME_SDL_RENDERER_H +#define LIME_SDL_RENDERER_H + + +#include +#include "Renderer.h" + + +namespace lime { + + + class SDLRenderer : public Renderer { + + public: + + SDLRenderer (Window* window); + ~SDLRenderer (); + + SDL_Renderer* sdlRenderer; + + }; + + +} + + +#endif \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp new file mode 100644 index 000000000..9c96d9530 --- /dev/null +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -0,0 +1,30 @@ +#include "SDLWindow.h" +#include + + +namespace lime { + + + SDLWindow::SDLWindow (Application* application) { + + currentApplication = application; + sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, 0); + + } + + + SDLWindow::~SDLWindow () { + + + + } + + + Window* CreateWindow (Application* application) { + + return new SDLWindow (application); + + } + + +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h new file mode 100644 index 000000000..a0ed0eeae --- /dev/null +++ b/project/src/backend/sdl/SDLWindow.h @@ -0,0 +1,27 @@ +#ifndef LIME_SDL_WINDOW_H +#define LIME_SDL_WINDOW_H + + +#include +#include "Window.h" + + +namespace lime { + + + class SDLWindow : public Window { + + public: + + SDLWindow (Application* application); + ~SDLWindow (); + + SDL_Window* sdlWindow; + + }; + + +} + + +#endif \ No newline at end of file diff --git a/templates/haxe/ApplicationMain.hx b/templates/haxe/ApplicationMain.hx index b4a1615ef..9abda5b11 100644 --- a/templates/haxe/ApplicationMain.hx +++ b/templates/haxe/ApplicationMain.hx @@ -1,36 +1,40 @@ import ::APP_MAIN::; -import lime.Lime; class ApplicationMain { - - public static var _main_ : ::APP_MAIN::; - public static var _lime : Lime; - - public static function main () { - //Create the runtime - _lime = new Lime(); - //Create the app class, give it to the bootstrapper - _main_ = new ::APP_MAIN::(); - - var config : LimeConfig = { - host : _main_, - fullscreen : ::WIN_FULLSCREEN::, - resizable : ::WIN_RESIZABLE::, - borderless : ::WIN_BORDERLESS::, - antialiasing : Std.int(::WIN_ANTIALIASING::), - stencil_buffer : ::WIN_STENCIL_BUFFER::, - depth_buffer : ::WIN_DEPTH_BUFFER::, - vsync : ::WIN_VSYNC::, - fps : Std.int(::WIN_FPS::), - width : Std.int(::WIN_WIDTH::), - height : Std.int(::WIN_HEIGHT::), - orientation : "::WIN_ORIENTATION::", - title : "::APP_TITLE::", - }; - - //Start up - _lime.init( _main_, config ); - } - + + + private var app:lime.app.Application; + + + public static function main () { + + var app = new ::APP_MAIN:: (); + + var config:lime.app.Config = { + + antialiasing: Std.int (::WIN_ANTIALIASING::), + borderless: ::WIN_BORDERLESS::, + depthBuffer: ::WIN_DEPTH_BUFFER::, + fps: Std.int (::WIN_FPS::), + fullscreen: ::WIN_FULLSCREEN::, + height: Std.int (::WIN_HEIGHT::), + orientation: "::WIN_ORIENTATION::", + resizable: ::WIN_RESIZABLE::, + stencilBuffer: ::WIN_STENCIL_BUFFER::, + title: "::APP_TITLE::", + vsync: ::WIN_VSYNC::, + width: Std.int (::WIN_WIDTH::), + + } + + app.create (config); + + #if sys + Sys.exit (app.exec ()); + #end + + } + + } \ No newline at end of file diff --git a/templates/project/Assets/lime.svg b/templates/project/Assets/lime.svg new file mode 100644 index 000000000..0e20a1c77 --- /dev/null +++ b/templates/project/Assets/lime.svg @@ -0,0 +1,54 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/project/Project.hxproj b/templates/project/Project.hxproj new file mode 100644 index 000000000..6d1b7c5aa --- /dev/null +++ b/templates/project/Project.hxproj @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/project/Source/Main.hx b/templates/project/Source/Main.hx new file mode 100644 index 000000000..a295f8f57 --- /dev/null +++ b/templates/project/Source/Main.hx @@ -0,0 +1,19 @@ +package; + + +import lime.app.Application; + + +class Main extends Application { + + + public function new () { + + super (); + + + + } + + +} \ No newline at end of file diff --git a/templates/project/project.xml b/templates/project/project.xml new file mode 100644 index 000000000..9f63eddf0 --- /dev/null +++ b/templates/project/project.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file