Przeglądaj źródła

Fix Windows build

Daniele Bartolini 11 lat temu
rodzic
commit
0678899bcb

+ 2 - 2
engine/config.h

@@ -75,8 +75,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
 	#if !defined(WINVER) && !defined(_WIN32_WINNT)
 // Windows Server 2003 with SP1, Windows XP with SP2 and above
-		#define WINVER 0x0600
-		#define _WIN32_WINNT 0x0600
+		#define WINVER 0x0502
+		#define _WIN32_WINNT 0x0502
 	#endif // !defined(WINVER) && !defined(_WIN32_WINNT)
 	#define CROWN_PLATFORM_WINDOWS 1
 #elif defined(__ANDROID__)

+ 1 - 1
engine/core/filesystem/network_file.h

@@ -27,8 +27,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "assert.h"
-#include "file.h"
 #include "socket.h"
+#include "os.h"
 #include "file.h"
 
 namespace crown

+ 4 - 4
engine/core/math/math_utils.h

@@ -216,7 +216,7 @@ inline float sqrt(float x)
 //-----------------------------------------------------------------------------
 inline float inv_sqrt(float x)
 {
-	return 1.0 / sqrt(x);
+	return 1.0f / sqrt(x);
 }
 
 //-----------------------------------------------------------------------------
