PolyWinCore.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #include "PolyWinCore.h"
  20. using namespace Polycode;
  21. long getThreadID() {
  22. return 0;
  23. }
  24. extern Win32Core *core;
  25. void ClientResize(HWND hWnd, int nWidth, int nHeight)
  26. {
  27. RECT rcClient, rcWindow;
  28. POINT ptDiff;
  29. GetClientRect(hWnd, &rcClient);
  30. GetWindowRect(hWnd, &rcWindow);
  31. ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
  32. ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
  33. MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
  34. }
  35. Win32Core::Win32Core(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen, int aaLevel,int frameRate) : Core(xRes, yRes, fullScreen,aaLevel,frameRate) {
  36. hWnd = *((HWND*)view->windowData);
  37. core = this;
  38. initKeymap();
  39. hDC = NULL;
  40. hRC = NULL;
  41. PixelFormat = 0;
  42. lastMouseX = -1;
  43. lastMouseY = -1;
  44. eventMutex = createMutex();
  45. isFullScreen = fullScreen;
  46. renderer = new OpenGLRenderer();
  47. services->setRenderer(renderer);
  48. setVideoMode(xRes, yRes, fullScreen, aaLevel);
  49. // WSADATA WsaData;
  50. /// if(WSAStartup( MAKEWORD(2,2), &WsaData ) != NO_ERROR ){
  51. // Logger::log("Error initializing sockets!\n");
  52. // }
  53. ((OpenGLRenderer*)renderer)->initOSSpecific();
  54. CoreServices::getInstance()->installModule(new GLSLShaderModule());
  55. }
  56. Win32Core::~Win32Core() {
  57. destroyContext();
  58. }
  59. void Win32Core::enableMouse(bool newval) {
  60. ShowCursor(newval);
  61. }
  62. unsigned int Win32Core::getTicks() {
  63. return GetTickCount();
  64. }
  65. bool Win32Core::Update() {
  66. if(!running)
  67. return false;
  68. checkEvents();
  69. renderer->BeginRender();
  70. updateCore();
  71. renderer->EndRender();
  72. SwapBuffers(hDC);
  73. doSleep();
  74. return running;
  75. }
  76. void Win32Core::setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) {
  77. if(fullScreen) {
  78. SetWindowLong(hWnd, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP);
  79. ShowWindow(hWnd, SW_SHOW);
  80. DEVMODE dmScreenSettings; // Device Mode
  81. memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
  82. dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
  83. dmScreenSettings.dmPelsWidth = xRes; // Selected Screen Width
  84. dmScreenSettings.dmPelsHeight = yRes; // Selected Screen Height
  85. dmScreenSettings.dmBitsPerPel = 32; // Selected Bits Per Pixel
  86. dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
  87. ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN);
  88. SetWindowPos(hWnd, NULL, 0, 0, xRes, yRes, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
  89. } else {
  90. if(isFullScreen) {
  91. ChangeDisplaySettings(NULL,0);
  92. }
  93. // SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPED|WS_SYSMENU);
  94. // ShowWindow(hWnd, SW_SHOW);
  95. ClientResize(hWnd, xRes, yRes);
  96. }
  97. isFullScreen = fullScreen;
  98. initContext(false, 0);
  99. if(aaLevel > 0) {
  100. initMultisample(aaLevel);
  101. }
  102. renderer->Resize(xRes, yRes);
  103. }
  104. void Win32Core::initContext(bool usePixelFormat, unsigned int pixelFormat) {
  105. destroyContext();
  106. memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)) ;
  107. pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
  108. pfd.nVersion = 1 ;
  109. pfd.dwFlags = PFD_DOUBLEBUFFER |
  110. PFD_SUPPORT_OPENGL |
  111. PFD_DRAW_TO_WINDOW ;
  112. pfd.iPixelType = PFD_TYPE_RGBA ;
  113. pfd.cColorBits = 24;
  114. pfd.cDepthBits = 16;
  115. pfd.cAccumBlueBits = 8;
  116. pfd.cAccumRedBits = 8;
  117. pfd.cAccumGreenBits = 8;
  118. pfd.cAccumAlphaBits = 8;
  119. pfd.cAccumBits = 24;
  120. pfd.iLayerType = PFD_MAIN_PLANE ;
  121. if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
  122. {
  123. Logger::log("Can't Create A GL Device Context.\n");
  124. return; // Return FALSE
  125. }
  126. if(usePixelFormat) {
  127. PixelFormat = pixelFormat;
  128. } else {
  129. if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
  130. {
  131. Logger::log("Can't Find A Suitable PixelFormat.\n");
  132. return; // Return FALSE
  133. }
  134. }
  135. Logger::log("Setting format: %d\n", PixelFormat);
  136. if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
  137. {
  138. Logger::log("Can't Set The PixelFormat: %d.\n", PixelFormat);
  139. return; // Return FALSE
  140. }
  141. if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
  142. {
  143. Logger::log("Can't Create A GL Rendering Context.\n");
  144. return; // Return FALSE
  145. }
  146. if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
  147. {
  148. Logger::log("Can't Activate The GL Rendering Context.\n");
  149. return; // Return FALSE
  150. }
  151. }
  152. void Win32Core::destroyContext() {
  153. if(hDC == NULL)
  154. return;
  155. wglMakeCurrent (hDC, 0);
  156. wglDeleteContext(hRC);
  157. hRC = 0;
  158. ReleaseDC (hWnd, hDC);
  159. hDC = 0;
  160. if (isFullScreen)
  161. ChangeDisplaySettings (NULL,0);
  162. }
  163. void Win32Core::initMultisample(int numSamples) {
  164. PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB =
  165. (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
  166. if (!wglChoosePixelFormatARB) {
  167. Logger::log("Multisampling not supported!\n");
  168. return;
  169. }
  170. int pixelFormat;
  171. bool valid;
  172. UINT numFormats;
  173. float fAttributes[] = {0,0};
  174. int iAttributes[] = { WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
  175. WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
  176. WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
  177. WGL_COLOR_BITS_ARB,24,
  178. WGL_DEPTH_BITS_ARB,24,
  179. WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
  180. WGL_ACCUM_GREEN_BITS_ARB, 8,
  181. WGL_ACCUM_RED_BITS_ARB, 8,
  182. WGL_ACCUM_BLUE_BITS_ARB, 8,
  183. WGL_ACCUM_ALPHA_BITS_ARB, 8,
  184. WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
  185. WGL_SAMPLES_ARB, numSamples ,
  186. 0,0};
  187. if(!wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats)) {
  188. Logger::log("Invalid pixel format chosen\n");
  189. return;
  190. }
  191. // initContext(true, pixelFormat);
  192. glEnable(GL_MULTISAMPLE_ARB);
  193. }
  194. void Win32Core::initKeymap() {
  195. for (int i=0; i<1024; ++i )
  196. keyMap[i] = KEY_UNKNOWN;
  197. keyMap[VK_BACK] = KEY_BACKSPACE;
  198. keyMap[VK_TAB] = KEY_TAB;
  199. keyMap[VK_CLEAR] = KEY_CLEAR;
  200. keyMap[VK_RETURN] = KEY_RETURN;
  201. keyMap[VK_PAUSE] = KEY_PAUSE;
  202. keyMap[VK_ESCAPE] = KEY_ESCAPE;
  203. keyMap[VK_SPACE] = KEY_SPACE;
  204. keyMap[VK_APOSTROPHE] = KEY_QUOTE;
  205. keyMap[VK_COMMA] = KEY_COMMA;
  206. keyMap[VK_MINUS] = KEY_MINUS;
  207. keyMap[VK_PERIOD] = KEY_PERIOD;
  208. keyMap[VK_SLASH] = KEY_SLASH;
  209. keyMap[VK_0] = KEY_0;
  210. keyMap[VK_1] = KEY_1;
  211. keyMap[VK_2] = KEY_2;
  212. keyMap[VK_3] = KEY_3;
  213. keyMap[VK_4] = KEY_4;
  214. keyMap[VK_5] = KEY_5;
  215. keyMap[VK_6] = KEY_6;
  216. keyMap[VK_7] = KEY_7;
  217. keyMap[VK_8] = KEY_8;
  218. keyMap[VK_9] = KEY_9;
  219. keyMap[VK_SEMICOLON] = KEY_SEMICOLON;
  220. keyMap[VK_EQUALS] = KEY_EQUALS;
  221. keyMap[VK_LBRACKET] = KEY_LEFTBRACKET;
  222. keyMap[VK_BACKSLASH] = KEY_BACKSLASH;
  223. keyMap[VK_OEM_102] = KEY_LESS;
  224. keyMap[VK_RBRACKET] = KEY_RIGHTBRACKET;
  225. keyMap[VK_GRAVE] = KEY_BACKQUOTE;
  226. keyMap[VK_BACKTICK] = KEY_BACKQUOTE;
  227. keyMap[VK_A] = KEY_a;
  228. keyMap[VK_B] = KEY_b;
  229. keyMap[VK_C] = KEY_c;
  230. keyMap[VK_D] = KEY_d;
  231. keyMap[VK_E] = KEY_e;
  232. keyMap[VK_F] = KEY_f;
  233. keyMap[VK_G] = KEY_g;
  234. keyMap[VK_H] = KEY_h;
  235. keyMap[VK_I] = KEY_i;
  236. keyMap[VK_J] = KEY_j;
  237. keyMap[VK_K] = KEY_k;
  238. keyMap[VK_L] = KEY_l;
  239. keyMap[VK_M] = KEY_m;
  240. keyMap[VK_N] = KEY_n;
  241. keyMap[VK_O] = KEY_o;
  242. keyMap[VK_P] = KEY_p;
  243. keyMap[VK_Q] = KEY_q;
  244. keyMap[VK_R] = KEY_r;
  245. keyMap[VK_S] = KEY_s;
  246. keyMap[VK_T] = KEY_t;
  247. keyMap[VK_U] = KEY_u;
  248. keyMap[VK_V] = KEY_v;
  249. keyMap[VK_W] = KEY_w;
  250. keyMap[VK_X] = KEY_x;
  251. keyMap[VK_Y] = KEY_y;
  252. keyMap[VK_Z] = KEY_z;
  253. keyMap[VK_DELETE] = KEY_DELETE;
  254. keyMap[VK_NUMPAD0] = KEY_KP0;
  255. keyMap[VK_NUMPAD1] = KEY_KP1;
  256. keyMap[VK_NUMPAD2] = KEY_KP2;
  257. keyMap[VK_NUMPAD3] = KEY_KP3;
  258. keyMap[VK_NUMPAD4] = KEY_KP4;
  259. keyMap[VK_NUMPAD5] = KEY_KP5;
  260. keyMap[VK_NUMPAD6] = KEY_KP6;
  261. keyMap[VK_NUMPAD7] = KEY_KP7;
  262. keyMap[VK_NUMPAD8] = KEY_KP8;
  263. keyMap[VK_NUMPAD9] = KEY_KP9;
  264. keyMap[VK_DECIMAL] = KEY_KP_PERIOD;
  265. keyMap[VK_DIVIDE] = KEY_KP_DIVIDE;
  266. keyMap[VK_MULTIPLY] = KEY_KP_MULTIPLY;
  267. keyMap[VK_SUBTRACT] = KEY_KP_MINUS;
  268. keyMap[VK_ADD] = KEY_KP_PLUS;
  269. keyMap[VK_UP] = KEY_UP;
  270. keyMap[VK_DOWN] = KEY_DOWN;
  271. keyMap[VK_RIGHT] = KEY_RIGHT;
  272. keyMap[VK_LEFT] = KEY_LEFT;
  273. keyMap[VK_INSERT] = KEY_INSERT;
  274. keyMap[VK_HOME] = KEY_HOME;
  275. keyMap[VK_END] = KEY_END;
  276. keyMap[VK_PRIOR] = KEY_PAGEUP;
  277. keyMap[VK_NEXT] = KEY_PAGEDOWN;
  278. keyMap[VK_F1] = KEY_F1;
  279. keyMap[VK_F2] = KEY_F2;
  280. keyMap[VK_F3] = KEY_F3;
  281. keyMap[VK_F4] = KEY_F4;
  282. keyMap[VK_F5] = KEY_F5;
  283. keyMap[VK_F6] = KEY_F6;
  284. keyMap[VK_F7] = KEY_F7;
  285. keyMap[VK_F8] = KEY_F8;
  286. keyMap[VK_F9] = KEY_F9;
  287. keyMap[VK_F10] = KEY_F10;
  288. keyMap[VK_F11] = KEY_F11;
  289. keyMap[VK_F12] = KEY_F12;
  290. keyMap[VK_F13] = KEY_F13;
  291. keyMap[VK_F14] = KEY_F14;
  292. keyMap[VK_F15] = KEY_F15;
  293. keyMap[VK_NUMLOCK] = KEY_NUMLOCK;
  294. keyMap[VK_CAPITAL] = KEY_CAPSLOCK;
  295. keyMap[VK_SCROLL] = KEY_SCROLLOCK;
  296. keyMap[VK_RSHIFT] = KEY_RSHIFT;
  297. keyMap[VK_LSHIFT] = KEY_LSHIFT;
  298. keyMap[VK_RCONTROL] = KEY_RCTRL;
  299. keyMap[VK_LCONTROL] = KEY_LCTRL;
  300. keyMap[VK_RMENU] = KEY_RALT;
  301. keyMap[VK_LMENU] = KEY_LALT;
  302. keyMap[VK_RWIN] = KEY_RSUPER;
  303. keyMap[VK_LWIN] = KEY_LSUPER;
  304. keyMap[VK_HELP] = KEY_HELP;
  305. keyMap[VK_SNAPSHOT] = KEY_PRINT;
  306. keyMap[VK_CANCEL] = KEY_BREAK;
  307. keyMap[VK_APPS] = KEY_MENU;
  308. }
  309. PolyKEY Win32Core::mapKey(LPARAM lParam, WPARAM wParam) {
  310. switch (wParam) {
  311. case VK_CONTROL:
  312. if ( lParam&EXTENDED_KEYMASK )
  313. wParam = VK_RCONTROL;
  314. else
  315. wParam = VK_LCONTROL;
  316. break;
  317. case 33:
  318. if ( lParam&EXTENDED_KEYMASK )
  319. wParam = VK_RMENU;
  320. else
  321. wParam = VK_LMENU;
  322. break;
  323. }
  324. return keyMap[(unsigned int)wParam];
  325. }
  326. void Win32Core::handleKeyDown(LPARAM lParam, WPARAM wParam) {
  327. lockMutex(eventMutex);
  328. Win32Event newEvent;
  329. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  330. newEvent.eventCode = InputEvent::EVENT_KEYDOWN;
  331. newEvent.keyCode = mapKey(lParam, wParam);
  332. newEvent.unicodeChar = ' ';
  333. win32Events.push_back(newEvent);
  334. unlockMutex(eventMutex);
  335. }
  336. void Win32Core::handleKeyUp(LPARAM lParam, WPARAM wParam) {
  337. lockMutex(eventMutex);
  338. Win32Event newEvent;
  339. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  340. newEvent.eventCode = InputEvent::EVENT_KEYUP;
  341. newEvent.keyCode = mapKey(lParam, wParam);
  342. newEvent.unicodeChar = ' ';
  343. win32Events.push_back(newEvent);
  344. unlockMutex(eventMutex);
  345. }
  346. void Win32Core::handleMouseMove(LPARAM lParam, WPARAM wParam) {
  347. lockMutex(eventMutex);
  348. Win32Event newEvent;
  349. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  350. newEvent.eventCode = InputEvent::EVENT_MOUSEMOVE;
  351. newEvent.mouseX = GET_X_LPARAM(lParam);
  352. newEvent.mouseY = GET_Y_LPARAM(lParam);
  353. win32Events.push_back(newEvent);
  354. unlockMutex(eventMutex);
  355. }
  356. void Win32Core::handleMouseWheel(LPARAM lParam, WPARAM wParam) {
  357. lockMutex(eventMutex);
  358. Win32Event newEvent;
  359. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  360. newEvent.mouseX = GET_X_LPARAM(lParam);
  361. newEvent.mouseY = GET_Y_LPARAM(lParam);
  362. int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
  363. if(zDelta < 0)
  364. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_DOWN;
  365. else
  366. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_UP;
  367. win32Events.push_back(newEvent);
  368. unlockMutex(eventMutex);
  369. }
  370. void Win32Core::handleMouseDown(int mouseCode,LPARAM lParam, WPARAM wParam) {
  371. lockMutex(eventMutex);
  372. Win32Event newEvent;
  373. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  374. newEvent.mouseX = GET_X_LPARAM(lParam);
  375. newEvent.mouseY = GET_Y_LPARAM(lParam);
  376. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  377. newEvent.mouseButton = mouseCode;
  378. win32Events.push_back(newEvent);
  379. unlockMutex(eventMutex);
  380. }
  381. void Win32Core::handleMouseUp(int mouseCode,LPARAM lParam, WPARAM wParam) {
  382. lockMutex(eventMutex);
  383. Win32Event newEvent;
  384. newEvent.eventGroup = Win32Event::INPUT_EVENT;
  385. newEvent.mouseX = GET_X_LPARAM(lParam);
  386. newEvent.mouseY = GET_Y_LPARAM(lParam);
  387. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  388. newEvent.mouseButton = mouseCode;
  389. win32Events.push_back(newEvent);
  390. unlockMutex(eventMutex);
  391. }
  392. void Win32Core::checkEvents() {
  393. lockMutex(eventMutex);
  394. Win32Event event;
  395. for(int i=0; i < win32Events.size(); i++) {
  396. event = win32Events[i];
  397. switch(event.eventGroup) {
  398. case Win32Event::INPUT_EVENT:
  399. switch(event.eventCode) {
  400. case InputEvent::EVENT_MOUSEMOVE:
  401. input->setDeltaPosition(event.mouseX - lastMouseX , event.mouseY - lastMouseY);
  402. lastMouseX = event.mouseX;
  403. lastMouseY = event.mouseY;
  404. input->setMousePosition(event.mouseX, event.mouseY, getTicks());
  405. break;
  406. case InputEvent::EVENT_MOUSEDOWN:
  407. input->setMouseButtonState(event.mouseButton, true, getTicks());
  408. break;
  409. case InputEvent::EVENT_MOUSEUP:
  410. input->setMouseButtonState(event.mouseButton, false, getTicks());
  411. break;
  412. case InputEvent::EVENT_KEYDOWN:
  413. input->setKeyState(event.keyCode, (char)event.unicodeChar, true, getTicks());
  414. break;
  415. case InputEvent::EVENT_KEYUP:
  416. input->setKeyState(event.keyCode, (char)event.unicodeChar, false, getTicks());
  417. break;
  418. }
  419. break;
  420. }
  421. }
  422. win32Events.clear();
  423. unlockMutex(eventMutex);
  424. }
  425. DWORD WINAPI Win32LaunchThread(LPVOID data) {
  426. Threaded *threaded = (Threaded*)data;
  427. threaded->runThread();
  428. return 1;
  429. }
  430. void Win32Core::createThread(Threaded *target) {
  431. DWORD dwGenericThread;
  432. HANDLE handle = CreateThread(NULL,0,Win32LaunchThread,target,0,&dwGenericThread);
  433. }
  434. void Win32Core::lockMutex(CoreMutex *mutex) {
  435. WaitForSingleObject(((Win32Mutex*)mutex)->winMutex,INFINITE);
  436. }
  437. void Win32Core::unlockMutex(CoreMutex *mutex) {
  438. ReleaseMutex(((Win32Mutex*)mutex)->winMutex);
  439. }
  440. void Win32Core::platformSleep(int msecs) {
  441. Sleep(msecs);
  442. }
  443. CoreMutex *Win32Core::createMutex() {
  444. Win32Mutex *newMutex = new Win32Mutex();
  445. newMutex->winMutex = CreateMutex( NULL, FALSE, NULL);
  446. return newMutex;
  447. }
  448. vector<Polycode::Rectangle> Win32Core::getVideoModes() {
  449. vector<Polycode::Rectangle> retVector;
  450. return retVector;
  451. }