Jelajahi Sumber

lot of bug fixes in win port

mikymod 12 tahun lalu
induk
melakukan
417f58bbf7
3 mengubah file dengan 19 tambahan dan 16 penghapusan
  1. 16 12
      src/os/win/OsWindow.cpp
  2. 0 4
      src/os/win/OsWindow.h
  3. 3 0
      src/renderers/gl/wgl/GLContext.cpp

+ 16 - 12
src/os/win/OsWindow.cpp

@@ -24,8 +24,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "OsWindow.h"
+#include "GLContext.h"
 #include "Assert.h"
 #include "Keyboard.h"
+#include "StringUtils.h"
 #include "Log.h"
 
 namespace crown
@@ -89,11 +91,15 @@ static Key translate_key(int32_t winKey)
 }
 
 //-----------------------------------------------------------------------------
-OsWindow::OsWindow(uint32_t width, uint32_t height)
+OsWindow::OsWindow(uint32_t width, uint32_t height) :
+	m_window_handle(NULL),
+	m_x(0),
+	m_y(0),
+	m_fullscreen(false)
 {
-	CE_ASSERT(!width && !height, "Width and height must differ from 0.");
+	CE_ASSERT(width != 0 || height != 0, "Width and height must differ from 0.");
 
-	strcpy(m_window_name, "CrownWindowClass");
+	string::strcpy(m_window_name, "CrownWindowClass");
 	WNDCLASSEX wcex;
 	wcex.cbSize = sizeof(WNDCLASSEX);
 	wcex.style = CS_OWNDC;
@@ -101,15 +107,17 @@ OsWindow::OsWindow(uint32_t width, uint32_t height)
 	wcex.cbClsExtra = 0;
 	wcex.cbWndExtra = 0;
 	wcex.hInstance = GetModuleHandle(NULL);
+    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
 	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
 	wcex.lpszMenuName = NULL;
 	wcex.lpszClassName = m_window_name;
+    wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
 
-	bool registered = RegisterClassEx(&wcex);
-	CE_ASSERT(registered, "Unable to register a Window Class.");
+	uint32_t registered = RegisterClassEx(&wcex);
+	CE_ASSERT(registered != 0, "Unable to register a Window Class.");
 
 	m_window_handle = CreateWindowEx(0, m_window_name, "", WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
-
 	CE_ASSERT(m_window_handle != NULL, "Unable to create a Window.");
 	
 	//Save the WGLRenderWindow pointer to the window's user data
@@ -146,6 +154,8 @@ OsWindow::OsWindow(uint32_t width, uint32_t height)
 	
 	bool pf_set = SetPixelFormat(device_context, pixel_format, &pfd);
 	CE_ASSERT(pf_set, "Unable to set the pixel format, altough it seems to be supported.");
+
+	set_win_handle_window(m_window_handle);
 }
 
 //-----------------------------------------------------------------------------
@@ -413,12 +423,6 @@ void OsWindow::frame()
 		}
 	}
 
-}
-
-void OsWindow::set_window(uint32_t width, uint32_t height)
-{
-
-
 }
 
 } // namespace crown

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

@@ -62,10 +62,6 @@ public:
 
 	void			frame();
 
-private:
-
-	void			set_window(uint32_t width, uint32_t height);
-
 private:
 
 	HWND			m_window_handle;

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

@@ -42,11 +42,14 @@ void set_win_handle_window(HWND win)
 GLContext::GLContext() :
 	m_win_context(NULL)
 {
+	
 }
 
 //-----------------------------------------------------------------------------
 void GLContext::create_context()
 {
+	m_win_context = wglCreateContext(GetDC(s_handle_window));
+
 	wglMakeCurrent(GetDC(s_handle_window), m_win_context);
 
 	CE_ASSERT(m_win_context != NULL, "Unable to create a rendering context.");