Explorar o código

Merge branch 'master' of https://github.com/taylor001/crown

Daniele Bartolini %!s(int64=12) %!d(string=hai) anos
pai
achega
9a494d2c81

+ 1 - 1
README.md

@@ -77,7 +77,7 @@ Windows:
 Android:
 
 	$ cd utils
-	$ ruby crown-android.rb --target <android-target> --name <project-name> --path <project-path>
+	$ ruby crown-android.rb --target <android-target> --name <project-name> --path <project-path> [--res <res-path>]
 
 You can also use the GUI front-end of CMake which can, less or more, simplify the overall 'complexity' of building from the terminal.
 

+ 1 - 0
engine/CMakeLists.txt

@@ -570,6 +570,7 @@ if (WINDOWS)
 	)
 
 	list (APPEND OS_HEADERS
+		os/win/WinHeaders.h
 		os/win/OsFile.h
 		os/win/OsThread.h
 		os/win/OsSocket.h

+ 0 - 4
engine/ConsoleServer.cpp

@@ -36,10 +36,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Filesystem.h"
 #include "MathUtils.h"
 
-#ifdef WINDOWS
-#undef NO_ERROR
-#endif
-
 namespace crown
 {
 

+ 0 - 5
engine/core/Log.cpp

@@ -28,11 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Device.h"
 #include "ConsoleServer.h"
 
-#ifdef WINDOWS
-#undef ERROR
-#define __va_copy(dest, src) (dest = src)
-#endif
-
 namespace crown
 {
 

+ 0 - 4
engine/core/Log.h

@@ -31,10 +31,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "Macros.h"
 
-#ifdef WINDOWS
-#undef ERROR
-#endif
-
 namespace crown
 {
 

+ 0 - 2
engine/core/containers/RBTree.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include <cstdlib>
 

+ 0 - 5
engine/core/math/Frustum.h

@@ -32,11 +32,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Plane.h"
 #include "Intersection.h"
 
-#ifdef WINDOWS
-#undef NEAR
-#undef FAR
-#endif
-
 namespace crown
 {
 

+ 0 - 3
engine/core/math/MathUtils.h

@@ -26,9 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#undef min
-#undef max
-
 #include <math.h>
 
 #include "Assert.h"

+ 0 - 2
engine/core/settings/FloatSetting.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include "Types.h"
 

+ 0 - 2
engine/core/settings/IntSetting.h

@@ -25,8 +25,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #pragma once
-#undef min
-#undef max
 
 #include "Types.h"
 

+ 0 - 6
engine/os/OS.h

@@ -43,13 +43,7 @@ namespace crown
 #elif defined(WINDOWS)
 	const size_t	MAX_PATH_LENGTH = 1024;
 	const char		PATH_SEPARATOR = '\\';
-
 	#define snprintf _snprintf
-
-	#undef MK_SHIFT
-	#undef MK_ALT
-	#undef ERROR
-
 #elif defined(ANDROID)
 	const size_t	MAX_PATH_LENGTH = 1024;
 	const char		PATH_SEPARATOR = '/';

+ 1 - 1
engine/os/win/AtomicInt.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "windows.h"
+#include "WinHeaders.h"
 
 namespace crown
 {

+ 1 - 5
engine/os/win/Cond.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "Mutex.h"
 #include "OS.h"

+ 1 - 5
engine/os/win/Mutex.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "OS.h"
 

+ 1 - 5
engine/os/win/OsFile.h

@@ -26,12 +26,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
 #include <cstdio>
-#include <windows.h>
+#include "WinHeaders.h"
 #include "Types.h"
 #include "File.h"
 

+ 6 - 3
engine/os/win/OsSocket.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-//Undefined in Frustum.h, but winsock2 ecc need it.
+//Undefined in WinHeaders.h, but winsock2 ecc need it.
 #ifndef NEAR
 #define NEAR
 #endif
@@ -35,7 +35,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 #endif
 
 #include <winsock2.h>
-#include <windows.h>
+#include "WinHeaders.h"
+
+//Re-undef NEAR and FAR after use
+#undef NEAR
+#undef FAR
 
 #include "NetAddress.h"
 #include "Assert.h"
@@ -43,7 +47,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "OS.h"
 
 #pragma comment(lib, "Ws2_32.lib")
-#undef NO_ERROR
 
 namespace crown
 {

+ 1 - 5
engine/os/win/OsThread.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include <process.h>
 #include <WinBase.h>
 

+ 1 - 5
engine/os/win/OsWindow.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 
 #include "Types.h"
 #include "Macros.h"

+ 1 - 5
engine/os/win/Semaphore.h

@@ -26,11 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
+#include "WinHeaders.h"
 #include <limits.h>
 
 #include "Assert.h"

+ 46 - 0
engine/os/win/WinHeaders.h

@@ -0,0 +1,46 @@
+/*
+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.
+*/
+
+#pragma once
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include "Windows.h"
+
+#undef NEAR
+#undef FAR
+#undef near
+#undef far
+#undef NO_ERROR
+#undef ERROR
+#undef MK_SHIFT
+#undef MK_ALT
+#undef min
+#undef max
+
+#define __va_copy(dest, src) (dest = src)

+ 1 - 1
engine/os/win/WinOS.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <windows.h>
+#include "WinHeaders.h"
 #include <cstdio>
 #include <cstdarg>
 #include "StringUtils.h"

+ 40 - 41
engine/os/win/main.cpp

@@ -24,10 +24,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
 #include <windowsx.h>
 
 #define WM_USER_SET_WINDOW_SIZE     (WM_USER+0)
@@ -427,53 +423,56 @@ public:
 	bool process_events()
 	{
 		OsEvent event;
-		do
+		bool exit = false;
+
+		while(m_queue.pop_event(event))
 		{
-			m_queue.pop_event(event);
+			if (event.type == OsEvent::NONE) continue;
 
-			if (event.type != OsEvent::NONE)
+			switch (event.type)
 			{
-				switch (event.type)
+				case OsEvent::MOUSE:
 				{
-					case OsEvent::MOUSE:
-					{
-						const OsMouseEvent& ev = event.mouse;
-						switch (ev.type)
-						{
-							case OsMouseEvent::BUTTON: m_mouse->set_button_state(ev.x, ev.y, ev.button, ev.pressed); break;
-							case OsMouseEvent::MOVE: m_mouse->set_position(ev.x, ev.y); break;
-							default: CE_FATAL("Oops, unknown mouse event type"); break;
-						}
-
-						break;
-					}
-					case OsEvent::KEYBOARD:
-					{
-						const OsKeyboardEvent& ev = event.keyboard;
-						m_keyboard->set_button_state(ev.button, ev.pressed);
-						break;
-					}
-					case OsEvent::METRICS:
-					{
-						const OsMetricsEvent& ev = event.metrics;
-						m_mouse->set_metrics(ev.width, ev.height);
-						break;
-					}
-					case OsEvent::EXIT:
-					{
-						return true;
-					}
-					default:
+					const OsMouseEvent& ev = event.mouse;
+					switch (ev.type)
 					{
-						Log::d("Unmanaged");
-						break;
+						case OsMouseEvent::BUTTON: m_mouse->set_button_state(ev.x, ev.y, ev.button, ev.pressed); break;
+						case OsMouseEvent::MOVE: m_mouse->set_position(ev.x, ev.y); break;
+						default: CE_FATAL("Oops, unknown mouse event type"); break;
 					}
+
+					break;
+				}
+				case OsEvent::KEYBOARD:
+				{
+					const OsKeyboardEvent& ev = event.keyboard;
+					m_keyboard->set_button_state(ev.button, ev.pressed);
+					break;
+				}
+				case OsEvent::METRICS:
+				{
+					const OsMetricsEvent& ev = event.metrics;
+					m_mouse->set_metrics(ev.width, ev.height);
+					//m_window->m_x = ev.x;
+					//m_window->m_y = ev.y;
+					//m_window->m_width = ev.width;
+					//m_window->m_height = ev.height;
+					break;
+				}
+				case OsEvent::EXIT:
+				{
+					exit = true;
+					break;
+				}
+				default:
+				{
+					CE_FATAL("Unknown Os Event");
+					break;
 				}
 			}
 		}
-		while (event.type != OsEvent::NONE);
 
-		return false;
+		return exit;
 	}
 
 	//-----------------------------------------------------------------------------

+ 1 - 1
engine/renderers/backend/gl/wgl/wglext.h

@@ -40,7 +40,7 @@ extern "C" {
 /* Function declaration macros - to move into glplatform.h */
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
 #define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
+#include "WinHeaders.h"
 #endif
 
 #ifndef APIENTRY