mikymod 12 лет назад
Родитель
Сommit
f64adc67da

+ 0 - 0
src/os/win/Cond.cpp


+ 0 - 0
src/os/win/Cond.h


+ 0 - 0
src/os/win/Mutex.cpp


+ 0 - 0
src/os/win/Mutex.h


+ 0 - 0
src/os/win/OsFile.cpp


+ 0 - 0
src/os/win/OsFile.h


+ 121 - 0
src/os/win/OsWindow.cpp

@@ -0,0 +1,121 @@
+/*
+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.
+*/
+
+#include "OsWindow.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+OsWindow::OsWindow(uint32_t width, uint32_t height)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+OsWindow::~OsWindow()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::show()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::hide()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_size(uint32_t& width, uint32_t& height)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_position(uint32_t& x, uint32_t& y)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::resize(uint32_t width, uint32_t height)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::move(uint32_t x, uint32_t y)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::show_cursor()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::hide_cursor()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_cursor_xy(int32_t& x, int32_t& y)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_cursor_xy(int32_t x, int32_t y)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+char* OsWindow::title()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_title(const char* title)
+{
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::frame()
+{
+
+}
+
+} // namespace crown

+ 72 - 0
src/os/win/OsWindow.h

@@ -0,0 +1,72 @@
+/*
+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
+
+#include <windows.h>
+
+#include "Types.h"
+
+namespace crown
+{
+
+class OsWindow
+{
+public:
+
+					OsWindow(uint32_t width, uint32_t height);
+					~OsWindow();
+
+	void			show();
+	void			hide();
+
+	void			get_size(uint32_t& width, uint32_t& height);
+	void			get_position(uint32_t& x, uint32_t& y);
+
+	void			resize(uint32_t width, uint32_t height);
+	void			move(uint32_t x, uint32_t y);
+
+	void			show_cursor();
+	void			hide_cursor();
+
+	void			get_cursor_xy(int32_t& x, int32_t& y);
+	void			set_cursor_xy(int32_t x, int32_t y);
+
+	char*			title();
+	void			set_title(const char* title);
+
+	void			frame();
+
+private:
+
+	HWND			m_window_handle;
+
+	uint32_t		m_x;
+	uint32_t		m_y;
+	uint32_t		m_width;
+	uint32_t		m_height;
+};
+
+} // namespace crown

+ 0 - 0
src/os/win/WinTCPSocket.cpp → src/os/win/TCPSocket.cpp


+ 0 - 0
src/os/win/TCPSocket.h


+ 0 - 0
src/os/win/Thread.cpp


+ 0 - 0
src/os/win/Thread.h


+ 0 - 0
src/os/win/WinUDPSocket.cpp → src/os/win/UDPSocket.cpp


+ 0 - 0
src/os/win/UDPSocket.h


+ 80 - 1
src/os/win/WinOS.cpp

@@ -34,7 +34,10 @@ namespace crown
 namespace os
 {
 
-static timespec base_time;
+// FIXME: timespec does not exists in win
+// static timespec base_time;
+	LARGE_INTEGER* frequency;
+	LARGE_INTEGER* base_time;
 
 //-----------------------------------------------------------------------------
 void printf(const char* string, ...)
@@ -84,6 +87,26 @@ void log_info(const char* string, va_list arg)
 	printf("\n");
 }
 
+//-----------------------------------------------------------------------------
+bool is_root_path(const char* path)
+{
+	CE_ASSERT(path != NULL, "Path must be != NULL");
+
+	// MUST BE IMPLEMENTED
+
+	return false;
+}
+
+//-----------------------------------------------------------------------------
+bool is_absolute_path(const char* path)
+{
+	CE_ASSERT(path != NULL, "Path must be != NULL");
+
+	// MUST BE IMPLEMENTED
+
+	return false;
+}
+
 //-----------------------------------------------------------------------------
 bool exists(const char* path)
 {
@@ -177,5 +200,61 @@ bool ls(const char* path, List<Str>& fileList)
 	return false; 
 }
 
+//-----------------------------------------------------------------------------
+void init_os()
+{
+	QueryPerformanceFrequency(frequency);
+
+	CE_ASSERT(frequency > 0, "Hardware does not support high resolution performance counter.\n");
+	
+	QueryPerformanceCounter(base_time);
+}
+
+//-----------------------------------------------------------------------------
+uint64_t milliseconds()
+{
+	LARGE_INTEGER* current_time;
+
+	QueryPerformanceCounter(current_time);
+
+	return (uint64_t) (*current_time - *base_time) / (*frequency / 1000);
+}
+
+//-----------------------------------------------------------------------------
+uint64_t microseconds()
+{
+	LARGE_INTEGER* current_time;
+
+	QueryPerformanceCounter(current_time);
+
+	return (uint64_t) (*current_time - *base_time) / (*frequency / 1000000);
+}
+
+//-----------------------------------------------------------------------------
+void* open_library(const char* path)
+{
+	HMODULE library = LoadLibrary(_T(path));
+
+	CE_ASSERT(library  != NULL, "Unable to load library '%s' with error: %s\n", path, GetLastError());
+
+	return library;
+}
+
+//-----------------------------------------------------------------------------
+void close_library(void* library)
+{
+	BOOL freed = FreeLibrary(library);
+
+	CE_ASSERT(freed,  "Failed to close library\n");
+}
+
+//-----------------------------------------------------------------------------
+void* lookup_symbol(void* library, const char* name)
+{
+	FARPROC symbol = GetProcAddress(library, name);
+
+	return symbol;
+}
+
 } // namespace crown
 

+ 0 - 0
src/os/win/main.cpp


+ 61 - 0
src/renderers/gl/wgl/GLContext.cpp

@@ -0,0 +1,61 @@
+/*
+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.
+*/
+
+#include "GLContext.h"
+#include "Assert.h"
+#include "Types.h"
+
+namespace crown
+{
+
+static HWND s_handle_window = 0;
+
+//-----------------------------------------------------------------------------
+void set_win_handle_window(HWND win)
+{
+	s_handle_window = win;
+}
+
+//-----------------------------------------------------------------------------
+GLContext::GLContext()
+{
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::create_context()
+{
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::destroy_context()
+{
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::swap_buffers()
+{
+}
+
+} // namespace crown

+ 50 - 0
src/renderers/gl/wgl/GLContext.h

@@ -0,0 +1,50 @@
+/*
+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
+
+#include <windows.h>
+
+namespace crown
+{
+
+void set_win_handle_window(HWND win);
+
+class GLContext
+{
+public:
+					GLContext();
+
+	void			create_context();
+	void			destroy_context();
+
+	void			swap_buffers();
+
+private:
+
+};
+
+} // namespace crown