-
Notifications
You must be signed in to change notification settings - Fork 1
/
window.c
80 lines (66 loc) · 1.92 KB
/
window.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* This proprietary software may be used only as
* authorised by a licensing agreement from ARM Limited
* (C) COPYRIGHT 2009 - 2011 ARM Limited
* ALL RIGHTS RESERVED
* The entire notice above must be reproduced on all authorised
* copies and copies may only be made to the extent permitted
* by a licensing agreement from ARM Limited.
*/
/*
* window.c
* Platform-specific window setup.
*/
#include "window.h"
/*
* create_window(): Set up Windows specific bits.
*
* uiWidth: Width of window to create.
* uiHeight: Height of window to create.
*
* Returns: Device specific window handle.
*/
HWND create_window(int uiWidth, int uiHeight) {
WNDCLASS wc;
RECT wRect;
HWND sWindow;
HINSTANCE hInstance;
wRect.left = 0L;
wRect.right = (long)uiWidth;
wRect.top = 0L;
wRect.bottom = (long)uiHeight;
hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)process_window;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OGLES";
RegisterClass(&wc);
AdjustWindowRectEx(&wRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
sWindow = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, "OGLES", "main", WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, uiWidth, uiHeight, NULL, NULL, hInstance, NULL);
ShowWindow(sWindow, SW_SHOW);
SetForegroundWindow(sWindow);
SetFocus(sWindow);
return sWindow;
}
/*
* process_window(): This function handles Windows callbacks.
*/
LRESULT CALLBACK process_window(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) {
switch(uiMsg) {
case WM_CLOSE:
PostQuitMessage(0);
return 0;
case WM_ACTIVATE:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SIZE:
return 0;
}
return DefWindowProc(hWnd, uiMsg, wParam, lParam);
}