Parcourir la source

Merge branch 'master' into win-port

Conflicts:
	CMakeLists.txt
	samples/CMakeLists.txt
mikymod il y a 12 ans
Parent
commit
f881232a22

+ 0 - 42
CMakeLists.txt

@@ -10,25 +10,6 @@ option (CROWN_BUILD_SAMPLES "Whether to build the samples" ON)
 option (CROWN_BUILD_TOOLS "Whether to build the tools" ON)
 option (CROWN_BUILD_TESTS "Whether to build unit tests" OFF)
 
-# platform independent includes
-set (CROWN_INCLUDES
-	${CMAKE_SOURCE_DIR}/src
-	${CMAKE_SOURCE_DIR}/src/core
-	${CMAKE_SOURCE_DIR}/src/core/bv
-	${CMAKE_SOURCE_DIR}/src/core/containers
-	${CMAKE_SOURCE_DIR}/src/core/math
-	${CMAKE_SOURCE_DIR}/src/core/mem
-	${CMAKE_SOURCE_DIR}/src/core/compressors
-	${CMAKE_SOURCE_DIR}/src/core/filesystem
-	${CMAKE_SOURCE_DIR}/src/core/strings
-	${CMAKE_SOURCE_DIR}/src/core/settings
-	${CMAKE_SOURCE_DIR}/src/os
-	${CMAKE_SOURCE_DIR}/src/input
-	${CMAKE_SOURCE_DIR}/src/renderers
-	${CMAKE_SOURCE_DIR}/src/network
-	${CMAKE_SOURCE_DIR}/src/lua
-)
-
 # always debug mode for now
 set (CROWN_DEBUG 1)
 
