diff --git a/lime/Assets.hx b/lime/Assets.hx index 9c80fbdea..217dddbfd 100644 --- a/lime/Assets.hx +++ b/lime/Assets.hx @@ -1164,7 +1164,11 @@ class Assets { var fields = embedData (":file"); + #if lime_console + if (false) { + #else if (fields != null) { + #end var constructor = macro { @@ -1188,7 +1192,11 @@ class Assets { var fields = embedData (":file"); + #if lime_console + if (false) { + #else if (fields != null) { + #end var constructor = macro { @@ -1535,4 +1543,4 @@ class Assets { var TEMPLATE = "TEMPLATE"; var TEXT = "TEXT"; -} \ No newline at end of file +} diff --git a/lime/Lib.hx b/lime/Lib.hx new file mode 100644 index 000000000..e2a9a79d4 --- /dev/null +++ b/lime/Lib.hx @@ -0,0 +1,23 @@ +package lime; + + +class Lib { + + + @:noCompletion private static var __sentWarnings = new Map (); + + + public static function notImplemented (api:String):Void { + + if (!__sentWarnings.exists (api)) { + + __sentWarnings.set (api, true); + + trace ("Warning: " + api + " is not implemented"); + + } + + } + + +} diff --git a/lime/_backend/native/NativeRenderer.hx b/lime/_backend/native/NativeRenderer.hx index a07f5d7a7..acd22c45c 100644 --- a/lime/_backend/native/NativeRenderer.hx +++ b/lime/_backend/native/NativeRenderer.hx @@ -51,6 +51,7 @@ class NativeRenderer { useHardware = true; parent.context = CONSOLE (new ConsoleRenderContext ()); + parent.type = CONSOLE; #else diff --git a/lime/audio/AudioBuffer.hx b/lime/audio/AudioBuffer.hx index 3babbbe58..729343c34 100644 --- a/lime/audio/AudioBuffer.hx +++ b/lime/audio/AudioBuffer.hx @@ -12,7 +12,7 @@ import js.html.Audio; #elseif flash import flash.media.Sound; #elseif lime_console -import lime.audio.fmod.Sound; +import lime.audio.fmod.FMODSound; #end #if !macro @@ -34,7 +34,7 @@ class AudioBuffer { #elseif flash public var src:Sound; #elseif lime_console - public var src:Sound; + public var src:FMODSound; #else public var src:Dynamic; #end @@ -50,33 +50,30 @@ class AudioBuffer { public function dispose ():Void { #if lime_console - src.release (); + if (channels > 0) { + src.release (); + channels = 0; + } #end } + + + #if lime_console + @:void + private static function finalize (a:AudioBuffer):Void { + + a.dispose (); + + } + #end public static function fromBytes (bytes:Bytes):AudioBuffer { #if lime_console - openfl.Lib.notImplemented ("Sound.fromBytes"); - - /* - var sound:Sound = Sound.fromBytes (bytes); - - if (sound.valid) { - - var audioBuffer = new AudioBuffer (); - audioBuffer.bitsPerSample = 0; - audioBuffer.channels = 0; - audioBuffer.data = null; - audioBuffer.sampleRate = 0; - audioBuffer.src = sound; - return audioBuffer; - - } - */ + lime.Lib.notImplemented ("AudioBuffer.fromBytes"); #elseif ((cpp || neko || nodejs) && !macro) @@ -104,16 +101,24 @@ class AudioBuffer { #if lime_console - var sound:Sound = Sound.fromFile (path); + var sound:FMODSound = FMODSound.fromFile (path); if (sound.valid) { + // TODO(james4k): AudioBuffer needs sound info filled in + // TODO(james4k): probably move fmod.Sound creation to AudioSource, + // and keep AudioBuffer as raw data. not as efficient for typical + // use, but probably less efficient to do complex copy-on-read + // mechanisms and such. also, what do we do for compressed sounds? + // usually don't want to decompress large music files. I suppose we + // can specialize for those and not allow data access. var audioBuffer = new AudioBuffer (); audioBuffer.bitsPerSample = 0; - audioBuffer.channels = 0; + audioBuffer.channels = 1; audioBuffer.data = null; audioBuffer.sampleRate = 0; audioBuffer.src = sound; + cpp.vm.Gc.setFinalizer (audioBuffer, cpp.Function.fromStaticFunction (finalize)); return audioBuffer; } @@ -185,4 +190,4 @@ class AudioBuffer { #end -} \ No newline at end of file +} diff --git a/lime/audio/AudioSource.hx b/lime/audio/AudioSource.hx index ed524134b..95359c913 100644 --- a/lime/audio/AudioSource.hx +++ b/lime/audio/AudioSource.hx @@ -8,7 +8,7 @@ import lime.audio.openal.AL; #if flash import flash.media.SoundChannel; #elseif lime_console -import lime.audio.fmod.Channel; +import lime.audio.fmod.FMODChannel; #end #if lime_console @@ -45,7 +45,7 @@ class AudioSource { #if flash private var channel:SoundChannel; #elseif lime_console - private var channel:Channel; + private var channel:FMODChannel; #end #if (cpp || neko || nodejs) @@ -170,7 +170,7 @@ class AudioSource { if (old != this) { - old.channel = Channel.INVALID; + old.channel = FMODChannel.INVALID; } @@ -276,19 +276,19 @@ class AudioSource { // boxing and allocations going on. // can't use Maps because we need by-value key comparisons, so use two arrays. - private static var fmodActiveChannels = new Array (); + private static var fmodActiveChannels = new Array (); private static var fmodActiveSources = new Array (); // onFmodChannelEnd is called from C++ when an fmod channel end callback is // called. - private static function onFmodChannelEnd (channel:Channel) { + private static function onFmodChannelEnd (channel:FMODChannel) { var source = removeFmodActive (channel); if (source != null) { - source.channel = Channel.INVALID; + source.channel = FMODChannel.INVALID; source.onComplete.dispatch (); } @@ -296,9 +296,9 @@ class AudioSource { } - // removeFmodActive disassociates a Channel with its AudioSource, returning + // removeFmodActive disassociates an FMODChannel with its AudioSource, returning // the AudioSource it was associated with. - private static function removeFmodActive(key:Channel):AudioSource { + private static function removeFmodActive(key:FMODChannel):AudioSource { for (i in 0...fmodActiveChannels.length) { @@ -325,11 +325,11 @@ class AudioSource { } - // setFmodActive associates a Channel with an AudioSource to allow for fmod + // setFmodActive associates an FMODChannel with an AudioSource to allow for fmod // channel callbacks to propagate to the user's AudioSource onComplete // callbacks. Returns the previous AudioSource associated with the channel // if there was one, or the passed in AudioSource if not. - private static function setFmodActive (key:Channel, value:AudioSource):AudioSource { + private static function setFmodActive (key:FMODChannel, value:AudioSource):AudioSource { for (i in 0...fmodActiveChannels.length) { @@ -402,6 +402,11 @@ class AudioSource { #elseif flash return Std.int (channel.position); + + #elseif lime_console + + lime.Lib.notImplemented ("AudioSource.get_currentTime"); + return 0; #else @@ -425,6 +430,11 @@ class AudioSource { // TODO: create new sound channel //channel.position = value; return pauseTime = value; + + #elseif lime_console + + lime.Lib.notImplemented ("AudioSource.set_currentTime"); + return value; #else @@ -471,6 +481,11 @@ class AudioSource { #elseif flash return channel.soundTransform.volume; + + #elseif lime_console + + lime.Lib.notImplemented ("AudioSource.get_gain"); + return 1; #else @@ -493,6 +508,11 @@ class AudioSource { soundTransform.volume = value; channel.soundTransform = soundTransform; return value; + + #elseif lime_console + + lime.Lib.notImplemented ("AudioSource.set_gain"); + return value; #else @@ -519,6 +539,11 @@ class AudioSource { #elseif flash return Std.int (buffer.src.length); + + #elseif lime_console + + lime.Lib.notImplemented ("AudioSource.get_length"); + return 0; #else @@ -532,7 +557,12 @@ class AudioSource { private function set_length (value:Int):Int { - #if (!flash && !html5) + #if lime_console + + lime.Lib.notImplemented ("AudioSource.set_length"); + return value; + + #elseif (!flash && !html5) if (playing && __length != value) { diff --git a/lime/audio/fmod/FMOD.hx b/lime/audio/fmod/FMOD.hx deleted file mode 100644 index 6f241c974..000000000 --- a/lime/audio/fmod/FMOD.hx +++ /dev/null @@ -1,23 +0,0 @@ -package lime.audio.fmod; -#if lime_console - - -import lime.system.System; - - -class FMOD { - - - //public static function createSound (name:String):Sound { - //} - - - #if lime_console - //private static var lime_fmod_sound_create:Dynamic = System.load ("lime", "lime_fmod_sound_create", 1); - #end - - -} - - -#end diff --git a/lime/audio/fmod/Channel.hx b/lime/audio/fmod/FMODChannel.hx similarity index 83% rename from lime/audio/fmod/Channel.hx rename to lime/audio/fmod/FMODChannel.hx index 5b1aecc65..8b0d045f7 100644 --- a/lime/audio/fmod/Channel.hx +++ b/lime/audio/fmod/FMODChannel.hx @@ -3,13 +3,11 @@ package lime.audio.fmod; import lime.ConsoleIncludePaths; -import lime.system.System; -import lime.utils.ByteArray; @:include("ConsoleFmodChannel.h") @:native("cpp::Struct") -extern class Channel { +extern class FMODChannel { // valid is true if this represents a valid handle to a channel. @@ -35,13 +33,13 @@ extern class Channel { // INVALID represents an invalid channel handle - public static var INVALID (get, never):Channel; + public static var INVALID (get, never):FMODChannel; private function get_valid ():Bool; @:native("lime::ConsoleFmodChannel") - private static function get_INVALID ():Channel; + private static function get_INVALID ():FMODChannel; } diff --git a/lime/audio/fmod/Sound.hx b/lime/audio/fmod/FMODSound.hx similarity index 76% rename from lime/audio/fmod/Sound.hx rename to lime/audio/fmod/FMODSound.hx index b033822d6..c0fef37e9 100644 --- a/lime/audio/fmod/Sound.hx +++ b/lime/audio/fmod/FMODSound.hx @@ -3,13 +3,11 @@ package lime.audio.fmod; import lime.ConsoleIncludePaths; -import lime.system.System; -import lime.utils.ByteArray; @:include("ConsoleFmodSound.h") @:native("cpp::Struct") -extern class Sound { +extern class FMODSound { // valid returns true if this represents a valid handle to a sound. @@ -18,11 +16,11 @@ extern class Sound { // fromFile creates a sound from the named file. @:native("lime::ConsoleFmodSound::fromFile") - public static function fromFile (name:String):Sound; + public static function fromFile (name:String):FMODSound; // play plays the sound and returns the channel it was assigned. - public function play ():Channel; + public function play ():FMODChannel; // release releases the sound. diff --git a/lime/graphics/console/RenderState.hx b/lime/graphics/console/RenderState.hx index 0456faf10..acf1af5ae 100644 --- a/lime/graphics/console/RenderState.hx +++ b/lime/graphics/console/RenderState.hx @@ -35,12 +35,16 @@ package lime.graphics.console; var SRCALPHA_INVSRCALPHA_INVDESTALPHA_ONE_RGBA = 6; var ZERO_INVSRCCOLOR_ONE_ZERO_RGBA = 7; var ZERO_SRCCOLOR_ONE_ZERO_RGBA = 8; - var SRCALPHA_ONE_ONE_ZERO_RGBA = 9; - var SRCALPHA_ONE_ONE_ONE_RGBA = 10; - var DESTCOLOR_SRCCOLOR_ONE_ZERO_RGBA = 11; - var ONE_ONE_ONE_ZERO_RGBA = 12; - var ONE_ONE_ONE_ONE_RGBA = 13; - var ONE_ZERO_ONE_ZERO_RGBA = 14; - var ZERO_ONE_ZERO_ONE = 15; + var SRCALPHA_ONE_ONE_ZERO_RGB = 9; + var SRCALPHA_ONE_ONE_ZERO_RGBA = 10; + var SRCALPHA_ONE_ONE_ONE_RGBA = 11; + var DESTCOLOR_INVSRCALPHA_ONE_ZERO_RGB = 12; + var DESTCOLOR_INVSRCALPHA_ONE_ZERO_RGBA = 13; + var DESTCOLOR_SRCCOLOR_ONE_ZERO_RGB = 14; + var DESTCOLOR_SRCCOLOR_ONE_ZERO_RGBA = 15; + var ONE_ONE_ONE_ZERO_RGBA = 16; + var ONE_ONE_ONE_ONE_RGBA = 17; + var ONE_ZERO_ONE_ZERO_RGBA = 18; + var ZERO_ONE_ZERO_ONE = 19; } diff --git a/lime/graphics/console/TextureData.hx b/lime/graphics/console/TextureData.hx index 86247f5f5..ed91cb07b 100644 --- a/lime/graphics/console/TextureData.hx +++ b/lime/graphics/console/TextureData.hx @@ -4,8 +4,6 @@ package lime.graphics.console; #if lime_console import cpp.Pointer; import cpp.UInt8; import lime.ConsoleIncludePaths; -import lime.system.System; -import lime.utils.ByteArray; @:include("ConsoleTextureData.h") diff --git a/lime/tools/helpers/CPPHelper.hx b/lime/tools/helpers/CPPHelper.hx index 8b0efbcba..4767614fe 100644 --- a/lime/tools/helpers/CPPHelper.hx +++ b/lime/tools/helpers/CPPHelper.hx @@ -145,8 +145,12 @@ class CPPHelper { public static function rebuild (project:HXProject, commands:Array>, path:String = null, buildFile:String = null):Void { var buildRelease = (!project.targetFlags.exists ("debug")); - var buildDebug = (project.targetFlags.exists ("debug") || (!project.targetFlags.exists ("rebuild") && !project.targetFlags.exists ("release") && project.config.exists ("project.rebuild.fulldebug"))); - + var buildDebug = (project.targetFlags.exists ("debug") || + (!project.targetFlags.exists ("rebuild") && + !project.targetFlags.exists ("release") && + !project.targetFlags.exists ("final") && + project.config.exists ("project.rebuild.fulldebug"))); + for (haxelib in project.haxelibs) { if (!rebuiltLibraries.exists (haxelib.name)) { @@ -320,4 +324,4 @@ class CPPHelper { } -} \ No newline at end of file +} diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 04aa340ea..ad7fe2e2d 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1493,19 +1493,34 @@ namespace lime { } +#ifdef LIME_CAIRO extern "C" int lime_cairo_register_prims (); +#endif +#ifdef LIME_CURL extern "C" int lime_curl_register_prims (); +#endif +#ifdef LIME_OPENAL extern "C" int lime_openal_register_prims (); +#endif +#ifdef LIME_OPENGL extern "C" int lime_opengl_register_prims (); +#endif extern "C" int lime_register_prims () { - lime_cairo_register_prims (); - lime_curl_register_prims (); - lime_openal_register_prims (); - lime_opengl_register_prims (); - - return 0; - + return 0 +#ifdef LIME_CAIRO + + lime_cairo_register_prims () +#endif +#ifdef LIME_CURL + + lime_curl_register_prims () +#endif +#ifdef LIME_OPENAL + + lime_openal_register_prims () +#endif +#ifdef LIME_OPENGL + + lime_opengl_register_prims () +#endif + ; }