changeset 555:98380e4a0ee5

Switch to libepoxy instead of libGLEW, which will help with OpenGL portability.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 19 Apr 2014 19:05:06 +0200
parents 653a9f087673
children c34b23e29d16
files README pytouhou/lib/opengl.pxd pytouhou/ui/opengl/backend.pyx setup.py
diffstat 4 files changed, 7 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/README	Fri May 30 04:06:09 2014 +0200
+++ b/README	Sat Apr 19 19:05:06 2014 +0200
@@ -15,6 +15,7 @@
     * Python2 (>= 2.6)
     * Cython
     * A working OpenGL driver
+    * libepoxy
     * SDL2
     * SDL2_image, SDL2_mixer, SDL2_ttf
     * A TTF font file, placed as “font.ttf” in the game directory.
--- a/pytouhou/lib/opengl.pxd	Fri May 30 04:06:09 2014 +0200
+++ b/pytouhou/lib/opengl.pxd	Sat Apr 19 19:05:06 2014 +0200
@@ -13,12 +13,7 @@
 ##
 
 
-IF USE_GLEW:
-    cdef extern from 'GL/glew.h' nogil:
-        GLenum glewInit()
-
-
-cdef extern from 'GL/gl.h' nogil:
+cdef extern from 'epoxy/gl.h' nogil:
     ctypedef unsigned int GLuint
     ctypedef unsigned short GLushort
     ctypedef int GLint
@@ -123,8 +118,8 @@
     void glHint(GLenum target, GLenum mode)
     void glEnableClientState(GLenum cap)
 
+    # Here start non-1.x declarations.
 
-cdef extern from 'GL/glext.h' nogil:
     void glVertexAttribPointer(GLuint index, GLint size, GLenum type_, GLboolean normalized, GLsizei stride, const GLvoid *pointer)
     void glEnableVertexAttribArray(GLuint index)
 
--- a/pytouhou/ui/opengl/backend.pyx	Fri May 30 04:06:09 2014 +0200
+++ b/pytouhou/ui/opengl/backend.pyx	Sat Apr 19 19:05:06 2014 +0200
@@ -6,9 +6,6 @@
           GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
           GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY)
 
-IF USE_GLEW:
-    from pytouhou.lib.opengl cimport glewInit
-
 
 GameRenderer = None
 
@@ -49,10 +46,6 @@
     window = Window(title, x, y, width, height, flags)
     window.gl_create_context()
 
-    if USE_GLEW:
-        if glewInit() != 0:
-            raise Exception('GLEW init fail!')
-
     # Initialize OpenGL
     glEnable(GL_BLEND)
     if is_legacy:
--- a/setup.py	Fri May 30 04:06:09 2014 +0200
+++ b/setup.py	Sat Apr 19 19:05:06 2014 +0200
@@ -17,7 +17,7 @@
 
 COMMAND = 'pkg-config'
 SDL_LIBRARIES = ['sdl2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf']
-GL_LIBRARIES = ['gl']
+GL_LIBRARIES = ['epoxy']
 
 packages = []
 extension_names = []
@@ -45,11 +45,11 @@
     'SDL2_image': '-lSDL2_image',
     'SDL2_mixer': '-lSDL2_mixer',
     'SDL2_ttf': '-lSDL2_ttf',
-    'gl': '-lGL'
+    'epoxy': '-lepoxy'
 }
 
 
-# Check for gl.pc, and don’t compile the OpenGL backend if it isn’t present.
+# Check for epoxy.pc, and don’t compile the OpenGL backend if it isn’t present.
 try:
     check_output([COMMAND] + GL_LIBRARIES)
 except CalledProcessError:
@@ -120,10 +120,8 @@
 try:
     from cx_Freeze import setup, Executable
 except ImportError:
-    is_windows = False
     extra = {}
 else:
-    is_windows = True
     nthreads = None  # It seems Windows can’t compile in parallel.
     base = 'Win32GUI' if sys.platform == 'win32' else None
     extra = {'options': {'build_exe': {'includes': extension_names + ['glob', 'socket', 'select']}},
@@ -144,7 +142,6 @@
                             compile_time_env={'MAX_TEXTURES': 128,
                                               'MAX_ELEMENTS': 640 * 4 * 3,
                                               'MAX_SOUNDS': 26,
-                                              'USE_OPENGL': use_opengl,
-                                              'USE_GLEW': is_windows}),
+                                              'USE_OPENGL': use_opengl}),
       scripts=['scripts/pytouhou'] + (['scripts/anmviewer'] if anmviewer else []),
       **extra)