Skip to content

Commit

Permalink
Switch from GLEW to epoxy
Browse files Browse the repository at this point in the history
  • Loading branch information
JayFoxRox committed Jun 28, 2018
1 parent 0523dea commit ba02bd2
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 145 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ addons:
- sparse
- uuid-dev
- libsdl2-dev
- libglew-dev
- libepoxy-dev

git:
# we want to do this ourselves
submodules: false

before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install libffi gettext glib pixman pkg-config autoconf pixman sdl2 glew; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install libffi gettext glib pixman pkg-config autoconf pixman sdl2 libepoxy; fi

script:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./build_macos.sh ; fi
Expand Down
2 changes: 1 addition & 1 deletion appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ bash -xlc "pacman --noconfirm -S --needed automake-wrapper"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-libtool"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-pkg-config"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-glib2"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-glew"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-SDL2"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-pixman"
bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-libepoxy"

rem Invoke subsequent bash in the build tree
cd %APPVEYOR_BUILD_FOLDER%
Expand Down
6 changes: 3 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ if test "$mingw32" = "yes" ; then
QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
# MinGW needs -mthreads for TLS and macro _MT.
QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
LIBS="-lwinmm -lws2_32 -liphlpapi -lopengl32 -lglew32 -lgdi32 $LIBS"
LIBS="-lwinmm -lws2_32 -liphlpapi -lopengl32 -lepoxy -lgdi32 $LIBS"
write_c_skeleton;
if compile_prog "" "-liberty" ; then
LIBS="-liberty $LIBS"
Expand Down Expand Up @@ -2948,7 +2948,7 @@ fi

# Xbox hack to include ogl framework
if test "$darwin" = "yes" ; then
sdl_libs="$sdl_libs -framework OpenGL"
sdl_libs="$sdl_libs -framework OpenGL -lepoxy"
# cat > $TMPC << EOF
# #include <OpenGL/gl.h>
# #include <OpenGL/CGLTypes.h>
Expand All @@ -2958,7 +2958,7 @@ if test "$darwin" = "yes" ; then
fi

if test "$linux" = "yes" ; then
sdl_libs="$sdl_libs -lGLEW -lGLU -lGL"
sdl_libs="$sdl_libs -lepoxy -lGLU -lGL"
fi

##########################################
Expand Down
2 changes: 1 addition & 1 deletion hw/xbox/nv2a/gl/Makefile.objs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
obj-y += gloffscreen_common.o glextensions.o
obj-y += gloffscreen_common.o
obj-$(CONFIG_WIN32) += gloffscreen_wgl.o
obj-$(CONFIG_DARWIN) += gloffscreen_cgl.o
obj-$(CONFIG_LINUX) += gloffscreen_glx.o
46 changes: 0 additions & 46 deletions hw/xbox/nv2a/gl/glextensions.c

This file was deleted.

44 changes: 0 additions & 44 deletions hw/xbox/nv2a/gl/glextensions.h

This file was deleted.

13 changes: 4 additions & 9 deletions hw/xbox/nv2a/gl/gloffscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@

#include <stdbool.h>

#include <epoxy/gl.h>

#if defined(__APPLE__) /* macOS-Specific GL Includes */
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <OpenGL/glext.h>
#elif defined(_WIN32) /* Windows-Specific GL Includes */
#include <GL/glew.h>
#include <GL/wglew.h>
#include <GL/gl.h>
#include <GL/wglext.h>
#include <epoxy/wgl.h>
#else /* Assume GLX */
#include <GL/glew.h>
#include <GL/glx.h>
#include <GL/glxext.h>
#include <GL/gl.h>
#include <epoxy/glx.h>
#endif

/* Used to hold data for the OpenGL context */
Expand All @@ -56,7 +52,6 @@ void glo_set_current(GloContext *context);

/* Check GL Extensions */
bool glo_check_extension(const char* ext_name);
void* glo_get_extension_proc(const char* extProc);

/* Create an OpenGL context */
GloContext *glo_context_create(void);
Expand Down
10 changes: 1 addition & 9 deletions hw/xbox/nv2a/gl/gloffscreen_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,7 @@ void glo_readpixels(GLenum gl_format, GLenum gl_type,
glPixelStorei(GL_PACK_ALIGNMENT, pa);
}


bool glo_check_extension(const char* ext_name)
{
int i;
int num_extensions = GL_NUM_EXTENSIONS;
for (i=0; i<num_extensions; i++) {
const char* ext = (const char*)glGetStringi(GL_EXTENSIONS, i);
if (!ext) break;
if (strcmp(ext, ext_name) == 0) return true;
}
return false;
return epoxy_has_gl_extension(ext_name);
}
19 changes: 2 additions & 17 deletions hw/xbox/nv2a/gl/gloffscreen_glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,13 @@ GloContext *glo_context_create(void)
if (context->glx_context == NULL) return NULL;
glo_set_current(context);

if (!initialized) {
/* Initialize glew */
glewExperimental = GL_TRUE;
if (GLEW_OK != glewInit()) {
/* GLEW failed! */
fprintf(stderr,"GLEW init failed.\n");
exit(EXIT_FAILURE);
}

/* Get rid of GLEW errors */
while(glGetError() != GL_NO_ERROR);
}
/* Get rid of possible errors from within GL wrapper or glo */
while(glGetError() != GL_NO_ERROR);

initialized = true;
return context;
}

void* glo_get_extension_proc(const char* ext_proc)
{
return glXGetProcAddress((const GLubyte *)ext_proc);
}

/* Set current context */
void glo_set_current(GloContext *context)
{
Expand Down
12 changes: 3 additions & 9 deletions hw/xbox/nv2a/gl/gloffscreen_wgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ static void glo_init(void) {
}
wglMakeCurrent(glo.hDC, glo.hContext);

/* Initialize glew */
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Glew init failed.\n");
abort();
}

if (!WGLEW_ARB_create_context
|| !WGLEW_ARB_pixel_format
|| !WGLEW_ARB_pbuffer) {
if (!epoxy_has_wgl_extension(glo.hDC, "ARB_create_context")
|| !epoxy_has_wgl_extension(glo.hDC, "ARB_pixel_format")
|| !epoxy_has_wgl_extension(glo.hDC, "ARB_pbuffer")) {
fprintf(stderr, "Unable to load the required WGL extensions\n");
abort();
}
Expand Down
1 change: 0 additions & 1 deletion hw/xbox/nv2a/nv2a.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "nv2a_int.h"

#include "gl/gloffscreen.h"
#include "gl/glextensions.h"

#define USE_TEXTURE_CACHE

Expand Down
8 changes: 8 additions & 0 deletions hw/xbox/nv2a/nv2a_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
#include "nv2a_debug.h"
#include "gl/glextensions.h"


void gl_debug_initialize(void)
{
if (glo_check_extension("GL_KHR_debug")) {
glEnable(GL_DEBUG_OUTPUT);
}
}

void gl_debug_message(bool cc, const char *fmt, ...)
{
size_t n;
Expand Down
4 changes: 1 addition & 3 deletions hw/xbox/nv2a/nv2a_pgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2641,11 +2641,9 @@ void pgraph_init(NV2AState *d)
assert(pg->gl_context);

#ifdef DEBUG_NV2A_GL
glEnable(GL_DEBUG_OUTPUT);
gl_debug_initialize();
#endif

glextensions_init();

/* DXT textures */
assert(glo_check_extension("GL_EXT_texture_compression_s3tc"));
/* Internal RGB565 texture format */
Expand Down

0 comments on commit ba02bd2

Please sign in to comment.