1 /* $Id: getprocaddress.c,v 1.6 2002/11/08 15:35:46 brianp Exp $ */
4 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Test that glXGetProcAddress works.
28 #define GLX_GLXEXT_PROTOTYPES
31 #include <X11/Xutil.h>
40 test_ActiveTextureARB(void *func
)
42 PFNGLACTIVETEXTUREARBPROC activeTexture
= (PFNGLACTIVETEXTUREARBPROC
) func
;
45 (*activeTexture
)(GL_TEXTURE1_ARB
);
46 glGetIntegerv(GL_ACTIVE_TEXTURE_ARB
, &t
);
47 pass
= (t
== GL_TEXTURE1_ARB
);
48 (*activeTexture
)(GL_TEXTURE0_ARB
); /* restore default */
54 test_SecondaryColor3fEXT(void *func
)
56 PFNGLSECONDARYCOLOR3FEXTPROC secColor3f
= (PFNGLSECONDARYCOLOR3FEXTPROC
) func
;
59 (*secColor3f
)(1.0, 1.0, 0.0);
60 glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT
, color
);
61 pass
= (color
[0] == 1.0 && color
[1] == 1.0 && color
[2] == 0.0);
62 (*secColor3f
)(0.0, 0.0, 0.0); /* restore default */
68 test_ActiveStencilFaceEXT(void *func
)
70 PFNGLACTIVESTENCILFACEEXTPROC activeFace
= (PFNGLACTIVESTENCILFACEEXTPROC
) func
;
73 (*activeFace
)(GL_BACK
);
74 glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT
, &face
);
75 pass
= (face
== GL_BACK
);
76 (*activeFace
)(GL_FRONT
); /* restore default */
84 * The following header file is auto-generated with Python. The Python
85 * script looks in this file for functions named "test_*" as seen above.
87 #include "getproclist.h"
92 extension_supported(const char *haystack
, const char *needle
)
94 if (strstr(haystack
, needle
))
102 check_functions( const char *extensions
)
104 struct name_test_pair
*entry
;
105 int failures
= 0, passes
= 0;
106 int totalFail
= 0, totalPass
= 0;
109 for (entry
= functions
; entry
->name
; entry
++) {
110 if (entry
->name
[0] == '-') {
111 if (entry
->name
[1] == '1') {
115 /* check if the named extension is available */
116 doTests
= extension_supported(extensions
, entry
->name
+1);
119 printf("Testing %s functions\n", entry
->name
+ 1);
120 totalFail
+= failures
;
126 void *funcPtr
= (void *) glXGetProcAddressARB((const GLubyte
*) entry
->name
);
130 printf(" Validating %s:", entry
->name
);
131 b
= (*entry
->test
)(funcPtr
);
137 printf(" FAIL!!!\n");
146 printf(" glXGetProcAddress(%s) failed!\n", entry
->name
);
151 if (doTests
&& (!(entry
+1)->name
|| (entry
+1)->name
[0] == '-')) {
153 printf(" %d failed.\n", failures
);
156 printf(" %d passed.\n", passes
);
160 totalFail
+= failures
;
163 printf("-----------------------------\n");
164 printf("Total: %d pass %d fail\n", totalPass
, totalFail
);
170 print_screen_info(Display
*dpy
, int scrnum
, Bool allowDirect
)
173 int attribSingle
[] = {
179 int attribDouble
[] = {
187 XSetWindowAttributes attr
;
191 XVisualInfo
*visinfo
;
192 int width
= 100, height
= 100;
194 root
= RootWindow(dpy
, scrnum
);
196 visinfo
= glXChooseVisual(dpy
, scrnum
, attribSingle
);
198 visinfo
= glXChooseVisual(dpy
, scrnum
, attribDouble
);
200 fprintf(stderr
, "Error: couldn't find RGB GLX visual\n");
205 attr
.background_pixel
= 0;
206 attr
.border_pixel
= 0;
207 attr
.colormap
= XCreateColormap(dpy
, root
, visinfo
->visual
, AllocNone
);
208 attr
.event_mask
= StructureNotifyMask
| ExposureMask
;
209 mask
= CWBackPixel
| CWBorderPixel
| CWColormap
| CWEventMask
;
210 win
= XCreateWindow(dpy
, root
, 0, 0, width
, height
,
211 0, visinfo
->depth
, InputOutput
,
212 visinfo
->visual
, mask
, &attr
);
214 ctx
= glXCreateContext( dpy
, visinfo
, NULL
, allowDirect
);
216 fprintf(stderr
, "Error: glXCreateContext failed\n");
217 XDestroyWindow(dpy
, win
);
221 if (glXMakeCurrent(dpy
, win
, ctx
)) {
222 check_functions( (const char *) glGetString(GL_EXTENSIONS
) );
225 fprintf(stderr
, "Error: glXMakeCurrent failed\n");
228 glXDestroyContext(dpy
, ctx
);
229 XDestroyWindow(dpy
, win
);
234 main(int argc
, char *argv
[])
236 char *displayName
= NULL
;
239 dpy
= XOpenDisplay(displayName
);
241 fprintf(stderr
, "Error: unable to open display %s\n", displayName
);
245 print_screen_info(dpy
, 0, GL_TRUE
);