Daniele Bartolini 11 лет назад
Родитель
Сommit
39b164ada5
4 измененных файлов с 164 добавлено и 18 удалено
  1. 106 0
      engine/audio/sound_world_null.cpp
  2. 33 8
      engine/config.h
  3. 23 10
      genie/crown.lua
  4. 2 0
      genie/genie.lua

+ 106 - 0
engine/audio/sound_world_null.cpp

@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
+ * License: https://github.com/taylor001/crown/blob/master/LICENSE
+ */
+
+#include "config.h"
+
+#if CROWN_SOUND_NULL
+
+#include "sound_world.h"
+#include "audio.h"
+#include "memory.h"
+
+namespace crown
+{
+
+namespace audio_globals
+{
+	void init()
+	{
+	}
+
+	void shutdown()
+	{
+	}
+}
+
+class NullSoundWorld : public SoundWorld
+{
+public:
+
+	NullSoundWorld()
+	{
+	}
+
+	virtual ~NullSoundWorld()
+	{
+	}
+
+	virtual SoundInstanceId play(SoundResource* /*sr*/, bool /*loop*/, float /*volume*/, const Vector3& /*pos*/)
+	{
+		Id id;
+		id.id = INVALID_ID;
+		id.index = 0;
+		return id;
+	}
+
+	virtual void stop(SoundInstanceId /*id*/)
+	{
+	}
+
+	virtual bool is_playing(SoundInstanceId /*id*/)
+	{
+		return false;
+	}
+
+	virtual void stop_all()
+	{
+	}
+
+	virtual void pause_all()
+	{
+	}
+
+	virtual void resume_all()
+	{
+	}
+
+	virtual void set_sound_positions(uint32_t /*num*/, const SoundInstanceId* /*ids*/, const Vector3* /*positions*/)
+	{
+	}
+
+	virtual void set_sound_ranges(uint32_t /*num*/, const SoundInstanceId* /*ids*/, const float* /*ranges*/)
+	{
+	}
+
+	virtual void set_sound_volumes(uint32_t /*num*/, const SoundInstanceId* /*ids*/, const float* /*volumes*/)
+	{
+	}
+
+	virtual void reload_sounds(SoundResource* /*old_sr*/, SoundResource* /*new_sr*/)
+	{
+	}
+
+	virtual void set_listener_pose(const Matrix4x4& /*pose*/)
+	{
+	}
+
+	virtual void update()
+	{
+	}
+};
+
+SoundWorld* SoundWorld::create(Allocator& a)
+{
+	return CE_NEW(a, NullSoundWorld)();
+}
+
+void SoundWorld::destroy(Allocator& a, SoundWorld* sw)
+{
+	CE_DELETE(a, sw);
+}
+
+} // namespace crown
+
+#endif // CROWN_SOUND_NULL

+ 33 - 8
engine/config.h

@@ -9,6 +9,39 @@
 
 #include "platform.h"
 
+#ifndef CROWN_SOUND_NULL
+#	define CROWN_SOUND_NULL 1
+#endif
+
+#if !defined(CROWN_SOUND_OPENAL) \
+	&& !defined(CROWN_SOUND_OPENSLES)\
+	&& !defined(CROWN_SOUND_NULL)
+
+#	ifndef CROWN_SOUND_OPENAL
+#		define CROWN_SOUND_OPENAL (CROWN_PLATFORM_LINUX || CROWN_PLATFORM_WINDOWS)
+#	endif // CROWN_SOUND_OPENAL
+
+#	ifndef CROWN_SOUND_OPENSLES
+#		define CROWN_SOUND_OPENSLES (CROWN_PLATFORM_ANDROID)
+#	endif // CROWN_SOUND_OPENSLES
+
+#	ifndef CROWN_SOUND_NULL
+#		define CROWN_SOUND_NULL
+#	endif // CROWN_SOUND_NULL
+#else
+#	ifndef CROWN_SOUND_OPENAL
+#		define CROWN_SOUND_OPENAL 0
+#	endif
+
+#	ifndef CROWN_SOUND_OPENSLES
+#		define CROWN_SOUND_OPENSLES 0
+#	endif
+
+#	ifndef CROWN_SOUND_NULL
+#		define CROWN_SOUND_NULL 0
+#	endif
+#endif
+
 #ifndef CROWN_DEFAULT_PIXELS_PER_METER
 	#define CROWN_DEFAULT_PIXELS_PER_METER 32
 #endif // CROWN_DEFAULT_PIXELS_PER_METER
