Browse Source

Adding some windows bits

Panagiotis Christopoulos Charitos 11 years ago
parent
commit
dbb582213f
5 changed files with 26 additions and 2 deletions
  1. 2 0
      src/CMakeLists.txt
  2. 3 0
      src/gl/GlState.cpp
  3. 1 1
      src/resource/Extension.cpp
  4. 12 0
      src/util/Memory.cpp
  5. 8 1
      src/util/System.cpp

+ 2 - 0
src/CMakeLists.txt

@@ -20,6 +20,8 @@ elseif(ANDROID)
 	set(_SYS GLESv3 EGL log android)
 	include_directories("${ANDROID_NDK}/sources/android/native_app_glue")
 	set(_SYS_SRC "${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")
+elseif(WINDOWS)
+	set(_SYS GL ankiglew)
 else()
 	message(FATAL_ERROR "Unhandled case")
 endif()

+ 3 - 0
src/gl/GlState.cpp

@@ -41,6 +41,9 @@ static const GlDbg gldbgseverity[] = {
 	{GL_DEBUG_SEVERITY_HIGH, "GL_DEBUG_SEVERITY_HIGH"}};
 
 //==============================================================================
+#if ANKI_OS == ANKI_OS_WINDOWS
+__stdcall 
+#endif
 void oglMessagesCallback(GLenum source,
 	GLenum type, GLuint id, GLenum severity, GLsizei length,
 	const char* message, GLvoid* userParam)

+ 1 - 1
src/resource/Extension.cpp

@@ -5,7 +5,7 @@
 
 #include "anki/resource/Extension.h"
 #include "anki/util/Exception.h"
-#include <dlfcn.h>
+//#include <dlfcn.h>
 
 namespace anki {
 

+ 12 - 0
src/util/Memory.cpp

@@ -55,6 +55,16 @@ void* mallocAligned(PtrSize size, PtrSize alignmentBytes) throw()
 		return nullptr;
 	}
 #	endif
+#elif ANKI_OS == ANKI_OS_WINDOWS
+	void* out = _aligned_malloc(size, alignmentBytes);
+
+	if(out)
+	{
+		// Make sure it's aligned
+		ANKI_ASSERT(isAligned(alignmentBytes, out));
+	}
+
+	return out;
 #else
 #	error "Unimplemented"
 #endif
@@ -65,6 +75,8 @@ void freeAligned(void* ptr) throw()
 {
 #if ANKI_POSIX
 	::free(ptr);
+#elif ANKI_OS == ANKI_OS_WINDOWS
+	_aligned_free(ptr);
 #else
 #	error "Unimplemented"
 #endif

+ 8 - 1
src/util/System.cpp

@@ -5,10 +5,13 @@
 
 #include "anki/util/System.h"
 #include "anki/Config.h"
+#include <cstdio>
 
 #if ANKI_POSIX
 #	include <unistd.h>
 #	include <signal.h>
+#elif ANKI_OS == ANKI_OS_WINDOWS
+#	include "Windows.h"
 #else
 #	error "Unimplemented"
 #endif
@@ -25,6 +28,10 @@ U32 getCpuCoresCount()
 {
 #if ANKI_POSIX
 	return sysconf(_SC_NPROCESSORS_ONLN);
+#elif ANKI_OS == ANKI_OS_WINDOWS
+	SYSTEM_INFO sysinfo;
+	GetSystemInfo(&sysinfo);
+	return sysinfo.dwNumberOfProcessors;
 #else
 #	error "Unimplemented"
 #endif
@@ -43,7 +50,7 @@ void printBacktrace()
 	// print out all the frames to stderr
 	backtrace_symbols_fd(array, size, 2);	
 #else
-	// No nothing
+	printf("TODO\n");
 #endif
 }