glx-dlopen-gpa
glx-dlopen-gpaa
egl-opengl-link-call
+egl-opengl-link-gpa
+egl-opengl-dlopen-dlsym
+egl-opengl-dlopen-gpa
test_programs += $(dir)/glx-dlopen-gpa
test_programs += $(dir)/glx-dlopen-gpaa
test_programs += $(dir)/egl-opengl-link-call
+test_programs += $(dir)/egl-opengl-link-gpa
+test_programs += $(dir)/egl-opengl-dlopen-dlsym
+test_programs += $(dir)/egl-opengl-dlopen-gpa
endif
glx_link_call_srcs = \
$(dir)/egl-opengl-link-call: $(egl_opengl_link_call_modules)
$(call quiet,$(FIPS_LINKER) $(CFLAGS)) $^ $(EGL_LDFLAGS) $(GL_LDFLAGS) $(X11_LDFLAGS) -o $@
+egl_opengl_link_gpa_srcs = \
+ $(dir)/egl-opengl-link-gpa.c \
+ $(dir)/util-x11.c
+
+egl_opengl_link_gpa_modules = $(egl_opengl_link_gpa_srcs:.c=.o)
+
+$(dir)/egl-opengl-link-gpa: $(egl_opengl_link_gpa_modules)
+ $(call quiet,$(FIPS_LINKER) $(CFLAGS)) $^ $(EGL_LDFLAGS) $(GL_LDFLAGS) $(X11_LDFLAGS) -o $@
+
+egl_opengl_dlopen_dlsym_srcs = \
+ $(dir)/egl-opengl-dlopen-dlsym.c \
+ $(dir)/util-x11.c
+
+egl_opengl_dlopen_dlsym_modules = $(egl_opengl_dlopen_dlsym_srcs:.c=.o)
+
+$(dir)/egl-opengl-dlopen-dlsym: $(egl_opengl_dlopen_dlsym_modules)
+ $(call quiet,$(FIPS_LINKER) $(CFLAGS)) $^ -ldl $(X11_LDFLAGS) -o $@
+
+egl_opengl_dlopen_gpa_srcs = \
+ $(dir)/egl-opengl-dlopen-gpa.c \
+ $(dir)/util-x11.c
+
+egl_opengl_dlopen_gpa_modules = $(egl_opengl_dlopen_gpa_srcs:.c=.o)
+
+$(dir)/egl-opengl-dlopen-gpa: $(egl_opengl_dlopen_gpa_modules)
+ $(call quiet,$(FIPS_LINKER) $(CFLAGS)) $^ -ldl $(X11_LDFLAGS) -o $@
+
test: all $(test_programs)
@${dir}/fips-test
$(glx_link_gpaa_srcs) \
$(glx_dlopen_dlsym_srcs) \
$(glx_dlopen_gpa_srcs) \
- $(egl_opengl_link_call_srcs)
+ $(egl_opengl_link_call_srcs) \
+ $(egl_opengl_link_gpa_srcs) \
+ $(egl_opengl_dlopen_dlsym_srcs) \
+ $(egl_opengl_dlopen_gpa_srcs)
CLEAN += $(test_programs) \
$(glx_link_call_modules) \
$(glx_link_gpaa_modules) \
$(glx_dlopen_dlsym_modules) \
$(glx_dlopen_gpa_modules) \
- $(egl_opengl_link_call_modules)
+ $(egl_opengl_link_call_modules) \
+ $(egl_opengl_link_gpa_modules) \
+ $(egl_opengl_dlopen_dlsym_modules) \
+ $(egl_opengl_dlopen_dlsym_modules)
#endif
#ifdef COMMON_USE_EGL
+#ifndef COMMON_EGL_PREFIX
+#error Code including common.c with COMMON_USE_EGL must define COMMON_EGL_PREFIX
+#endif
#define COMMON_CONTEXT EGLContext
#define COMMON_SWAP_DISPLAY EGLDisplay
#define COMMON_SWAP_WINDOW EGLSurface
-#define COMMON_SWAP_FUNCTION eglSwapBuffers
+#define COMMON_SWAP_FUNCTION _E(eglSwapBuffers)
#else
#define COMMON_CONTEXT GLXContext
#define COMMON_SWAP_DISPLAY Display*
#define COMMON_SWAP_WINDOW Window
-#define COMMON_SWAP_FUNCTION glXSwapBuffers
+#define COMMON_SWAP_FUNCTION _(glXSwapBuffers)
#endif
#define concat_(a,b) a ## b
#define concat(a,b) concat_(a,b)
#define _(func) concat(COMMON_GL_PREFIX, func)
+#define _E(func) concat(COMMON_EGL_PREFIX, func)
static void
set_2d_projection (int width, int height)
XVisualInfo *visual_info, visual_attr;
int visualid, num_visuals;
- egl_dpy = eglGetDisplay (dpy);
+ egl_dpy = _E(eglGetDisplay) (dpy);
- success = eglInitialize (egl_dpy, &major, &minor);
+ success = _E(eglInitialize) (egl_dpy, &major, &minor);
if (!success) {
fprintf (stderr, "Error: Failed to initialized EGL\n");
exit (1);
}
- success = eglChooseConfig (egl_dpy, config_attr, &config, 1, &num_configs);
+ success = _E(eglChooseConfig) (egl_dpy, config_attr, &config, 1, &num_configs);
if (!success || num_configs == 0) {
fprintf (stderr, "Error: Failed to find EGL config\n");
exit (1);
}
- success = eglGetConfigAttrib (egl_dpy, config, EGL_NATIVE_VISUAL_ID, &visualid);
+ success = _E(eglGetConfigAttrib) (egl_dpy, config, EGL_NATIVE_VISUAL_ID, &visualid);
if (!success) {
fprintf (stderr, "Error: Failed to find native Visual ID\n");
exit (1);
exit (1);
}
- eglBindAPI (api);
+ _E(eglBindAPI) (api);
- ctx = eglCreateContext (egl_dpy, config, NULL, context_attr);
+ ctx = _E(eglCreateContext) (egl_dpy, config, NULL, context_attr);
if (!ctx) {
fprintf (stderr, "Error: Failed to create EGL context\n");
exit (1);
static void
common_make_current (EGLDisplay egl_dpy, EGLContext ctx, EGLSurface surface)
{
- _(eglMakeCurrent) (egl_dpy, surface, surface, ctx);
+ _E(eglMakeCurrent) (egl_dpy, surface, surface, ctx);
}
#else
static void
for (i = 0; i < 2; i++) {
/* Frame: Draw a solid (magenta) frame */
paint_rgb_using_clear (RGB(frame));
- _(COMMON_SWAP_FUNCTION) (dpy, window);
+ COMMON_SWAP_FUNCTION (dpy, window);
frame++;
/* Frame: Draw a solid (yellow) frame */
paint_rgb_using_clear (RGB(frame));
- _(COMMON_SWAP_FUNCTION) (dpy, window);
+ COMMON_SWAP_FUNCTION (dpy, window);
frame++;
/* Frame: Draw a solid (cyan) frame */
paint_rgb_using_clear (RGB(frame));
- _(COMMON_SWAP_FUNCTION) (dpy, window);
+ COMMON_SWAP_FUNCTION (dpy, window);
frame++;
}
}
--- /dev/null
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* Perform some simple drawing via OpenGL as follows:
+ *
+ * 1. Using EGL to construct an OpenGL context
+ * 2. By using dlopen to dynamically load libGL.so and libEGL.so
+ * 3. By using dlsym to lookup OpenGL functions
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <EGL/egl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include "util-x11.h"
+
+EGLBoolean (*my_eglBindAPI)(EGLenum);
+EGLBoolean (*my_eglChooseConfig)(EGLDisplay, EGLint const *, EGLConfig *, EGLint, EGLint *);
+EGLContext (*my_eglCreateContext)(EGLDisplay, EGLConfig, EGLContext, EGLint const *);
+EGLSurface (*my_eglCreateWindowSurface)(EGLDisplay, EGLConfig, NativeWindowType, EGLint const *);
+EGLBoolean (*my_eglGetConfigAttrib)(EGLDisplay, EGLConfig, EGLint, EGLint *);
+EGLDisplay (*my_eglGetDisplay)(NativeDisplayType);
+EGLBoolean (*my_eglInitialize)(EGLDisplay, EGLint *, EGLint *);
+EGLBoolean (*my_eglMakeCurrent)(EGLDisplay, EGLSurface, EGLSurface, EGLContext);
+EGLBoolean (*my_eglSwapBuffers)(EGLDisplay, EGLSurface);
+void (*my_glClear)(GLbitfield);
+void (*my_glClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
+void (*my_glLoadIdentity)(void);
+void (*my_glMatrixMode)(GLenum);
+void (*my_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+void (*my_glViewport)(GLint, GLint, GLsizei, GLsizei);
+
+#define COMMON_USE_EGL
+#define COMMON_GL_PREFIX my_
+#define COMMON_EGL_PREFIX my_
+#include "common.c"
+
+static void
+resolve_symbols (void)
+{
+ void *gl_handle;
+ void *egl_handle;
+ char *error;
+
+ gl_handle = dlopen ("libGL.so", RTLD_LAZY);
+ if (gl_handle == NULL) {
+ fprintf (stderr, "Error: Failed to open libGL.so\n");
+ exit (1);
+ }
+
+ egl_handle = dlopen ("libEGL.so", RTLD_LAZY);
+ if (egl_handle == NULL) {
+ fprintf (stderr, "Error: Failed to open libEGL.so\n");
+ exit (1);
+ }
+
+ /* Clear errors. */
+ dlerror();
+
+ my_eglBindAPI = dlsym (egl_handle, "eglBindAPI");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglBindAPI: %s\n", error);
+ exit (1);
+ }
+
+ my_eglChooseConfig = dlsym (egl_handle, "eglChooseConfig");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglChooseConfig: %s\n", error);
+ exit (1);
+ }
+
+ my_eglCreateContext = dlsym (egl_handle, "eglCreateContext");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglCreateContext: %s\n", error);
+ exit (1);
+ }
+
+ my_eglCreateWindowSurface = dlsym (egl_handle, "eglCreateWindowSurface");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglCreateWindowSurface: %s\n", error);
+ exit (1);
+ }
+
+ my_eglGetConfigAttrib = dlsym (egl_handle, "eglGetConfigAttrib");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglGetConfigAttrib: %s\n", error);
+ exit (1);
+ }
+
+ my_eglGetDisplay = dlsym (egl_handle, "eglGetDisplay");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglGetDisplay: %s\n", error);
+ exit (1);
+ }
+
+ my_eglInitialize = dlsym (egl_handle, "eglInitialize");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglInitialize: %s\n", error);
+ exit (1);
+ }
+
+ my_eglMakeCurrent = dlsym (egl_handle, "eglMakeCurrent");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglMakeCurrent: %s\n", error);
+ exit (1);
+ }
+
+ my_eglSwapBuffers = dlsym (egl_handle, "eglSwapBuffers");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglSwapBuffers: %s\n", error);
+ exit (1);
+ }
+
+ my_glClear = dlsym (gl_handle, "glClear");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glClear: %s\n", error);
+ exit (1);
+ }
+
+ my_glClearColor = dlsym (gl_handle, "glClearColor");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glClearColor: %s\n", error);
+ exit (1);
+ }
+
+ my_glLoadIdentity = dlsym (gl_handle, "glLoadIdentity");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glLoadIdentity: %s\n", error);
+ exit (1);
+ }
+
+ my_glMatrixMode = dlsym (gl_handle, "glMatrixMode");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glMatrixMode: %s\n", error);
+ exit (1);
+ }
+
+ my_glOrtho = dlsym (gl_handle, "glOrtho");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glOrtho: %s\n", error);
+ exit (1);
+ }
+
+ my_glViewport = dlsym (gl_handle, "glViewport");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym glViewport: %s\n", error);
+ exit (1);
+ }
+}
+
+int
+main (void)
+{
+ Display *dpy;
+ Window window;
+ EGLDisplay egl_dpy;
+ EGLContext ctx;
+ EGLConfig config;
+ EGLSurface surface;
+ XVisualInfo *visual_info;
+
+ resolve_symbols ();
+
+ dpy = util_x11_init_display ();
+
+ common_create_egl_context (dpy, EGL_OPENGL_API, &egl_dpy,
+ &ctx, &config, &visual_info);
+
+ window = util_x11_init_window (dpy, visual_info);
+
+ surface = my_eglCreateWindowSurface (egl_dpy, config, window, NULL);
+
+ common_make_current (egl_dpy, ctx, surface);
+
+ common_handle_events (dpy, egl_dpy, surface);
+
+ util_x11_fini_window (dpy, window);
+
+ util_x11_fini_display (dpy);
+
+ return 0;
+}
--- /dev/null
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* Perform some simple drawing via OpenGL as follows:
+ *
+ * 1. Using EGL to construct an OpenGL context
+ * 2. By using dlopen to dynamically load libGL.so
+ * 3. By using eglGetProcAddress to lookup OpenGL functions
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <EGL/egl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include "util-x11.h"
+
+EGLBoolean (*my_eglBindAPI)(EGLenum);
+EGLBoolean (*my_eglChooseConfig)(EGLDisplay, EGLint const *, EGLConfig *, EGLint, EGLint *);
+EGLContext (*my_eglCreateContext)(EGLDisplay, EGLConfig, EGLContext, EGLint const *);
+EGLSurface (*my_eglCreateWindowSurface)(EGLDisplay, EGLConfig, NativeWindowType, EGLint const *);
+EGLBoolean (*my_eglGetConfigAttrib)(EGLDisplay, EGLConfig, EGLint, EGLint *);
+EGLDisplay (*my_eglGetDisplay)(NativeDisplayType);
+void * (*my_eglGetProcAddress)(char const *);
+EGLBoolean (*my_eglInitialize)(EGLDisplay, EGLint *, EGLint *);
+EGLBoolean (*my_eglMakeCurrent)(EGLDisplay, EGLSurface, EGLSurface, EGLContext);
+EGLBoolean (*my_eglSwapBuffers)(EGLDisplay, EGLSurface);
+
+/* The OpenGL header files give typedefs for the types of all
+ * functions provided by etensisons. Here, though, we're using
+ * glxGetProcAddress to lookup core functions, so we provide our own
+ * typedefs. */
+typedef void (*FIPS_GLCLEAR_FN)(GLbitfield);
+FIPS_GLCLEAR_FN my_glClear;
+
+typedef void (*FIPS_GLCLEARCOLOR_FN)(GLclampf, GLclampf, GLclampf, GLclampf);
+FIPS_GLCLEARCOLOR_FN my_glClearColor;
+
+typedef void (*FIPS_GLLOADIDENTITY_FN)(void);
+FIPS_GLLOADIDENTITY_FN my_glLoadIdentity;
+
+typedef void (*FIPS_GLMATRIXMODE_FN)(GLenum);
+FIPS_GLMATRIXMODE_FN my_glMatrixMode;
+
+typedef void (*FIPS_GLORTHO_FN)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+FIPS_GLORTHO_FN my_glOrtho;
+
+typedef void (*FIPS_GLVIEWPORT_FN)(GLint, GLint, GLsizei, GLsizei);
+FIPS_GLVIEWPORT_FN my_glViewport;
+
+#define COMMON_USE_EGL
+#define COMMON_GL_PREFIX my_
+#define COMMON_EGL_PREFIX my_
+#include "common.c"
+
+static void
+resolve_symbols (void)
+{
+ void *egl_handle, *gl_handle;
+ char *error;
+
+ egl_handle = dlopen ("libEGL.so", RTLD_LAZY);
+ if (egl_handle == NULL) {
+ fprintf (stderr, "Error: Failed to open libEGL.so\n");
+ exit (1);
+ }
+
+ gl_handle = dlopen ("libGL.so", RTLD_LAZY);
+ if (gl_handle == NULL) {
+ fprintf (stderr, "Error: Failed to open libGL.so\n");
+ exit (1);
+ }
+
+ /* Clear errors. */
+ dlerror();
+
+ my_eglBindAPI = dlsym (egl_handle, "eglBindAPI");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglBindAPI: %s\n", error);
+ exit (1);
+ }
+
+ my_eglChooseConfig = dlsym (egl_handle, "eglChooseConfig");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglChooseConfig: %s\n", error);
+ exit (1);
+ }
+
+ my_eglCreateContext = dlsym (egl_handle, "eglCreateContext");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglCreateContext: %s\n", error);
+ exit (1);
+ }
+
+ my_eglCreateWindowSurface = dlsym (egl_handle, "eglCreateWindowSurface");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglCreateWindowSurface: %s\n", error);
+ exit (1);
+ }
+
+ my_eglGetConfigAttrib = dlsym (egl_handle, "eglGetConfigAttrib");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglGetConfigAttrib: %s\n", error);
+ exit (1);
+ }
+
+ my_eglGetDisplay = dlsym (egl_handle, "eglGetDisplay");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglGetDisplay: %s\n", error);
+ exit (1);
+ }
+
+ my_eglGetProcAddress = dlsym (egl_handle, "eglGetProcAddress");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglGetProcAddress: %s\n", error);
+ exit (1);
+ }
+
+ my_eglInitialize = dlsym (egl_handle, "eglInitialize");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglInitialize: %s\n", error);
+ exit (1);
+ }
+
+ my_eglMakeCurrent = dlsym (egl_handle, "eglMakeCurrent");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglMakeCurrent: %s\n", error);
+ exit (1);
+ }
+
+ my_eglSwapBuffers = dlsym (egl_handle, "eglSwapBuffers");
+ error = dlerror ();
+ if (error) {
+ fprintf (stderr, "Failed to dlsym eglSwapBuffers: %s\n", error);
+ exit (1);
+ }
+
+ my_glClear = (FIPS_GLCLEAR_FN) my_eglGetProcAddress ("glClear");
+ if (my_glClear == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glClear\n");
+ exit (1);
+ }
+
+ my_glClearColor = (FIPS_GLCLEARCOLOR_FN) my_eglGetProcAddress ("glClearColor");
+ if (my_glClearColor == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glClearColor\n");
+ exit (1);
+ }
+
+ my_glLoadIdentity = (FIPS_GLLOADIDENTITY_FN) my_eglGetProcAddress ("glLoadIdentity");
+ if (my_glLoadIdentity == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glLoadIdentity\n");
+ exit (1);
+ }
+
+ my_glMatrixMode = (FIPS_GLMATRIXMODE_FN) my_eglGetProcAddress ("glMatrixMode");
+ if (my_glMatrixMode == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glMatrixMode\n");
+ exit (1);
+ }
+
+ my_glOrtho = (FIPS_GLORTHO_FN) my_eglGetProcAddress ("glOrtho");
+ if (my_glOrtho == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glOrtho\n");
+ exit (1);
+ }
+
+ my_glViewport = (FIPS_GLVIEWPORT_FN) my_eglGetProcAddress ("glViewport");
+ if (my_glViewport == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glViewport\n");
+ exit (1);
+ }
+}
+
+int
+main (void)
+{
+ Display *dpy;
+ Window window;
+ EGLDisplay egl_dpy;
+ EGLContext ctx;
+ EGLConfig config;
+ EGLSurface surface;
+ XVisualInfo *visual_info;
+
+ resolve_symbols ();
+
+ dpy = util_x11_init_display ();
+
+ common_create_egl_context (dpy, EGL_OPENGL_API, &egl_dpy,
+ &ctx, &config, &visual_info);
+
+ window = util_x11_init_window (dpy, visual_info);
+
+ surface = my_eglCreateWindowSurface (egl_dpy, config, window, NULL);
+
+ common_make_current (egl_dpy, ctx, surface);
+
+ common_handle_events (dpy, egl_dpy, surface);
+
+ util_x11_fini_window (dpy, window);
+
+ util_x11_fini_display (dpy);
+
+ return 0;
+}
/* Perform some simple drawing via OpenGL as follows:
*
* 1. Using EGL to construct an OpenGL context
- * 2. By directly linking with libEGL.so
+ * 2. By directly linking with libEGL.so and libGL.so
* 3. By directly calling OpenGL functions
*/
#define COMMON_USE_EGL
#define COMMON_GL_PREFIX
+#define COMMON_EGL_PREFIX
#include "common.c"
int
--- /dev/null
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* Perform some simple drawing via OpenGL as follows:
+ *
+ * 1. Using EGL to construct an OpenGL context
+ * 2. By directly linking with libEGL.so and libGL.so
+ * 3. By using eglGetProcAddress to lookup OpenGL functions
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <EGL/egl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util-x11.h"
+
+/* The OpenGL header files give typedefs for the types of all
+ * functions provided by etensisons. Here, though, we're using
+ * glxGetProcAddress to lookup core functions, so we provide our own
+ * typedefs. */
+typedef void (*FIPS_GLCLEAR_FN)(GLbitfield);
+FIPS_GLCLEAR_FN my_glClear;
+
+typedef void (*FIPS_GLCLEARCOLOR_FN)(GLclampf, GLclampf, GLclampf, GLclampf);
+FIPS_GLCLEARCOLOR_FN my_glClearColor;
+
+typedef void (*FIPS_GLLOADIDENTITY_FN)(void);
+FIPS_GLLOADIDENTITY_FN my_glLoadIdentity;
+
+typedef void (*FIPS_GLMATRIXMODE_FN)(GLenum);
+FIPS_GLMATRIXMODE_FN my_glMatrixMode;
+
+typedef void (*FIPS_GLORTHO_FN)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+FIPS_GLORTHO_FN my_glOrtho;
+
+typedef void (*FIPS_GLVIEWPORT_FN)(GLint, GLint, GLsizei, GLsizei);
+FIPS_GLVIEWPORT_FN my_glViewport;
+
+#define COMMON_USE_EGL
+#define COMMON_GL_PREFIX my_
+#define COMMON_EGL_PREFIX
+#include "common.c"
+
+static void
+resolve_symbols (void)
+{
+ my_glClear = (FIPS_GLCLEAR_FN) eglGetProcAddress ("glClear");
+ if (my_glClear == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glClear\n");
+ exit (1);
+ }
+
+ my_glClearColor = (FIPS_GLCLEARCOLOR_FN) eglGetProcAddress ("glClearColor");
+ if (my_glClearColor == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glClearColor\n");
+ exit (1);
+ }
+
+ my_glLoadIdentity = (FIPS_GLLOADIDENTITY_FN) eglGetProcAddress ("glLoadIdentity");
+ if (my_glLoadIdentity == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glLoadIdentity\n");
+ exit (1);
+ }
+
+ my_glMatrixMode = (FIPS_GLMATRIXMODE_FN) eglGetProcAddress ("glMatrixMode");
+ if (my_glMatrixMode == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glMatrixMode\n");
+ exit (1);
+ }
+
+ my_glOrtho = (FIPS_GLORTHO_FN) eglGetProcAddress ("glOrtho");
+ if (my_glOrtho == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glOrtho\n");
+ exit (1);
+ }
+
+ my_glViewport = (FIPS_GLVIEWPORT_FN) eglGetProcAddress ("glViewport");
+ if (my_glViewport == NULL) {
+ fprintf (stderr, "Failed to eglGetProcAddress glViewport\n");
+ exit (1);
+ }
+}
+
+int
+main (void)
+{
+ Display *dpy;
+ Window window;
+ EGLDisplay egl_dpy;
+ EGLContext ctx;
+ EGLConfig config;
+ EGLSurface surface;
+ XVisualInfo *visual_info;
+
+ resolve_symbols ();
+
+ dpy = util_x11_init_display ();
+
+ common_create_egl_context (dpy, EGL_OPENGL_API, &egl_dpy,
+ &ctx, &config, &visual_info);
+
+ window = util_x11_init_window (dpy, visual_info);
+
+ surface = eglCreateWindowSurface (egl_dpy, config, window, NULL);
+
+ common_make_current (egl_dpy, ctx, surface);
+
+ common_handle_events (dpy, egl_dpy, surface);
+
+ util_x11_fini_window (dpy, window);
+
+ util_x11_fini_display (dpy);
+
+ return 0;
+}
printf "Testing EGL/OpenGL link to libEGL direct calls ... "
test egl-opengl-link-call
+printf "Testing EGL/OpenGL link to libEGL eglGetProcAddress ... "
+test egl-opengl-link-gpa
+
+printf "Testing EGL/OpenGL dlopen(libGL) dlsym ... "
+test egl-opengl-dlopen-dlsym
+
+printf "Testing EGL/OpenGL dlopen(libGL) eglGetProcAddress ... "
+test egl-opengl-dlopen-gpa
+
echo ""
if [ $errors -gt 0 ]; then