@@ -270,7 +270,7 @@ inline float fmod(float n, float d)
 //-----------------------------------------------------------------------------
 inline bool solve_quadratic_equation(float a, float b, float c, float& x1, float& x2)
 {
-	float delta = (b * b) - (4.0 * a * c);
+	float delta = (b * b) - (4.0f * a * c);
 
 	// If the equation has no float solutions
 	if (delta < 0.0)
@@ -278,8 +278,8 @@ inline bool solve_quadratic_equation(float a, float b, float c, float& x1, float
 		return false;
 	}
 
-	x1 = (-b + sqrt(delta)) / (2.0 * a);
-	x2 = (-b - sqrt(delta)) / (2.0 * a);
+	x1 = (-b + sqrt(delta)) / (2.0f * a);
+	x2 = (-b - sqrt(delta)) / (2.0f * a);
 
 	if (x2 > x1)
 	{

+ 5 - 5
engine/core/math/matrix3x3.h

@@ -185,7 +185,7 @@ namespace matrix3x3
 		mat.x.y = (m.x.y * m.z.z - m.z.y * m.x.z);
 		mat.x.z = (m.x.y * m.y.z - m.y.y * m.x.z);
 
-		const float inv_det = 1.0 / (m.x.x * mat.x.x - m.y.x * mat.x.y + m.z.x * mat.x.z);
+		const float inv_det = 1.0f / (m.x.x * mat.x.x - m.y.x * mat.x.y + m.z.x * mat.x.z);
 
 		mat.y.x = (m.y.x * m.z.z - m.z.x * m.y.z);
 		mat.y.y = (m.x.x * m.z.z - m.z.x * m.x.z);
@@ -321,9 +321,9 @@ inline Matrix3x3::Matrix3x3(const Vector3& x, const Vector3& y, const Vector3& z
 
 //-----------------------------------------------------------------------------
 inline Matrix3x3::Matrix3x3(const Quaternion& r)
-	: x(1.0 - 2.0 * r.y * r.y - 2.0 * r.z * r.z, 2.0 * r.x * r.y + 2.0 * r.w * r.z, 2.0 * r.x * r.z - 2.0 * r.w * r.y)
-	, y(2.0 * r.x * r.y - 2.0 * r.w * r.z, 1.0 - 2.0 * r.x * r.x - 2.0 * r.z * r.z, 2.0 * r.y * r.z + 2.0 * r.w * r.x)
-	, z(2.0 * r.x * r.z + 2.0 * r.w * r.y, 2.0 * r.y * r.z - 2.0 * r.w * r.x, 1.0 - 2.0 * r.x * r.x - 2.0 * r.y * r.y)
+	: x(1.0f - 2.0f * r.y * r.y - 2.0f * r.z * r.z, 2.0f * r.x * r.y + 2.0f * r.w * r.z, 2.0f * r.x * r.z - 2.0f * r.w * r.y)
+	, y(2.0f * r.x * r.y - 2.0f * r.w * r.z, 1.0f - 2.0f * r.x * r.x - 2.0f * r.z * r.z, 2.0f * r.y * r.z + 2.0f * r.w * r.x)
+	, z(2.0f * r.x * r.z + 2.0f * r.w * r.y, 2.0f * r.y * r.z - 2.0f * r.w * r.x, 1.0f - 2.0f * r.x * r.x - 2.0f * r.y * r.y)
 {
 }
 
@@ -393,7 +393,7 @@ inline Matrix3x3& Matrix3x3::operator*=(float k)
 //-----------------------------------------------------------------------------
 inline Matrix3x3& Matrix3x3::operator/=(float k)
 {
-	const float inv_k = 1.0 / k;
+	const float inv_k = 1.0f / k;
 
 	x *= inv_k;
 	y *= inv_k;

+ 11 - 11
engine/core/math/matrix4x4.h

@@ -220,21 +220,21 @@ namespace matrix4x4
 	//-----------------------------------------------------------------------------
 	inline void set_perspective_rh(Matrix4x4& m, float fovy, float aspect, float near, float far)
 	{
-		const double top = math::tan(((double)fovy / 360.0 * math::PI)) * (double)near;
-		const double right = top * aspect;
+		const float top = math::tan(fovy / 360.0f * math::PI) * near;
+		const float right = top * aspect;
 
 		m.x = Vector4(near / right, 0, 0, 0);
 		m.y = Vector4(0, near / top, 0, 0);
 		m.z = Vector4(0, 0, (far + near) / (near - far), -1);
-		m.t = Vector4(0, 0, (2.0 * far * near) / (near - far), 0);
+		m.t = Vector4(0, 0, (2.0f * far * near) / (near - far), 0);
 	}
 
 	//-----------------------------------------------------------------------------
 	inline void set_orthographic_rh(Matrix4x4& m, float left, float right, float bottom, float top, float near, float far)
 	{
-		m.x = Vector4(2.0 / (right - left), 0, 0, 0);
-		m.y = Vector4(0, 2.0 / (top - bottom), 0, 0);
-		m.z = Vector4(0, 0, -2.0 / (far - near), 0);
+		m.x = Vector4(2.0f / (right - left), 0, 0, 0);
+		m.y = Vector4(0, 2.0f / (top - bottom), 0, 0);
+		m.z = Vector4(0, 0, -2.0f / (far - near), 0);
 		m.t = Vector4(-((right + left) / (right - left)), -((top + bottom) / (top - bottom)), -((far + near) / (far - near)), 1.0);
 	}
 
@@ -351,7 +351,7 @@ namespace matrix4x4
 		mat.x.z = (+ m.x.y * m06m15_m14m07 - m.y.y * m02m15_m14m03 + m.t.y * m02m07_m06m03);
 		mat.x.w = (+ m.x.y * m06m11_m10m07 - m.y.y * m02m11_m10m03 + m.z.y * m02m07_m06m03);
 
-		const float inv_det = 1.0 / (m.x.x * mat.x.x - m.y.x * mat.x.y + m.z.x * mat.x.z - m.t.x * mat.x.w);
+		const float inv_det = 1.0f / (m.x.x * mat.x.x - m.y.x * mat.x.y + m.z.x * mat.x.z - m.t.x * mat.x.w);
 
 		mat.y.x = (+ m.y.x * m10m15_m14m11 - m.z.x * m06m15_m14m07 + m.t.x * m06m11_m10m07);
 		mat.y.y = (+ m.x.x * m10m15_m14m11 - m.z.x * m02m15_m14m03 + m.t.x * m02m11_m10m03);
@@ -508,9 +508,9 @@ inline Matrix4x4::Matrix4x4(float r1c1, float r2c1, float r3c1, float r4c1,
 
 //-----------------------------------------------------------------------------
 inline Matrix4x4::Matrix4x4(const Quaternion& r, const Vector3& p)
-	: x(1.0 - 2.0 * r.y * r.y - 2.0 * r.z * r.z, 2.0 * r.x * r.y + 2.0 * r.w * r.z, 2.0 * r.x * r.z - 2.0 * r.w * r.y, 0)
-	, y(2.0 * r.x * r.y - 2.0 * r.w * r.z, 1.0 - 2.0 * r.x * r.x - 2.0 * r.z * r.z, 2.0 * r.y * r.z + 2.0 * r.w * r.x, 0)
-	, z(2.0 * r.x * r.z + 2.0 * r.w * r.y, 2.0 * r.y * r.z - 2.0 * r.w * r.x, 1.0 - 2.0 * r.x * r.x - 2.0 * r.y * r.y, 0)
+	: x(1.0f - 2.0f * r.y * r.y - 2.0f * r.z * r.z, 2.0f * r.x * r.y + 2.0f * r.w * r.z, 2.0f * r.x * r.z - 2.0f * r.w * r.y, 0)
+	, y(2.0f * r.x * r.y - 2.0f * r.w * r.z, 1.0f - 2.0f * r.x * r.x - 2.0f * r.z * r.z, 2.0f * r.y * r.z + 2.0f * r.w * r.x, 0)
+	, z(2.0f * r.x * r.z + 2.0f * r.w * r.y, 2.0f * r.y * r.z - 2.0f * r.w * r.x, 1.0f - 2.0f * r.x * r.x - 2.0f * r.y * r.y, 0)
 	, t(p, 1)
 {
 }
@@ -585,7 +585,7 @@ inline Matrix4x4& Matrix4x4::operator*=(float k)
 //-----------------------------------------------------------------------------
 inline Matrix4x4& Matrix4x4::operator/=(float k)
 {
-	const float inv_k = 1.0 / k;
+	const float inv_k = 1.0f / k;
 
 	x *= inv_k;
 	y *= inv_k;

+ 5 - 5
engine/core/math/quaternion.h

@@ -110,7 +110,7 @@ namespace quaternion
 
 	inline Quaternion inverse(const Quaternion& q)
 	{
-		return conjugate(q) * (1.0 / length(q));
+		return conjugate(q) * (1.0f / length(q));
 	}
 
 	inline Quaternion power(const Quaternion& q, float exp)
@@ -159,10 +159,10 @@ inline Quaternion::Quaternion(float nx, float ny, float nz, float nw)
 
 //-----------------------------------------------------------------------------
 inline Quaternion::Quaternion(const Vector3& axis, float angle)
-	: x(axis.x * math::sin(angle * 0.5))
-	, y(axis.y * math::sin(angle * 0.5))
-	, z(axis.z * math::sin(angle * 0.5))
-	, w(math::cos(angle * 0.5))
+	: x(axis.x * math::sin(angle * 0.5f))
+	, y(axis.y * math::sin(angle * 0.5f))
+	, z(axis.z * math::sin(angle * 0.5f))
+	, w(math::cos(angle * 0.5f))
 {
 }
 

+ 1 - 1
engine/core/math/vector2.h

@@ -163,7 +163,7 @@ namespace vector2
 	//-----------------------------------------------------------------------------
 	inline Vector2 normalize(Vector2& a)
 	{
-		float inv_len = 1.0 / length(a);
+		float inv_len = 1.0f / length(a);
 
 		a.x *= inv_len;
 		a.y *= inv_len;

+ 1 - 1
engine/core/math/vector3.h

@@ -179,7 +179,7 @@ namespace vector3
 	//-----------------------------------------------------------------------------
 	inline Vector3 normalize(Vector3& a)
 	{
-		float inv_len = 1.0 / length(a);
+		float inv_len = 1.0f / length(a);
 
 		a.x *= inv_len;
 		a.y *= inv_len;

+ 1 - 1
engine/core/math/vector4.h

@@ -171,7 +171,7 @@ namespace vector4
 	//-----------------------------------------------------------------------------
 	inline Vector4 normalize(Vector4& a)
 	{
-		float inv_len = 1.0 / length(a);
+		float inv_len = 1.0f / length(a);
 
 		a.x *= inv_len;
 		a.y *= inv_len;

+ 7 - 8
engine/core/network/socket.h

@@ -28,9 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "config.h"
 #include "types.h"
-#include "net_address.h"
 #include "assert.h"
-#include "os.h"
+#include "net_address.h"
 
 #if CROWN_PLATFORM_POSIX
 	#include <sys/socket.h>
@@ -40,7 +39,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#include <unistd.h>
 	#include <errno.h>
 #elif CROWN_PLATFORM_WINDOWS
-	//Undefined in WinHeaders.h, but winsock2 ecc need it.
+//Undefined in WinHeaders.h, but winsock2 ecc need it.
 	#ifndef NEAR
 	#define NEAR
 	#endif
@@ -48,7 +47,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#define FAR
 	#endif
 	#include <winsock2.h>
-	#include "win_headers.h"
+	#include <win_headers.h>
 	//Re-undef NEAR and FAR after use
 	#undef NEAR
 	#undef FAR
@@ -229,7 +228,7 @@ struct TCPSocket
 		}
 
 		int wsaerr = WSAGetLastError();
-		if (wsaerr == WSAEWOULDBLOCK))
+		if (wsaerr == WSAEWOULDBLOCK)
 			ar.error = AcceptResult::NO_CONNECTION;
 		else
 			ar.error = AcceptResult::UNKNOWN;
@@ -328,7 +327,7 @@ struct TCPSocket
 
 			buf += read_bytes;
 			to_read -= read_bytes;
-			result.bytes_read += read_bytes;
+			rr.bytes_read += read_bytes;
 		}
 
 		return rr;
@@ -393,7 +392,7 @@ struct TCPSocket
 
 		while (to_send > 0)
 		{
-			ssize_t bytes_wrote = ::send(m_socket, (const char*) buf, to_send, 0);
+			int bytes_wrote = ::send(m_socket, (const char*) buf, to_send, 0);
 
 			if (bytes_wrote == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
 			{
@@ -460,7 +459,7 @@ struct TCPSocket
 		CE_ASSERT(err == 0, "setsockopt: errno = %d", errno);
 #elif CROWN_PLATFORM_WINDOWS
 		int optval = (int) reuse;
-		int err = setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
+		int err = setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*) &optval, sizeof(optval));
 		CE_ASSERT(err == 0, "setsockopt: WSAGetLastError = %d", WSAGetLastError());
 #endif
 	}

+ 16 - 12
engine/core/os.h

@@ -49,6 +49,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#include <unistd.h>
 #elif CROWN_PLATFORM_WINDOWS
 	#include <win_headers.h>
+	#include <io.h>
 #endif
 
 #if CROWN_PLATFORM_ANDROID
@@ -124,7 +125,7 @@ inline bool is_root_path(const char* path)
 	return (path != NULL && string::strlen(path) == 1 && path[0] == PATH_SEPARATOR);
 #elif CROWN_PLATFORM_WINDOWS
 	return (path != NULL && string::strlen(path) == 3 && string::is_alpha(path[0]) &&
-		path[1] == ':' && path[2] == PATH_SEPARATOR;
+		path[1] == ':' && path[2] == PATH_SEPARATOR);
 #endif
 }
 
@@ -135,7 +136,7 @@ inline bool is_absolute_path(const char* path)
 	return (path != NULL && string::strlen(path) >= 1 && path[0] == PATH_SEPARATOR);
 #elif CROWN_PLATFORM_WINDOWS
 	return (path != NULL && string::strlen(path) >= 3 && string::is_alpha(path[0]) &&
-		path[1] == ':' && path[2] == PATH_SEPARATOR;
+		path[1] == ':' && path[2] == PATH_SEPARATOR);
 #endif
 }
 
@@ -144,7 +145,7 @@ inline bool exists(const char* path)
 #if CROWN_PLATFORM_POSIX
 	return access(path, F_OK) != -1;
 #elif CROWN_PLATFORM_WINDOWS
-	#error "impl"
+	return _access(path, 0) != -1;
 #endif
 }
 
@@ -189,12 +190,9 @@ inline void create_file(const char* path)
 	CE_ASSERT(err == 0, "mknod: errno = %d", errno);
 	CE_UNUSED(err);
 #elif CROWN_PLATFORM_WINDOWS
-	HANDLE hFile = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-	if (hFile == INVALID_HANDLE_VALUE)
-		return false;
-
-	CloseHandle(hFile);
-	return true;
+	HANDLE hfile = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+	CE_ASSERT(hfile != INVALID_HANDLE_VALUE, "CreateFile: GetLastError = %d", GetLastError());
+	CloseHandle(hfile);
 #endif
 }
 
@@ -206,7 +204,9 @@ inline void delete_file(const char* path)
 	CE_ASSERT(err == 0, "unlink: errno = %d", errno);
 	CE_UNUSED(err);
 #elif CROWN_PLATFORM_WINDOWS
-	return DeleteFile(path) == TRUE;
+	BOOL err = DeleteFile(path);
+	CE_ASSERT(err != 0, "DeleteFile: GetLastError = %d", GetLastError());
+	CE_UNUSED(err);
 #endif
 }
 
@@ -219,7 +219,9 @@ inline void create_directory(const char* path)
 	CE_ASSERT(err == 0, "mkdir: errno = %d", errno);
 	CE_UNUSED(err);
 #elif CROWN_PLATFORM_WINDOWS
-	return CreateDirectory(path, NULL) == TRUE;
+	BOOL err = CreateDirectory(path, NULL);
+	CE_ASSERT(err != 0, "CreateDirectory: GetLastError = %d", GetLastError());
+	CE_UNUSED(err);
 #endif
 }
 
