-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWin32.cpp
109 lines (96 loc) · 2.55 KB
/
Win32.cpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***********************************************
* $author: javery
* $date : 13 Nov 01
* $descp : Win32 OS interface
* $path : C:\Program Files\Microsoft Visual Studio\MyProjects\KaosDemoEngine\Win32.cpp
* $ver : 0.0.0
***********************************************/
#include "win32.h"
#include "opengl.h"
#include <windows.h>
/*
*******************************************
* W32_WndProc
* Handles messages sent to and generated by the
* applicaitons main window.
*******************************************
*/
LRESULT CALLBACK SYS_W32_WndProc( HWND hWnd , UINT uMsg , WPARAM wParam , LPARAM lParam )
{
HDC hDC;
PAINTSTRUCT painter;
switch( uMsg )
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
case WM_QUIT:
{
PostQuitMessage(0);
return 0;
}
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
}
case WM_PAINT:
{
hDC = BeginPaint( hWnd , &painter );
EndPaint( hWnd , &painter );
break;
}
case WM_SIZE:
{
SYS_OGL_ResizeContext( LOWORD( lParam ) , HIWORD( lParam ) );
break;
}
}
return DefWindowProc( hWnd , uMsg , wParam , lParam );
}
/*
*******************************************
* SYS_W32_RegisterClass
* Registers the passed class
*******************************************
*/
void SYS_W32_RegisterClass( pWndStruct pWS )
{
pWS->wndClass.cbClsExtra = 0;
pWS->wndClass.cbWndExtra = 0;
pWS->wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
pWS->wndClass.hCursor = LoadCursor( NULL , IDC_ARROW );
pWS->wndClass.hIcon = LoadIcon( NULL , IDI_APPLICATION );
pWS->wndClass.hInstance = pWS->hInstance;
pWS->wndClass.lpfnWndProc = SYS_W32_WndProc;
pWS->wndClass.lpszClassName = "Kaos Demo engine ( v 0.0.0 ) test app";
pWS->wndClass.lpszMenuName = NULL;
pWS->wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
RegisterClass( &pWS->wndClass );
}
/*
*******************************************
* SYS_W32_CreateWindow
* Creates the application's parent window.
*******************************************
*/
void SYS_W32_CreateWindow( pWndStruct pWS )
{
pWS->hWnd = CreateWindowEx(/*WS_EX_TOPMOST*/pWS->wExStyle,
pWS->wndClass.lpszClassName,
"Kaos Demo Engine (v0.0.0) Test Application",
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | pWS->wStyle,
CW_USEDEFAULT,
CW_USEDEFAULT,
pWS->xDimension,
pWS->yDimension,
NULL,
NULL,
pWS->hInstance,
NULL );
ShowWindow( pWS->hWnd , SW_SHOW );
SetForegroundWindow( pWS->hWnd );
SetFocus( pWS->hWnd );
}