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 "state_tracker/graw.h"
32 #include "target-helpers/inline_debug_helper.h"
33 #include "target-helpers/inline_sw_helper.h"
37 static LRESULT CALLBACK
38 window_proc(HWND hWnd,
49 return DefWindowProc(hWnd, uMsg, wParam, lParam);
60 graw_create_window_and_screen(int x,
64 enum pipe_format format,
67 struct sw_winsys *winsys = NULL;
68 struct pipe_screen *screen = NULL;
70 UINT style = WS_VISIBLE | WS_TILEDWINDOW;
75 if (format != PIPE_FORMAT_R8G8B8A8_UNORM)
78 winsys = gdi_create_sw_winsys();
82 screen = sw_screen_create(winsys);
86 memset(&wc, 0, sizeof wc);
87 wc.cbSize = sizeof wc;
88 wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
89 wc.lpfnWndProc = window_proc;
90 wc.lpszClassName = "graw-gdi";
91 wc.hInstance = GetModuleHandle(NULL);
92 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
93 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
94 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
97 SetRect(&rect, 0, 0, width, height);
98 AdjustWindowRectEx(&rect, style, FALSE, 0);
100 hWnd = CreateWindowEx(0,
106 rect.right - rect.left,
107 rect.bottom - rect.top,
119 *handle = (void *)hDC;
121 return debug_screen_wrap(screen);
128 screen->destroy(screen);
134 graw_set_display_func(void (* draw)(void))
145 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
146 if (msg.message == WM_QUIT) {
149 TranslateMessage(&msg);
150 DispatchMessage(&msg);