@@ -231,7 +233,9 @@ inline void delete_directory(const char* path)
 	CE_ASSERT(err == 0, "rmdir: errno = %d", errno);
 	CE_UNUSED(err);
 #elif CROWN_PLATFORM_WINDOWS
-	return RemoveDirectory(path) == TRUE;
+	BOOL err = RemoveDirectory(path);
+	CE_ASSERT(err != 0, "RemoveDirectory: GetLastError = %d", GetLastError());
+	CE_UNUSED(err);
 #endif
 }
 

+ 1 - 1
engine/core/strings/string_utils.h

@@ -230,7 +230,7 @@ inline float parse_float(const char* string)
 }
 
 //-----------------------------------------------------------------------------
-inline float parse_double(const char* string)
+inline double parse_double(const char* string)
 {
 	double val;
 	int ok = sscanf(string, "%lf", &val);

+ 3 - 0
engine/core/thread/mutex.h

@@ -33,6 +33,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 #if CROWN_PLATFORM_POSIX
 	#include <pthread.h>
 #elif CROWN_PLATFORM_WINDOWS
+	#ifndef WIN32_LEAN_AND_MEAN
+	#define WIN32_LEAN_AND_MEAN 1
+	#endif
 	#include <windows.h>
 #endif
 

+ 2 - 3
engine/core/thread/semaphore.h

@@ -103,9 +103,8 @@ struct Semaphore
 		m_count--;
 		m_mutex.unlock();
 #elif CROWN_PLATFORM_WINDOWS
-		DWORD milliseconds = (0 > msecs) ? INFINITE : msecs;
-		DWORD result = WaitForSingleObject(m_handle, milliseconds);
-		CE_ASSERT(result == WAIT_OBJECT_0, "Semaphore can not signal!");
+		DWORD result = WaitForSingleObject(m_handle, INFINITE);
+		CE_ASSERT(result == WAIT_OBJECT_0, "WaitForSingleObject: GetLastError = %d", GetLastError());
 		CE_UNUSED(result);
 #endif
 	}