@@ -104,11 +137,3 @@
 #ifndef CROWN_MAX_LUA_QUATERNION
 	#define CROWN_MAX_LUA_QUATERNION 4096
 #endif // CE_MAX
-
-#ifndef CROWN_SOUND_OPENAL
-	#define CROWN_SOUND_OPENAL (CROWN_PLATFORM_LINUX || CROWN_PLATFORM_WINDOWS)
-#endif // CROWN_SOUND_OPENAL
-
-#ifndef CROWN_SOUND_OPENSLES
-	#define CROWN_SOUND_OPENSLES (CROWN_PLATFORM_ANDROID)
-#endif // CROWN_SOUND_OPENSLES

+ 23 - 10
genie/crown.lua

@@ -30,7 +30,6 @@ function crown_project(_name, _kind, _defines)
 			CROWN_DIR .. "engine/physics",
 			CROWN_DIR .. "engine/world",
 			CROWN_DIR .. "third/luajit/src",
-			CROWN_DIR .. "third/openal/include",
 			CROWN_DIR .. "third/freetype",
 			CROWN_DIR .. "third/stb_image",
 			CROWN_DIR .. "third/stb_vorbis",
@@ -39,6 +38,29 @@ function crown_project(_name, _kind, _defines)
 			CROWN_DIR .. "third/bx/include",
 		}
 
+		if _OPTIONS["with-openal"] then
+			includedirs {
+				CROWN_DIR .. "third/openal/include"
+			}
+
+			-- Fix this in GENie
+			configuration { "debug", "x32", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-debug-32", }
+			configuration { "development", "x32", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-development-32", }
+			configuration { "release", "x32", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-release-32", }
+			configuration { "debug", "x64", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-debug-64", }
+			configuration { "development", "x64", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-development-64", }
+			configuration { "release", "x64", "linux-*" }
+				linkoptions { "-Lbin/debug", "-lopenal-release-64", }
+
+			configuration { "vs*" }
+				links { "openal", }
+		end
+
 		defines {
 			_defines,
 		}
@@ -140,14 +162,6 @@ function crown_project(_name, _kind, _defines)
 				"dl",
 			}
 
-		-- Fix this in GENie
-		configuration { "debug", "x32", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-debug-32", }
-		configuration { "development", "x32", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-development-32", }
-		configuration { "release", "x32", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-release-32", }
-		configuration { "debug", "x64", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-debug-64", }
-		configuration { "development", "x64", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-development-64", }
-		configuration { "release", "x64", "linux-*" } linkoptions { "-Lbin/debug", "-lopenal-release-64", }
-
 		configuration { "debug", "linux-*" }
 			links {
 				"bgfxDebug"
@@ -306,7 +320,6 @@ function crown_project(_name, _kind, _defines)
 			links {
 				"OpenGL32",
 				"lua51",
-				"openal",
 				"dbghelp"
 			}
 

+ 2 - 0
genie/genie.lua

@@ -29,10 +29,12 @@ local CROWN_BUILD_DIR = (CROWN_DIR .. ".build/")
 dofile ("toolchain.lua")
 toolchain(CROWN_BUILD_DIR, CROWN_THIRD_DIR)
 
+group "libs"
 if _OPTIONS["with-openal"] then
 	dofile ("openal.lua")
 end
 
+group "engine"
 dofile "crown.lua"
 crown_project("", "ConsoleApp", {})