From 6e11904c95a197bb52ccb93cb74d20c2c85f5868 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Sun, 26 Jun 2005 10:55:03 -0400 Subject: [PATCH] Changed: Partially abstracted the windows version of OpenArena::Window CreateGLWindow and KillGLWindow are now part of the Window class ResizeGLScene and InitGL are now callbacks --- include/main.h | 6 +++--- include/mygl.h | 4 +--- include/window.h | 43 +++++++++++++++++++++++++++++++++++++++++-- oa.vcproj | 3 +++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/include/main.h b/include/main.h index 816155d..c848df2 100644 --- a/include/main.h +++ b/include/main.h @@ -43,8 +43,8 @@ static float currentTime; void InitControls(); // Sets up player controls int InitGL(); // All setup for OpenGL goes here -GLvoid ReSizeGLScene(GLsizei width, GLsizei height); // Resize and initialize the GL window -GLvoid KillGLWindow(GLvoid); //Properly kill the window -bool CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag); +void ReSizeGLScene(GLsizei width, GLsizei height); // Resize and initialize the GL window + + #endif diff --git a/include/mygl.h b/include/mygl.h index 70f2384..45566c6 100644 --- a/include/mygl.h +++ b/include/mygl.h @@ -18,9 +18,7 @@ using namespace std; #ifdef WIN32 -//These three are windows specific -static HDC hDC=NULL; // Private GDI device context -static HGLRC hRC=NULL; // Permanent rendering context +//These this is windows specific static HINSTANCE hInstance; // Application instance #endif extern OpenArena::Window g_Screen; diff --git a/include/window.h b/include/window.h index a3cf9fd..81c992d 100644 --- a/include/window.h +++ b/include/window.h @@ -3,17 +3,26 @@ #include "screen.h" #ifdef __linux +#include #include #include #include #endif +#ifdef WIN32 +#include +#include +#include +#endif namespace OpenArena { + typedef void (*ResizeFunc)(GLsizei width, GLsizei height); + typedef int (*InitFunc)(); + class Window: public SCREEN { public: - #ifdef __linux +#ifdef __linux Display* display; int screen; ::Window window; @@ -22,8 +31,38 @@ namespace OpenArena bool doubleBuffered; XF86VidModeModeInfo vidMode; int x, y; - #endif + private: +#endif +#ifdef WIN32 + HGLRC glContext; + HWND window; + private: + HDC deviceContext; + HINSTANCE instance; +#endif + + + public: + Window(); + ~Window(); + void Close(); + bool Open(); + bool Open(string title, int width, int height, int bits, bool fullscreenflag); //make that string a const char* after this works + void SetOnInit(InitFunc function); + void SetOnResize(ResizeFunc function); + void SwapBuffers(); + + private: + ResizeFunc OnResize; + InitFunc OnInit; }; + + void DefaultResize(GLsizei width, GLsizei height); + int DefaultInit(); }; +#ifdef WIN32 +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +#endif + #endif diff --git a/oa.vcproj b/oa.vcproj index e62a11e..9f3233b 100644 --- a/oa.vcproj +++ b/oa.vcproj @@ -183,6 +183,9 @@ + +