+ 4 - 5
engine/core/thread/thread.h

@@ -36,7 +36,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #elif CROWN_PLATFORM_WINDOWS
 	#include "win_headers.h"
 	#include <process.h>
-	#include <win_base.h>
 #endif
 
 namespace crown
@@ -94,7 +93,7 @@ struct Thread
 		CE_UNUSED(result);
 #elif CROWN_PLATFORM_WINDOWS
 		m_handle = CreateThread(NULL, stack_size, Thread::thread_proc, this, 0, NULL);
-		CE_ASSERT(m_handle != NULL, "Failed to create the thread '%s'", m_name);
+		CE_ASSERT(m_handle != NULL, "CreateThread: GetLastError = %d", GetLastError());
 #endif
 
 		m_is_running = true;
@@ -112,7 +111,7 @@ struct Thread
 		m_handle = 0;
 #elif CROWN_PLATFORM_WINDOWS
 		WaitForSingleObject(m_handle, INFINITE);
-		GetExitCodeThread(m_handle, &m_exit_code);
+		// GetExitCodeThread(m_handle, &m_exit_code);
 		CloseHandle(m_handle);
 		m_handle = INVALID_HANDLE_VALUE;
 #endif
@@ -141,9 +140,9 @@ private:
 		return (void*)&result;
 	}
 #elif CROWN_PLATFORM_WINDOWS
