This commit is contained in:
Joshua Granick
2016-01-01 14:40:51 -08:00
12 changed files with 148 additions and 87 deletions

View File

@@ -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";
}
}

23
lime/Lib.hx Normal file
View File

@@ -0,0 +1,23 @@
package lime;
class Lib {
@:noCompletion private static var __sentWarnings = new Map<String, Bool> ();
public static function notImplemented (api:String):Void {
if (!__sentWarnings.exists (api)) {
__sentWarnings.set (api, true);
trace ("Warning: " + api + " is not implemented");
}
}
}

View File

@@ -51,6 +51,7 @@ class NativeRenderer {
useHardware = true;
parent.context = CONSOLE (new ConsoleRenderContext ());
parent.type = CONSOLE;
#else

View File

@@ -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
}
}

View File

@@ -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<Channel> ();
private static var fmodActiveChannels = new Array<FMODChannel> ();
private static var fmodActiveSources = new Array<AudioSource> ();
// 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) {

View File

@@ -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

View File

@@ -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<lime::ConsoleFmodChannel>")
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;
}

View File

@@ -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<lime::ConsoleFmodSound>")
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.

View File

@@ -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;
}

View File

@@ -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")

View File

@@ -145,8 +145,12 @@ class CPPHelper {
public static function rebuild (project:HXProject, commands:Array<Array<String>>, 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 {
}
}
}

View File

@@ -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
;
}