wglgears: add srgb-mode to usage
[mesa-demos.git] / src / wgl / wglfontbitmaps.c
blobd61195f61094f9af761fd3214a4434fa6859e68a
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, CW_USEDEFAULT, CW_USEDEFAULT,
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 SelectObject(hdc, GetStockObject(SYSTEM_FONT));
95 wglUseFontBitmaps(hdc, 0, 256, 1000);
97 glListBase(1000);
99 glCallLists(12, GL_UNSIGNED_BYTE, "Hello World!");
101 SwapBuffers(hdc);
103 Sleep(1000);
105 wglMakeCurrent(NULL, NULL);
107 wglDeleteContext(hglrc);
109 ReleaseDC(hwnd, hdc);
111 DestroyWindow(hwnd);
113 return 0;