wglgears: add srgb-mode to usage
[mesa-demos.git] / src / wgl / wglfontoutlines.c
blobbfc24b4b956f6db4b62f3b37d5f46f6350aa87c5
1 /*
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.
22 #include <windows.h>
23 #include <stdlib.h>
24 #include <GL/gl.h>
26 int
27 main(int argc, char *argv[])
29 WNDCLASS wc;
30 HWND hwnd;
31 HDC hdc;
32 PIXELFORMATDESCRIPTOR pfd;
33 int iPixelFormat;
34 HGLRC hglrc;
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)) {
45 abort();
48 hwnd = CreateWindowEx(0,
49 wc.lpszClassName,
50 "wglfont",
51 WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TILEDWINDOW,
52 CW_USEDEFAULT, CW_USEDEFAULT, 512, 512,
53 NULL, NULL,
54 wc.hInstance,
55 NULL);
56 if (!hwnd) {
57 abort();
60 hdc = GetDC(hwnd);
61 if (!hdc) {
62 abort();
65 ZeroMemory(&pfd, sizeof pfd);
66 pfd.nSize = sizeof pfd;
67 pfd.nVersion = 1;
68 pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
69 pfd.iPixelType = PFD_TYPE_RGBA;
70 pfd.cColorBits = 24;
71 pfd.cDepthBits = 0;
72 pfd.iLayerType = PFD_MAIN_PLANE;
74 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
75 if (!iPixelFormat) {
76 abort();
79 if (!SetPixelFormat(hdc, iPixelFormat, &pfd)) {
80 abort();
83 hglrc = wglCreateContext(hdc);
84 if (!hglrc) {
85 abort();
88 wglMakeCurrent(hdc, hglrc);
90 glClearColor(0.0, 0.0, 0.0, 1.0);
91 glClear(GL_COLOR_BUFFER_BIT);
93 HFONT hFont;
94 hFont = CreateFont(72, // Height Of Font
95 0, // Width Of Font
96 0, // Angle Of Escapement
97 0, // Orientation Angle
98 FW_NORMAL, // Font Weight
99 FALSE, // Italic
100 FALSE, // Underline
101 FALSE, // Strikeout
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
108 if (!hFont) {
109 abort();
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);
119 glCullFace(GL_BACK);
120 glEnable(GL_CULL_FACE);
122 glEnable(GL_LIGHT0);
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);
130 glListBase(1000);
132 glCallLists(12, GL_UNSIGNED_BYTE, "Hello World!");
134 SwapBuffers(hdc);
136 Sleep(1000);
138 wglMakeCurrent(NULL, NULL);
140 wglDeleteContext(hglrc);
142 ReleaseDC(hwnd, hdc);
144 DestroyWindow(hwnd);
146 return 0;