xref: /aosp_15_r20/external/libepoxy/test/wgl_usefontbitmaps.c (revision 706d0b42ae4182339789e08d473a0b312ecdc60f)
1 /*
2  * Copyright © 2013 Intel Corporation
3  *
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:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #include <stdio.h>
25 
26 #include "wgl_common.h"
27 #include <epoxy/gl.h>
28 
29 static int
test_function(HDC hdc)30 test_function(HDC hdc)
31 {
32     bool pass = true;
33     HGLRC ctx;
34     GLuint dlist[2] = {100, 101};
35     const char *string = "some string";
36 
37     ctx = wglCreateContext(hdc);
38     if (!ctx) {
39         fputs("Failed to create wgl context\n", stderr);
40         return 1;
41     }
42     if (!wglMakeCurrent(hdc, ctx)) {
43         fputs("Failed to make context current\n", stderr);
44         return 1;
45     }
46 
47     /* First, use the #ifdeffed variant of the function */
48     wglUseFontBitmaps(hdc, 0, 255, dlist[0]);
49     glListBase(dlist[1]);
50     glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);
51 
52     /* Now, use the specific version, manually. */
53 #ifdef UNICODE
54     wglUseFontBitmapsW(hdc, 0, 255, dlist[0]);
55 #else
56     wglUseFontBitmapsA(hdc, 0, 255, dlist[0]);
57 #endif
58     glListBase(dlist[1]);
59     glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);
60 
61     wglMakeCurrent(NULL, NULL);
62     wglDeleteContext(ctx);
63 
64     return !pass;
65 }
66 
67 int
main(int argc,char ** argv)68 main(int argc, char **argv)
69 {
70     make_window_and_test(test_function);
71 
72     /* UNREACHED */
73     return 1;
74 }
75