2 * Copyright (C) 2016, VMware, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 main(int argc
, char *argv
[])
32 PIXELFORMATDESCRIPTOR pfd
;
36 ZeroMemory(&wc
, sizeof wc
);
37 wc
.style
= CS_OWNDC
| CS_HREDRAW
| CS_VREDRAW
;
38 wc
.lpfnWndProc
= DefWindowProc
;
39 wc
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
40 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
41 wc
.hbrBackground
= (HBRUSH
) (COLOR_BTNFACE
+ 1);
42 wc
.lpszClassName
= "wglfont";
44 if (!RegisterClass(&wc
)) {
48 hwnd
= CreateWindowEx(0,
51 WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| WS_TILEDWINDOW
,
52 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
65 ZeroMemory(&pfd
, sizeof pfd
);
66 pfd
.nSize
= sizeof pfd
;
68 pfd
.dwFlags
= PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
;
69 pfd
.iPixelType
= PFD_TYPE_RGBA
;
72 pfd
.iLayerType
= PFD_MAIN_PLANE
;
74 iPixelFormat
= ChoosePixelFormat(hdc
, &pfd
);
79 if (!SetPixelFormat(hdc
, iPixelFormat
, &pfd
)) {
83 hglrc
= wglCreateContext(hdc
);
88 wglMakeCurrent(hdc
, hglrc
);
90 glClearColor(0.0, 0.0, 0.0, 1.0);
91 glClear(GL_COLOR_BUFFER_BIT
);
93 SelectObject(hdc
, GetStockObject(SYSTEM_FONT
));
95 wglUseFontBitmaps(hdc
, 0, 256, 1000);
99 glCallLists(12, GL_UNSIGNED_BYTE
, "Hello World!");
105 wglMakeCurrent(NULL
, NULL
);
107 wglDeleteContext(hglrc
);
109 ReleaseDC(hwnd
, hdc
);