1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
29 #include "gdi/gdi_sw_winsys.h"
30 #include "pipe/p_screen.h"
31 #include "softpipe/sp_public.h"
32 #include "state_tracker/graw.h"
33 #include "sw/sw_public.h"
34 #include "target-helpers/wrap_screen.h"
38 static LRESULT CALLBACK
39 window_proc(HWND hWnd
,
50 return DefWindowProc(hWnd
, uMsg
, wParam
, lParam
);
61 graw_create_window_and_screen(int x
,
65 enum pipe_format format
,
68 struct sw_winsys
*winsys
= NULL
;
69 struct pipe_screen
*screen
= NULL
;
70 WNDCLASSEX wc
= {sizeof(wc
)};
74 if (format
!= PIPE_FORMAT_R8G8B8A8_UNORM
)
77 winsys
= gdi_create_sw_winsys();
81 screen
= softpipe_create_screen(winsys
);
85 wc
.style
= CS_OWNDC
| CS_HREDRAW
| CS_VREDRAW
;
86 wc
.lpfnWndProc
= window_proc
;
87 wc
.lpszClassName
= "graw-gdi";
88 wc
.hInstance
= GetModuleHandle(NULL
);
89 wc
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
90 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
91 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
94 hWnd
= CreateWindowEx(0,
97 WS_VISIBLE
| WS_TILEDWINDOW
,
113 *handle
= (void *)hDC
;
115 return gallium_wrap_screen(screen
);
122 screen
->destroy(screen
);
128 graw_set_display_func(void (* draw
)(void))
139 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
140 if (msg
.message
== WM_QUIT
) {
143 TranslateMessage(&msg
);
144 DispatchMessage(&msg
);