Start porting the GL dispatch code to win32.

It now builds successfully builds a .dll file.  Not that it's usable
or anything yet.
macos/v1.5.9
Eric Anholt 11 years ago
parent 0e7b9c0939
commit 259136845d
  1. 39
      configure.ac
  2. 5
      src/Makefile.am
  3. 40
      src/dispatch_common.c
  4. 4
      src/dispatch_common.h

@ -44,6 +44,7 @@ AC_CHECK_PROGS([PYTHON], [python3 python2 python])
# Initialize libtool # Initialize libtool
AC_DISABLE_STATIC AC_DISABLE_STATIC
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
@ -51,13 +52,22 @@ case $host_os in
mingw*) mingw*)
build_egl=no build_egl=no
build_glx=no build_glx=no
# On windows, the DLL has to have all of its functions
# resolved at link time, so we have to link directly aginst
# opengl32.dll. But that's the only GL provider, anyway.
EPOXY_LINK_LIBS="-lopengl32"
;; ;;
*) *)
build_egl=yes build_egl=yes
build_glx=yes build_glx=yes
# On platforms with dlopen, we load everything dynamically and
# don't link against a specific window system or GL implementation.
EPOXY_LINK_LIBS=""
;; ;;
esac esac
AC_SUBST(EPOXY_LINK_LIBS)
AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes) AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes)
if test x$build_egl = xyes; then if test x$build_egl = xyes; then
AC_DEFINE([BUILD_EGL], [1], [build EGL tests]) AC_DEFINE([BUILD_EGL], [1], [build EGL tests])
@ -68,17 +78,26 @@ if test x$build_glx = xyes; then
AC_DEFINE([BUILD_GLX], [1], [build GLX tests]) AC_DEFINE([BUILD_GLX], [1], [build GLX tests])
fi fi
if test "x$GCC" = xyes; then
save_CFLAGS="$CFLAGS"
AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
VISIBILITY_CFLAGS="-fvisibility=hidden"
CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
[VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
# Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed. case $host_os in
CFLAGS=$save_CFLAGS mingw*)
fi # visibility flags aren't supported for windows DLLs, and the
# compiler whines to tell you so, so don't set them up.
;;
*)
if test "x$GCC" = xyes; then
save_CFLAGS="$CFLAGS"
AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
VISIBILITY_CFLAGS="-fvisibility=hidden"
CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
[VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
# Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
CFLAGS=$save_CFLAGS
fi
;;
esac
AC_SUBST([VISIBILITY_CFLAGS]) AC_SUBST([VISIBILITY_CFLAGS])

@ -93,6 +93,11 @@ libepoxy_la_SOURCES = \
$(BUILD_GLX_CODE) \ $(BUILD_GLX_CODE) \
$() $()
libepoxy_la_LDFLAGS = \
-no-undefined \
$(EPOXY_LINK_LIBS) \
$()
if BUILD_EGL if BUILD_EGL
BUILD_EGL_CODE = \ BUILD_EGL_CODE = \
$(GENERATED_EGL) \ $(GENERATED_EGL) \

@ -89,27 +89,26 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h> #include <dlfcn.h>
#include <err.h>
#include <pthread.h>
#endif
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <pthread.h>
#include <err.h>
#include "epoxy/gl.h"
#if PLATFORM_HAS_GLX
#include "epoxy/glx.h"
#endif
#if PLATFORM_HAS_EGL
#include "epoxy/egl.h"
#endif
#include "dispatch_common.h" #include "dispatch_common.h"
struct api { struct api {
#ifndef _WIN32
/** /**
* Locking for making sure we don't double-dlopen(). * Locking for making sure we don't double-dlopen().
*/ */
pthread_mutex_t mutex; pthread_mutex_t mutex;
#endif
/** dlopen() return value for libGL.so.1. */ /** dlopen() return value for libGL.so.1. */
void *glx_handle; void *glx_handle;
@ -139,9 +138,12 @@ struct api {
}; };
static struct api api = { static struct api api = {
#ifndef _WIN32
.mutex = PTHREAD_MUTEX_INITIALIZER, .mutex = PTHREAD_MUTEX_INITIALIZER,
#endif
}; };
#ifndef _WIN32
static void static void
get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail)
{ {
@ -173,6 +175,14 @@ do_dlsym(void **handle, const char *lib_name, const char *name,
return result; return result;
} }
#else
static void *
do_dlsym(void **handle, const char *lib_name, const char *name,
bool exit_on_fail)
{
return NULL;
}
#endif
PUBLIC bool PUBLIC bool
epoxy_is_desktop_gl(void) epoxy_is_desktop_gl(void)
@ -331,6 +341,9 @@ epoxy_gles2_dlsym(const char *name)
void * void *
epoxy_get_proc_address(const char *name) epoxy_get_proc_address(const char *name)
{ {
#ifdef _WIN32
return wglGetProcAddress(name);
#else
if (api.egl_handle) { if (api.egl_handle) {
return eglGetProcAddress(name); return eglGetProcAddress(name);
} else if (api.glx_handle) { } else if (api.glx_handle) {
@ -370,6 +383,7 @@ epoxy_get_proc_address(const char *name)
errx(1, "Couldn't find GLX or EGL libraries.\n"); errx(1, "Couldn't find GLX or EGL libraries.\n");
} }
#endif
} }
void void
@ -395,9 +409,13 @@ epoxy_print_failure_reasons(const char *name,
PUBLIC void PUBLIC void
epoxy_glBegin(GLenum primtype) epoxy_glBegin(GLenum primtype)
{ {
#ifdef _WIN32
#warning missing locking
#else
pthread_mutex_lock(&api.mutex); pthread_mutex_lock(&api.mutex);
api.begin_count++; api.begin_count++;
pthread_mutex_unlock(&api.mutex); pthread_mutex_unlock(&api.mutex);
#endif
epoxy_glBegin_unwrapped(primtype); epoxy_glBegin_unwrapped(primtype);
} }
@ -407,7 +425,11 @@ epoxy_glEnd(void)
{ {
epoxy_glEnd_unwrapped(); epoxy_glEnd_unwrapped();
#ifdef _WIN32
#warning missing locking
#else
pthread_mutex_lock(&api.mutex); pthread_mutex_lock(&api.mutex);
api.begin_count--; api.begin_count--;
pthread_mutex_unlock(&api.mutex); pthread_mutex_unlock(&api.mutex);
#endif
} }

@ -40,7 +40,9 @@
#endif #endif
#ifndef PUBLIC #ifndef PUBLIC
# if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # ifdef _WIN32
# define PUBLIC __declspec(dllexport)
# elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define PUBLIC __attribute__((visibility("default"))) # define PUBLIC __attribute__((visibility("default")))
# else # else
# define PUBLIC # define PUBLIC

Loading…
Cancel
Save