glx_alias_prefer_same_name.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/**
25 * @file glx_gles2.c
26 *
27 * Catches a bug where a GLES2 context using
28 * GLX_EXT_create_context_es2_profile would try to find the symbols in
29 * libGLESv2.so.2 instead of libGL.so.1.
30 */
31
32#include <stdio.h>
33#include <assert.h>
34#include <err.h>
35#include "epoxy/gl.h"
36#include "epoxy/glx.h"
37#include <X11/Xlib.h>
38
39#include "glx_common.h"
40
41static Display *dpy;
42
43static int last_call;
44
45#define CORE_FUNC_VAL 100
46#define EXT_FUNC_VAL 101
47
48void
49override_GL_glBindTexture(GLenum target, GLenum texture);
50void
51override_GL_glBindTextureEXT(GLenum target, GLenum texture);
52
53void
54override_GL_glBindTexture(GLenum target)
55{
56    last_call = CORE_FUNC_VAL;
57}
58
59void
60override_GL_glBindTexture(GLenum target)
61{
62    last_call = EXT_FUNC_VAL;
63}
64
65int
66main(int argc, char **argv)
67{
68    bool pass = true;
69    XVisualInfo *vis;
70    Window win;
71    GLXContext ctx;
72    GLXFBConfig config;
73    int context_attribs[] = {
74        GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
75        GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
76        GLX_CONTEXT_MINOR_VERSION_ARB, 0,
77        0
78    };
79    GLuint shader;
80
81    dpy = get_display_or_skip();
82    make_glx_context_current_or_skip(dpy);
83
84    if (!epoxy_has_gl_extension(dpy, 0, "GLX_EXT_texture_object"))
85        errx(77, "Test requires GLX_EXT_texture_object");
86
87    glBindTexture(GL_TEXTURE_2D, 1);
88    pass = pass && last_call == CORE_VAL;
89    glBindTextureEXT(GL_TEXTURE_2D, 1);
90    pass = pass && last_call == EXT_VAL;
91
92    return pass != true;
93}
94