glx_beginend.c revision e52adb7b
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#include <assert.h> 26#include "epoxy/gl.h" 27#include "epoxy/glx.h" 28#include <X11/Xlib.h> 29 30#include "glx_common.h" 31 32static Display *dpy; 33static bool has_argb2101010; 34 35static bool 36test_with_epoxy(void) 37{ 38 glBegin(GL_TRIANGLES); 39 { 40 /* Hit a base entrypoint that won't call gl_version() */ 41 glVertex2f(0, 0); 42 43 /* Hit an entrypoint that will call probably call gl_version() */ 44 glMultiTexCoord4f(GL_TEXTURE0, 0.0, 0.0, 0.0, 0.0); 45 46 /* Hit an entrypoint that will probably call 47 * epoxy_conservative_has_extension(); 48 */ 49 if (has_argb2101010) { 50 glTexCoordP4ui(GL_UNSIGNED_INT_2_10_10_10_REV, 0); 51 } 52 } 53 glEnd(); 54 55 /* No error should have been generated in the process. */ 56 return glGetError() == 0; 57} 58 59 60 61#undef glBegin 62#undef glEnd 63extern void glBegin(GLenum primtype); 64extern void glEnd(void); 65 66static bool 67test_without_epoxy(void) 68{ 69 glBegin(GL_TRIANGLES); 70 { 71 /* Hit a base entrypoint that won't call gl_version() */ 72 glVertex4f(0, 0, 0, 0); 73 74 /* Hit an entrypoint that will call probably call gl_version() */ 75 glMultiTexCoord3f(GL_TEXTURE0, 0.0, 0.0, 0.0); 76 77 /* Hit an entrypoint that will probably call 78 * epoxy_conservative_has_extension(); 79 */ 80 if (has_argb2101010) { 81 glTexCoordP3ui(GL_UNSIGNED_INT_2_10_10_10_REV, 0); 82 } 83 } 84 glEnd(); 85 86 /* We can't make any assertions about error presence this time 87 * around. This test is just trying to catch segfaults. 88 */ 89 return true; 90} 91 92int 93main(int argc, char **argv) 94{ 95 bool pass = true; 96 97 dpy = get_display_or_skip(); 98 make_glx_context_current_or_skip(dpy); 99 100 has_argb2101010 = 101 epoxy_has_gl_extension("GL_ARB_vertex_type_2_10_10_10_rev"); 102 103 pass = pass && test_with_epoxy(); 104 pass = pass && test_without_epoxy(); 105 106 return pass != true; 107} 108