@@ -60,35 +41,12 @@ set (CROWN_THIRD_LIBS
 # detect operating system
 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	set (LINUX 1)
-
-	list (APPEND CROWN_INCLUDES
-		${CMAKE_SOURCE_DIR}/src/os/linux
-		${CMAKE_SOURCE_DIR}/src/renderers/gl/glx
-	)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 	set(WINDOWS 1)
-
-	list (APPEND CROWN_INCLUDES
-		${CMAKE_SOURCE_DIR}/src/os/win
-		${CMAKE_SOURCE_DIR}/src/renderers/gl/wgl
-	)
-	
-	list (APPEND CROWN_THIRD_INCLUDES
-		${CROWN_THIRD}/zlib/include
-		${CROWN_THIRD}/luajit/include/luajit-2.0
-	)
-
-	list (APPEND CROWN_THIRD_LIBS
-		${CROWN_THIRD}/zlib/lib
-		${CROWN_THIRD}/luajit/lib
-	)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 
-include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
-link_directories(${CROWN_THIRD_LIBS})
-
 # add build directories
 add_subdirectory(src)
 add_subdirectory(${CROWN_THIRD}) #necessary?

+ 41 - 4
samples/CMakeLists.txt

@@ -2,8 +2,45 @@ cmake_minimum_required(VERSION 2.8)
 
 project(crown-samples)
 
-link_directories(${CROWN_BINARY_DIR})
+# platform independent includes
+set (CROWN_INCLUDES
+	${CMAKE_SOURCE_DIR}/src
+	${CMAKE_SOURCE_DIR}/src/core
+	${CMAKE_SOURCE_DIR}/src/core/bv
+	${CMAKE_SOURCE_DIR}/src/core/containers
+	${CMAKE_SOURCE_DIR}/src/core/math
+	${CMAKE_SOURCE_DIR}/src/core/mem
+	${CMAKE_SOURCE_DIR}/src/core/compressors
+	${CMAKE_SOURCE_DIR}/src/core/filesystem
+	${CMAKE_SOURCE_DIR}/src/core/strings
+	${CMAKE_SOURCE_DIR}/src/core/settings
+	${CMAKE_SOURCE_DIR}/src/os
+	${CMAKE_SOURCE_DIR}/src/input
+	${CMAKE_SOURCE_DIR}/src/renderers
+	${CMAKE_SOURCE_DIR}/src/network
+	${CMAKE_SOURCE_DIR}/src/lua
+)
 
-#add_subdirectory(terrain)
-#add_subdirectory(json)
-#add_subdirectory(lua)
+# detect operating system
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+	set (LINUX 1)
+
+	list (APPEND CROWN_INCLUDES
+		${CMAKE_SOURCE_DIR}/src/os/linux
+		${CMAKE_SOURCE_DIR}/src/renderers/glx
+	)
+endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+	set(WINDOWS 1)
+
+	list (APPEND CROWN_INCLUDES
+		${CMAKE_SOURCE_DIR}/src/os/win
+		${CMAKE_SOURCE_DIR}/src/renderers/gl/wgl
+	)
+endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+
+include_directories(${CROWN_INCLUDES})
+link_directories(${CROWN_BINARY_DIR} ${CROWN_THIRD_LIBS})
+
+add_subdirectory(terrain)

+ 27 - 1
src/CMakeLists.txt

@@ -1,3 +1,24 @@
+cmake_minimum_required(VERSION 2.8)
+
+# platform independent includes
+set (CROWN_INCLUDES
+	${CMAKE_SOURCE_DIR}/src
+	${CMAKE_SOURCE_DIR}/src/core
+	${CMAKE_SOURCE_DIR}/src/core/bv
+	${CMAKE_SOURCE_DIR}/src/core/containers
+	${CMAKE_SOURCE_DIR}/src/core/math
+	${CMAKE_SOURCE_DIR}/src/core/mem
+	${CMAKE_SOURCE_DIR}/src/core/compressors
+	${CMAKE_SOURCE_DIR}/src/core/filesystem
+	${CMAKE_SOURCE_DIR}/src/core/strings
+	${CMAKE_SOURCE_DIR}/src/core/settings
+	${CMAKE_SOURCE_DIR}/src/os
+	${CMAKE_SOURCE_DIR}/src/input
+	${CMAKE_SOURCE_DIR}/src/renderers
+	${CMAKE_SOURCE_DIR}/src/network
+	${CMAKE_SOURCE_DIR}/src/lua
+)
+
 set (SRC
 	Camera.cpp
 	Device.cpp
@@ -280,6 +301,11 @@ set (COMPILER_FLAGS
 
 # Platform specific stuff
 if (LINUX)
+	list (APPEND CROWN_INCLUDES
+		${CMAKE_SOURCE_DIR}/src/os/linux
+		${CMAKE_SOURCE_DIR}/src/renderers/gl/glx
+	)
+
 	list (APPEND OS_HEADERS
 		os/linux/OsWindow.h
 		os/linux/TCPSocket.h
@@ -449,4 +475,4 @@ install (FILES ${INPUT_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/input)
 install (FILES ${RENDERERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/renderers)
 install (FILES ${NETWORK_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/network)
 install (FILES ${OS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/os)
-install (FILES ${LUA_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/lua)
+install (FILES ${LUA_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/lua)

+ 2 - 2
src/Device.cpp

@@ -169,7 +169,7 @@ void Device::shutdown()
 	{
 		m_renderer->shutdown();
 
-		Renderer::destroy(m_renderer);
+		Renderer::destroy(m_allocator, m_renderer);
 	}
 
 	Log::i("Releasing Window...");
@@ -415,7 +415,7 @@ void Device::create_window()
 //-----------------------------------------------------------------------------
 void Device::create_renderer()
 {
-	m_renderer = Renderer::create();
+	m_renderer = Renderer::create(m_allocator);
 	m_renderer->init();
 
 	Log::d("Renderer created.");

+ 2 - 2
src/renderers/Renderer.h

@@ -101,8 +101,8 @@ class Renderer
 {
 public:
 
-	static Renderer*		create();
-	static void				destroy(Renderer* renderer);
+	static Renderer*		create(Allocator& a);
+	static void				destroy(Allocator& a, Renderer* renderer);
 
 	virtual 				~Renderer() {};
 

+ 4 - 4
src/renderers/gl/GLRenderer.cpp

@@ -1019,15 +1019,15 @@ GLint GLRenderer::find_gpu_program_uniform(GLuint program, const char* name) con
 }
 
 //-----------------------------------------------------------------------------
-Renderer* Renderer::create()
+Renderer* Renderer::create(Allocator& a)
 {
-	return CE_NEW(default_allocator(), GLRenderer);
+	return CE_NEW(a, GLRenderer);
 }
 
 //-----------------------------------------------------------------------------
-void Renderer::destroy(Renderer* renderer)
+void Renderer::destroy(Allocator& a, Renderer* renderer)
 {
-	CE_DELETE(default_allocator(), renderer);
+	CE_DELETE(a, renderer);
 }
 
 } // namespace crown

+ 1 - 0
tools/CMakeLists.txt

@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.8)
 project(crown-tools)
 
 set (INCLUDES
+	${CMAKE_SOURCE_DIR}/tools
 	${CMAKE_SOURCE_DIR}/tools/core
 	${CMAKE_SOURCE_DIR}/tools/core/formats
 	${CMAKE_SOURCE_DIR}/tools/core/strings

+ 5 - 1
tools/cli/resource-hash.cpp

@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "Crown.h"
+#include "Hash.h"
+#include "Path.h"
+#include "StringUtils.h"
+#include "Args.h"
+#include "Resource.h"
 
 using namespace crown;
 

+ 47 - 0
tools/core/Resource.h

@@ -0,0 +1,47 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+namespace crown
+{
+
+/// Hashed values for supported resource types
+const char* const TEXTURE_EXTENSION			= "tga";
+const char* const MESH_EXTENSION			= "dae";
+const char* const SCRIPT_EXTENSION			= "lua";
+const char* const TEXT_EXTENSION			= "txt";
+const char* const MATERIAL_EXTENSION		= "material";
+const char* const VERTEX_SHADER_EXTENSION	= "vs";
+const char* const PIXEL_SHADER_EXTENSION	= "ps";
+
+const uint32_t TEXTURE_TYPE					= 0x1410A16A;
+const uint32_t MESH_TYPE					= 0xE8239EEC;
+const uint32_t SCRIPT_TYPE					= 0xD96E7C37;
+const uint32_t TEXT_TYPE					= 0x9000BF0B;
+const uint32_t MATERIAL_TYPE				= 0x46807A92;
+const uint32_t VERTEX_SHADER_TYPE			= 0xDC7F061F;
+const uint32_t PIXEL_SHADER_TYPE			= 0x2A461B45;
+
+} // namespace crown

+ 2 - 0
tools/core/formats/PixelFormat.h

@@ -96,3 +96,5 @@ enum PixelFormat
 
 	PF_UNKNOWN = 40
 };
+
+} // namespace crown