| 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 |
#include "qe3.h" |
| 26 |
|
| 27 |
static HDC s_hdcZ; |
| 28 |
static HGLRC s_hglrcZ; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
LONG WINAPI WZ_WndProc ( |
| 36 |
HWND hWnd, |
| 37 |
UINT uMsg, |
| 38 |
WPARAM wParam, |
| 39 |
LPARAM lParam) |
| 40 |
{ |
| 41 |
int fwKeys, xPos, yPos; |
| 42 |
RECT rect; |
| 43 |
|
| 44 |
GetClientRect(hWnd, &rect); |
| 45 |
|
| 46 |
switch (uMsg) |
| 47 |
{ |
| 48 |
|
| 49 |
case WM_DESTROY: |
| 50 |
QEW_StopGL( hWnd, s_hglrcZ, s_hdcZ ); |
| 51 |
return 0; |
| 52 |
|
| 53 |
case WM_CREATE: |
| 54 |
s_hdcZ = GetDC(hWnd); |
| 55 |
QEW_SetupPixelFormat( s_hdcZ, false); |
| 56 |
if ( ( s_hglrcZ = wglCreateContext( s_hdcZ ) ) == 0 ) |
| 57 |
Error( "wglCreateContext in WZ_WndProc failed" ); |
| 58 |
|
| 59 |
if (!wglMakeCurrent( s_hdcZ, s_hglrcZ )) |
| 60 |
Error ("wglMakeCurrent in WZ_WndProc failed"); |
| 61 |
|
| 62 |
if (!wglShareLists( g_qeglobals.d_hglrcBase, s_hglrcZ ) ) |
| 63 |
Error( "wglShareLists in WZ_WndProc failed" ); |
| 64 |
return 0; |
| 65 |
|
| 66 |
case WM_PAINT: |
| 67 |
{ |
| 68 |
PAINTSTRUCT ps; |
| 69 |
|
| 70 |
BeginPaint(hWnd, &ps); |
| 71 |
|
| 72 |
if ( !wglMakeCurrent( s_hdcZ, s_hglrcZ ) ) |
| 73 |
Error ("wglMakeCurrent failed"); |
| 74 |
QE_CheckOpenGLForErrors(); |
| 75 |
|
| 76 |
Z_Draw (); |
| 77 |
SwapBuffers(s_hdcZ); |
| 78 |
|
| 79 |
EndPaint(hWnd, &ps); |
| 80 |
} |
| 81 |
return 0; |
| 82 |
|
| 83 |
|
| 84 |
case WM_KEYDOWN: |
| 85 |
QE_KeyDown (wParam); |
| 86 |
return 0; |
| 87 |
|
| 88 |
case WM_MBUTTONDOWN: |
| 89 |
case WM_RBUTTONDOWN: |
| 90 |
case WM_LBUTTONDOWN: |
| 91 |
if (GetTopWindow(g_qeglobals.d_hwndMain) != hWnd) |
| 92 |
BringWindowToTop(hWnd); |
| 93 |
|
| 94 |
SetFocus( g_qeglobals.d_hwndZ ); |
| 95 |
SetCapture( g_qeglobals.d_hwndZ ); |
| 96 |
fwKeys = wParam; |
| 97 |
xPos = (short)LOWORD(lParam); |
| 98 |
yPos = (short)HIWORD(lParam); |
| 99 |
yPos = (int)rect.bottom - 1 - yPos; |
| 100 |
Z_MouseDown (xPos, yPos, fwKeys); |
| 101 |
return 0; |
| 102 |
|
| 103 |
case WM_MBUTTONUP: |
| 104 |
case WM_RBUTTONUP: |
| 105 |
case WM_LBUTTONUP: |
| 106 |
fwKeys = wParam; |
| 107 |
xPos = (short)LOWORD(lParam); |
| 108 |
yPos = (short)HIWORD(lParam); |
| 109 |
yPos = (int)rect.bottom - 1 - yPos; |
| 110 |
Z_MouseUp (xPos, yPos, fwKeys); |
| 111 |
if (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON))) |
| 112 |
ReleaseCapture (); |
| 113 |
return 0; |
| 114 |
|
| 115 |
case WM_GETMINMAXINFO: |
| 116 |
{ |
| 117 |
MINMAXINFO *pmmi = (LPMINMAXINFO) lParam; |
| 118 |
|
| 119 |
pmmi->ptMinTrackSize.x = ZWIN_WIDTH; |
| 120 |
return 0; |
| 121 |
} |
| 122 |
|
| 123 |
case WM_MOUSEMOVE: |
| 124 |
fwKeys = wParam; |
| 125 |
xPos = (short)LOWORD(lParam); |
| 126 |
yPos = (short)HIWORD(lParam); |
| 127 |
yPos = (int)rect.bottom - 1 - yPos; |
| 128 |
Z_MouseMoved (xPos, yPos, fwKeys); |
| 129 |
return 0; |
| 130 |
|
| 131 |
case WM_SIZE: |
| 132 |
z.width = rect.right; |
| 133 |
z.height = rect.bottom; |
| 134 |
InvalidateRect( g_qeglobals.d_hwndZ, NULL, false); |
| 135 |
return 0; |
| 136 |
|
| 137 |
case WM_NCCALCSIZE: |
| 138 |
DefWindowProc (hWnd, uMsg, wParam, lParam); |
| 139 |
return WVR_REDRAW; |
| 140 |
|
| 141 |
case WM_KILLFOCUS: |
| 142 |
case WM_SETFOCUS: |
| 143 |
SendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 ); |
| 144 |
return 0; |
| 145 |
|
| 146 |
case WM_CLOSE: |
| 147 |
|
| 148 |
DestroyWindow (hWnd); |
| 149 |
return 0; |
| 150 |
} |
| 151 |
|
| 152 |
return DefWindowProc (hWnd, uMsg, wParam, lParam); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
void WZ_Create (HINSTANCE hInstance) |
| 162 |
{ |
| 163 |
WNDCLASS wc; |
| 164 |
|
| 165 |
|
| 166 |
memset (&wc, 0, sizeof(wc)); |
| 167 |
|
| 168 |
wc.style = 0; |
| 169 |
wc.lpfnWndProc = (WNDPROC)WZ_WndProc; |
| 170 |
wc.cbClsExtra = 0; |
| 171 |
wc.cbWndExtra = 0; |
| 172 |
wc.hInstance = hInstance; |
| 173 |
wc.hIcon = 0; |
| 174 |
wc.hCursor = LoadCursor (NULL,IDC_ARROW); |
| 175 |
wc.hbrBackground = NULL; |
| 176 |
wc.lpszMenuName = NULL; |
| 177 |
wc.lpszClassName = Z_WINDOW_CLASS; |
| 178 |
|
| 179 |
if (!RegisterClass (&wc) ) |
| 180 |
Error ("WCam_Register: failed"); |
| 181 |
|
| 182 |
g_qeglobals.d_hwndZ = CreateWindow (Z_WINDOW_CLASS , |
| 183 |
"Z", |
| 184 |
QE3_STYLE, |
| 185 |
0,20,ZWIN_WIDTH,screen_height-38, |
| 186 |
g_qeglobals.d_hwndMain, |
| 187 |
0, |
| 188 |
hInstance, |
| 189 |
NULL); |
| 190 |
if (!g_qeglobals.d_hwndZ) |
| 191 |
Error ("Couldn't create zwindow"); |
| 192 |
|
| 193 |
LoadWindowState(g_qeglobals.d_hwndZ, "zwindow"); |
| 194 |
ShowWindow (g_qeglobals.d_hwndZ, SW_SHOWDEFAULT); |
| 195 |
} |