-	static DWORD WINAPI OsThread::thread_proc(void* arg)
+	static DWORD WINAPI thread_proc(void* arg)
 	{
-		OsThread* thread = (OsThread*)arg;
+		Thread* thread = (Thread*) arg;
 		int32_t result = thread->run();
 		return result;
 	}

+ 0 - 133
engine/crown.h

@@ -1,133 +0,0 @@
-/*
-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
-
-// Core
-#include "assert.h"
-#include "types.h"
-#include "args.h"
-#include "log.h"
-
-// Core/Math
-#include "aabb.h"
-#include "color4.h"
-#include "frustum.h"
-#include "intersection.h"
-#include "math_utils.h"
-#include "matrix3x3.h"
-#include "matrix4x4.h"
-#include "plane.h"
-#include "quaternion.h"
-#include "random.h"
-#include "ray.h"
-#include "sphere.h"
-#include "vector2.h"
-#include "vector3.h"
-#include "vector4.h"
-
-// Core/Containers
-#include "container_types.h"
-#include "event_stream.h"
-#include "hash.h"
-#include "id_array.h"
-#include "id_table.h"
-#include "map.h"
-#include "priority_queue.h"
-#include "queue.h"
-#include "vector.h"
-
-// Core/Strings
-#include "string_utils.h"
-#include "string_stream.h"
-#include "string_utils.h"
-#include "path.h"
-
-// Core/Mem
-#include "memory.h"
-#include "allocator.h"
-#include "temp_allocator.h"
-#include "linear_allocator.h"
-#include "stack_allocator.h"
-#include "proxy_allocator.h"
-#include "pool_allocator.h"
-
-// Core/Filesystem
-#include "disk_file.h"
-#include "file.h"
-#include "filesystem.h"
-#include "null_file.h"
-#include "reader_writer.h"
-
-// Core/Json
-#include "json.h"
-#include "json_parser.h"
-
-// Core/Settings
-#include "int_setting.h"
-#include "float_setting.h"
-#include "string_setting.h"
-
-// Engine
-#include "camera.h"
-#include "device.h"
-#include "console_server.h"
-
-// Engine/Input
-#include "keyboard.h"
-#include "key_code.h"
-#include "mouse.h"
-#include "touch.h"
-
-// Engine/Lua
-#include "lua_stack.h"
-#include "lua_environment.h"
-
-// Engine/Os
-#include "thread.h"
-#include "mutex.h"
-#include "os_file.h"
-#include "os_window.h"
-#include "socket.h"
-
-// Engine/Renderers
-#include "renderer.h"
-#include "render_context.h"
-#include "pixel_format.h"
-#include "vertex_format.h"
-
-// Engine/Resource
-#include "bundle.h"
-#include "resource_loader.h"
-#include "resource_manager.h"
-#include "texture_resource.h"
-#include "mesh_resource.h"
-#include "sound_resource.h"
-#include "material_resource.h"
-#include "font_resource.h"
-
-// Engine/Audio
-#include "sound_world.h"

+ 0 - 13
engine/lua/lua_device.cpp

@@ -56,18 +56,6 @@ static int device_argv(lua_State* L)
 	return 1;
 }
 
-//-----------------------------------------------------------------------------
-static int device_frame_count(lua_State* L)
-{
-	LuaStack stack(L);
-
-	uint64_t frame = device()->frame_count();
-
-	stack.push_uint64(frame);
-
-	return 1;
-}
-
 //-----------------------------------------------------------------------------
 static int device_last_delta_time(lua_State* L)
 {
@@ -203,7 +191,6 @@ static int device_set_fullscreen(lua_State* L)
 void load_device(LuaEnvironment& env)
 {
 	env.load_module_function("Device", "argv",                     device_argv);
-	env.load_module_function("Device", "frame_count",              device_frame_count);
 	env.load_module_function("Device", "last_delta_time",          device_last_delta_time);
 	env.load_module_function("Device", "start",                    device_start);
 	env.load_module_function("Device", "stop",                     device_stop);

+ 1 - 1
engine/lua/lua_environment.cpp

@@ -151,7 +151,7 @@ void LuaEnvironment::call_global(const char* func, uint8_t argc, ...)
 		{
 			case ARGUMENT_FLOAT:
 			{
-				stack.push_float(va_arg(vl, double));
+				stack.push_float(va_arg(vl, float));
 				break;
 			}
 			default:

+ 4 - 16
engine/lua/lua_stack.h

@@ -130,13 +130,13 @@ public:
 	//-----------------------------------------------------------------------------
 	bool is_nil(int32_t index)
 	{
-		return lua_isnil(m_L, index);
+		return lua_isnil(m_L, index) == 1;
 	}
 
 	//-----------------------------------------------------------------------------
 	bool is_number(int32_t index)
 	{
-		return (bool) lua_isnumber(m_L, index);
+		return lua_isnumber(m_L, index) == 1;
 	}
 
 	/// Wraps lua_type.
@@ -169,18 +169,6 @@ public:
 		lua_pushinteger(m_L, value);
 	}
 
-	//-----------------------------------------------------------------------------
-	void push_int64(int64_t value)
-	{
-		lua_pushinteger(m_L, value);
-	}
-
-	//-----------------------------------------------------------------------------
-	void push_uint64(uint64_t value)
-	{
-		lua_pushinteger(m_L, value);
-	}
-
 	//-----------------------------------------------------------------------------
 	void push_float(float value)
 	{
@@ -211,7 +199,7 @@ public:
 	//-----------------------------------------------------------------------------
 	bool get_bool(int32_t index)
 	{
-		return (bool) CHECKBOOLEAN(m_L, index);
+		return CHECKBOOLEAN(m_L, index) == 1;
 	}
 
 	//-----------------------------------------------------------------------------
@@ -223,7 +211,7 @@ public:
 	//-----------------------------------------------------------------------------
 	float get_float(int32_t index)
 	{
-		return CHECKNUMBER(m_L, index);
+		return (float) CHECKNUMBER(m_L, index);
 	}
 
 	//-----------------------------------------------------------------------------

+ 11 - 8
engine/os/win/main.cpp

@@ -30,12 +30,16 @@ OTHER DEALINGS IN THE SOFTWARE.
 #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1)
 #define WM_USER_MOUSE_LOCK          (WM_USER+2)
 
-#include "crown.h"
 #include "os_types.h"
 #include "os_event_queue.h"
-#include "glcontext.h"
+#include "gl_context.h"
 #include "bundle_compiler.h"
-
+#include "device.h"
+#include "thread.h"
+#include "log.h"
+#include "os_window.h"
+#include "args.h"
+#include "json_parser.h"
 #include "os.h"
 
 #define ENTRY_DEFAULT_WIDTH 1024
@@ -50,7 +54,6 @@ extern void set_win_handle_window(HWND hwnd);
 void init()
 {
 	memory::init();
-	os::init_os();
 }
 
 //-----------------------------------------------------------------------------
@@ -206,14 +209,14 @@ public:
 	//-----------------------------------------------------------------------------
 	int32_t	run(int argc, char** argv)
 	{
-		init(argc, argv);
-
 		WSADATA WsaData;
 		int res = WSAStartup(MAKEWORD(2,2), &WsaData);
 		CE_ASSERT(res == 0, "Unable to initialize socket");
 		CE_UNUSED(WsaData);
 		CE_UNUSED(res);
 
+		init(argc, argv);
+
 		HINSTANCE instance = (HINSTANCE)GetModuleHandle(NULL);
 
 		WNDCLASSEX wnd;
@@ -279,7 +282,7 @@ public:
 		m_argc = argc;
 		m_argv = argv;
 
-		OsThread thread("game-loop");
+		Thread thread;
 		thread.start(WindowsDevice::main_loop, this);
 		m_started = true;
 
@@ -811,7 +814,7 @@ public:
 				case '?':
 				default:
 				{
-					os::printf(help_message);
+					printf(help_message);
 					exit(EXIT_FAILURE);
 				}
 			}

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

@@ -30,7 +30,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 	#define WIN32_LEAN_AND_MEAN
 #endif
 
-#include "windows.h"
+#include <windows.h>
 
 #undef NEAR
 #undef FAR

+ 2 - 2
engine/renderers/debug_line.cpp

@@ -73,8 +73,8 @@ void DebugLine::add_sphere(const Color4& color, const Vector3& center, const flo
 
 	for (uint32_t deg = 0; deg < 360; deg += deg_step)
 	{
-		const float rad0 = math::deg_to_rad(deg);
-		const float rad1 = math::deg_to_rad(deg + deg_step);
+		const float rad0 = math::deg_to_rad((float) deg);
+		const float rad1 = math::deg_to_rad((float) deg + deg_step);
 
 		// XZ plane
 		const Vector3 start0(math::cos(rad0) * radius, 0, -math::sin(rad0) * radius);

+ 1 - 1
engine/renderers/sprite.cpp

@@ -165,7 +165,7 @@ void Sprite::update(float dt)
 		}
 	}
 
-	uint32_t frame = m_animation->num_frames * (m_time / m_animation->time);
+	uint32_t frame = (uint32_t) m_animation->num_frames * (m_time / m_animation->time);
 	m_frame = m_resource->get_animation_frame(m_animation, frame);
 }
 

+ 13 - 13
engine/resource/physics_resource.cpp

@@ -223,13 +223,13 @@ void parse_joints(JSONElement e, Array<PhysicsJoint>& joints)
 		pj.actor_1 = actor_1.to_string_id();
 		pj.anchor_0 = Vector3(anchor_0[0].to_float(), anchor_0[1].to_float(), anchor_0[2].to_float());
 		pj.anchor_1 = Vector3(anchor_1[0].to_float(), anchor_1[1].to_float(), anchor_1[2].to_float());
-		pj.restitution = restitution.is_nil() 	? 0.5 : restitution.to_float();
-		pj.spring = spring.is_nil() 			? 100.0 : spring.to_float();
-		pj.damping = damping.is_nil() 			? 0.0 : damping.to_float();
-		pj.distance = distance.is_nil() 		? 1.0 : distance.to_float();
+		pj.restitution = restitution.is_nil() 	? 0.5f : restitution.to_float();
+		pj.spring = spring.is_nil() 			? 100.0f : spring.to_float();
+		pj.damping = damping.is_nil() 			? 0.0f : damping.to_float();
+		pj.distance = distance.is_nil() 		? 1.0f : distance.to_float();
 		pj.breakable = breakable.is_nil() 		? false : breakable.to_bool();
-		pj.break_force = break_force.is_nil() 	? 3000.0 : break_force.to_float();
-		pj.break_torque = break_torque.is_nil() ? 1000.0 : break_torque.to_float();
+		pj.break_force = break_force.is_nil() 	? 3000.0f : break_force.to_float();
+		pj.break_torque = break_torque.is_nil() ? 1000.0f : break_torque.to_float();
 
 		switch (pj.type)
 		{
@@ -245,7 +245,7 @@ void parse_joints(JSONElement e, Array<PhysicsJoint>& joints)
 
 				pj.y_limit_angle = y_limit_angle.is_nil() ? math::HALF_PI : y_limit_angle.to_float();
 				pj.z_limit_angle = z_limit_angle.is_nil() ? math::HALF_PI : z_limit_angle.to_float();
-				pj.contact_dist = contact_dist.is_nil() ? 0.0 : contact_dist.to_float();
+				pj.contact_dist = contact_dist.is_nil() ? 0.0f : contact_dist.to_float();
 
 				break;
 			}
@@ -256,16 +256,16 @@ void parse_joints(JSONElement e, Array<PhysicsJoint>& joints)
 				JSONElement upper_limit = joint.key_or_nil("upper_limit");
 				JSONElement contact_dist = joint.key_or_nil("contact_dist");
 
-				pj.lower_limit = lower_limit.is_nil() ? 0.0 : lower_limit.to_float();
-				pj.upper_limit = upper_limit.is_nil() ? 0.0 : upper_limit.to_float();
-				pj.contact_dist = contact_dist.is_nil() ? 0.0 : contact_dist.to_float();
+				pj.lower_limit = lower_limit.is_nil() ? 0.0f : lower_limit.to_float();
+				pj.upper_limit = upper_limit.is_nil() ? 0.0f : upper_limit.to_float();
+				pj.contact_dist = contact_dist.is_nil() ? 0.0f : contact_dist.to_float();
 
 				break;
 			}
 			case PhysicsJointType::DISTANCE:
 			{
 				JSONElement max_distance = joint.key_or_nil("max_distance");
-				pj.max_distance = max_distance.is_nil() ? 0.0 : max_distance.to_float();
+				pj.max_distance = max_distance.is_nil() ? 0.0f : max_distance.to_float();
 
 				break;
 			}
@@ -447,8 +447,8 @@ namespace physics_config_resource
 
 			// Read actor object
 			PhysicsActor2 pa2;
-			pa2.linear_damping = linear_damping.is_nil() ? 0.0 : linear_damping.to_float();
-			pa2.angular_damping = angular_damping.is_nil() ? 0.05 : angular_damping.to_float();
+			pa2.linear_damping = linear_damping.is_nil() ? 0.0f : linear_damping.to_float();
+			pa2.angular_damping = angular_damping.is_nil() ? 0.05f : angular_damping.to_float();
 			pa2.flags = 0;
 			if (!dynamic.is_nil())
 			{

+ 4 - 4
engine/resource/sprite_resource.cpp

@@ -108,10 +108,10 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 		const float w = fd.region.z / CE_PIXELS_PER_METER;
 		const float h = fd.region.w / CE_PIXELS_PER_METER;
 
-		const float x0 = fd.scale.x * (-w * 0.5) + fd.offset.x;
-		const float y0 = fd.scale.y * (-h * 0.5) + fd.offset.y;
-		const float x1 = fd.scale.x * ( w * 0.5) + fd.offset.x;
-		const float y1 = fd.scale.y * ( h * 0.5) + fd.offset.y;
+		const float x0 = fd.scale.x * (-w * 0.5f) + fd.offset.x;
+		const float y0 = fd.scale.y * (-h * 0.5f) + fd.offset.y;
+		const float x1 = fd.scale.x * ( w * 0.5f) + fd.offset.x;
+		const float y1 = fd.scale.y * ( h * 0.5f) + fd.offset.y;
 
 		array::push_back(vertices, x0); array::push_back(vertices, y0); // position
 		array::push_back(vertices, u0); array::push_back(vertices, v0); // uv

+ 2 - 2
engine/resource/unit_resource.cpp

@@ -193,8 +193,8 @@ void parse_cameras(JSONElement e, Array<UnitCamera>& cameras, const Array<GraphN
 		cn.name = string::murmur2_32(camera_name, string::strlen(camera_name));
 		cn.node = find_node_index(node_name_hash, node_depths);
 		cn.type = projection_name_to_enum(camera_type.c_str());
-		cn.fov = fov.is_nil() ? 16.0 / 9.0 : fov.to_float();
-		cn.near = near.is_nil() ? 0.01 : near.to_float();
+		cn.fov = fov.is_nil() ? 16.0f / 9.0f : fov.to_float();
+		cn.near = near.is_nil() ? 0.01f : near.to_float();
 		cn.far = far.is_nil() ? 1000 : far.to_float();
 
 		array::push_back(cameras, cn);

+ 4 - 4
engine/world/camera.cpp

@@ -208,7 +208,7 @@ Vector3 Camera::screen_to_world(const Vector3& pos)
 				 (2 * pos.z) - 1, 1);
 
 	Vector4 tmp = mvp * ndc;
-	tmp *= 1.0 / tmp.w;
+	tmp *= 1.0f / tmp.w;
 
 	return Vector3(tmp.x, tmp.y, tmp.z);
 }
@@ -223,9 +223,9 @@ Vector3 Camera::world_to_screen(const Vector3& pos)
 
 	Vector3 ndc = (m_projection * world_inv) * pos;
 
-	return Vector3( (m_view_x + m_view_width * (ndc.x + 1.0)) / 2.0,
-					(m_view_y + m_view_height * (ndc.y + 1.0)) / 2.0,
-					(ndc.z + 1.0) / 2.0);
+	return Vector3( (m_view_x + m_view_width * (ndc.x + 1.0f)) / 2.0f,
+					(m_view_y + m_view_height * (ndc.y + 1.0f)) / 2.0f,
+					(ndc.z + 1.0f) / 2.0f);
 }
 
 //-----------------------------------------------------------------------------

+ 17 - 21
premake/premake4.lua

@@ -525,10 +525,6 @@ solution "crown"
 
 			}
 
-			links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
-				"DelayImp",
-			}
-
 			defines {
 				"WIN32",
 				"_WIN32",
@@ -553,23 +549,23 @@ solution "crown"
 			}
 
 			includedirs {
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/common",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/characterkinematic",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/cloth",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/common",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/cooking",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/extensions",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/foundation",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/geometry",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/particles",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/physxprofilesdk",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/physxvisualdebuggersdk",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/pvd",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/pxtask",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/RepX",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/RepXUpgrader",
-				"$(PHYSX_SDK_WINDOWS)/physx/win64/include/vehicle",
+				"$(PHYSX_SDK_WINDOWS)/Include",
+				"$(PHYSX_SDK_WINDOWS)/Include/common",
+				"$(PHYSX_SDK_WINDOWS)/Include/characterkinematic",
+				"$(PHYSX_SDK_WINDOWS)/Include/cloth",
+				"$(PHYSX_SDK_WINDOWS)/Include/common",
+				"$(PHYSX_SDK_WINDOWS)/Include/cooking",
+				"$(PHYSX_SDK_WINDOWS)/Include/extensions",
+				"$(PHYSX_SDK_WINDOWS)/Include/foundation",
+				"$(PHYSX_SDK_WINDOWS)/Include/geometry",
+				"$(PHYSX_SDK_WINDOWS)/Include/particles",
+				"$(PHYSX_SDK_WINDOWS)/Include/physxprofilesdk",
+				"$(PHYSX_SDK_WINDOWS)/Include/physxvisualdebuggersdk",
+				"$(PHYSX_SDK_WINDOWS)/Include/pvd",
+				"$(PHYSX_SDK_WINDOWS)/Include/pxtask",
+				"$(PHYSX_SDK_WINDOWS)/Include/RepX",
+				"$(PHYSX_SDK_WINDOWS)/Include/RepXUpgrader",
+				"$(PHYSX_SDK_WINDOWS)/Include/vehicle",
 				CROWN_THIRD_DIR .. "luajit/src",
 				CROWN_THIRD_DIR .. "opengl",
 				CROWN_THIRD_DIR .. "openal/include",

BIN
third/openal/lib/OpenAL32.dll


BIN
third/openal/lib/OpenAL32.lib