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
, 512, 512,
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
);
94 hFont
= CreateFont(72, // Height Of Font
96 0, // Angle Of Escapement
97 0, // Orientation Angle
98 FW_NORMAL
, // Font Weight
102 ANSI_CHARSET
, // Character Set Identifier
103 OUT_TT_PRECIS
, // Output Precision
104 CLIP_DEFAULT_PRECIS
, // Clipping Precision
105 ANTIALIASED_QUALITY
, // Output Quality
106 FF_DONTCARE
|DEFAULT_PITCH
, // Family And Pitch
107 "Arial"); // Font Name
112 SelectObject(hdc
, hFont
);
114 GLYPHMETRICSFLOAT agmf
[256];
115 wglUseFontOutlinesA(hdc
, 0, 256, 1000, 0.0f
, 1.0f
, WGL_FONT_POLYGONS
, agmf
);
117 glShadeModel(GL_SMOOTH
);
120 glEnable(GL_CULL_FACE
);
123 glEnable(GL_LIGHTING
);
124 glEnable(GL_COLOR_MATERIAL
);
125 glColor3f(1.0f
, 0.5, 0.0);
127 glTranslatef(-0.8f
, -0.0f
, -1.0f
);
128 glScalef(0.25f
, 0.25f
, 0.25f
);
132 glCallLists(12, GL_UNSIGNED_BYTE
, "Hello World!");
138 wglMakeCurrent(NULL
, NULL
);
140 wglDeleteContext(hglrc
);
142 ReleaseDC(hwnd
, hdc
);