-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCDreamDeviceWin32.cpp
More file actions
103 lines (93 loc) · 3.04 KB
/
CDreamDeviceWin32.cpp
File metadata and controls
103 lines (93 loc) · 3.04 KB
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
/******************************************************************************************************
Dream2d is 2d game engine written by Changer.
Copyright (C) Changer Stdio.
This program is free software;
you can redistribute it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not,
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
******************************************************************************************************/
#ifdef DREAM2D_WIN32
#include <Windows.h>
#include <tchar.h>
#include "CDreamDeviceWin32.h"
#include "CWinGUIDriver.h"
#define WINDOWS_CLASS_NAME _T("DREAM2D")
LRESULT CALLBACK WindowProc(
HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam ) {
PAINTSTRUCT ps;
HDC hdc;
switch(uMsg) {
case WM_CREATE:
break;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
break;
case WM_SIZE:
break;
case WM_CLOSE:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
void CDreamDeviceWin32::InitWin32Device()
{
WNDCLASSEX ws;
int style = WS_CAPTION|WS_SYSMENU;
ZeroMemory(&ws,sizeof(WNDCLASSEX));
ws.cbSize = sizeof(WNDCLASSEX);
ws.style = CS_VREDRAW|CS_HREDRAW;
ws.lpfnWndProc = WindowProc;
ws.cbClsExtra = 0;
ws.cbWndExtra = 0;
ws.hInstance = m_hInstance;
ws.hIcon = LoadIcon(NULL,IDI_APPLICATION);
ws.hCursor = LoadCursor(NULL,IDC_ARROW);
ws.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
ws.lpszClassName = WINDOWS_CLASS_NAME;
RegisterClassEx(&ws);
RECT rect = {0,0,0,0};
rect.right = m_Width;
rect.bottom = m_Height;
AdjustWindowRect(&rect,style,false);
m_hWnd = CreateWindow(WINDOWS_CLASS_NAME,_T("Hello"),style,100,100,rect.right-rect.left,rect.bottom-rect.top,NULL,NULL,m_hInstance,NULL);
ShowWindow(m_hWnd,SW_NORMAL);
UpdateWindow(m_hWnd);
}
s32 CDreamDeviceWin32::run() {
MSG msg = {0};
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
if(msg.message == WM_QUIT)
return 0;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 1;
}
void CDreamDeviceWin32::initDriver(s32 sWidth,s32 sHeight,DRIVER_TYPE driver,COLOR_FORMAT f) {
switch(driver) {
case DRIVER_GUIWIN32:
m_videoDriver = new CWinGUIDriver(m_hWnd,sWidth,sHeight);
break;
case DRIVER_OPENGL:
m_videoDriver = NULL;
break;
case DRIVER_DIRECT9:
m_videoDriver = NULL;
break;
case DRIVER_DDRAW:
m_videoDriver = NULL;
break;
}
}
#endif