Fix duplicate creation of window (makes fullscreen mode work on OSX)
[numtypysics.git] / OsWin32.cpp
blob6ed972dc99acc6c523d9d45a57d21afbad6d71b5
1 /*
2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
17 #ifdef WIN32
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
23 #include <SDL/SDL_syswm.h>
24 #include <windows.h>
27 class OsWin32 : public Os
29 HICON icon;
30 HWND hwnd;
32 public:
34 OsWin32()
36 HINSTANCE handle = GetModuleHandle(NULL);
37 icon = LoadIcon(handle, MAKEINTRESOURCE(1));
38 SDL_SysWMinfo wminfo;
39 SDL_VERSION(&wminfo.version);
40 if(SDL_GetWMInfo(&wminfo) != 1) {
41 //error wrong SDL version
43 hwnd = wminfo.window;
44 SetClassLong(hwnd, GCL_HICON, (LONG)icon);
47 ~OsWin32()
49 DestroyIcon(icon);
52 virtual bool openBrowser( const char* url )
54 //??
55 return false;
61 Os* Os::get()
63 static OsWin32 os;
64 return &os;
67 const char Os::pathSep = '\\';
71 /**
72 * For Windows, we have to define "WinMain" instead of the
73 * usual "main" in order to get a graphical application without
74 * the console window that normally pops up otherwise
75 **/
76 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
77 LPSTR lpCmdLine, int nCmdShow)
79 //TODO - pass level args here...
80 npmain(0,0);
83 #endif