changeset 450:2a352118c55a

Add back Windows support, using GLEW for OpenGL.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 Aug 2013 18:21:07 +0200
parents d56536ef28e8
children c034570ac785
files pytouhou/lib/opengl.pxd pytouhou/lib/sdl.pxd pytouhou/lib/sdl.pyx pytouhou/ui/window.pyx setup.py
diffstat 5 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/lib/opengl.pxd	Sat Aug 03 15:49:11 2013 +0200
+++ b/pytouhou/lib/opengl.pxd	Fri Aug 30 18:21:07 2013 +0200
@@ -12,7 +12,13 @@
 ## GNU General Public License for more details.
 ##
 
-cdef extern from 'GL/gl.h':
+
+IF USE_GLEW:
+    cdef extern from 'GL/glew.h' nogil:
+        GLenum glewInit()
+
+
+cdef extern from 'GL/gl.h' nogil:
     ctypedef unsigned int GLuint
     ctypedef int GLint
     ctypedef float GLfloat
--- a/pytouhou/lib/sdl.pxd	Sat Aug 03 15:49:11 2013 +0200
+++ b/pytouhou/lib/sdl.pxd	Fri Aug 30 18:21:07 2013 +0200
@@ -23,6 +23,11 @@
     void SDL_Quit()
 
 
+IF UNAME_SYSNAME == "Windows":
+    cdef extern from "SDL_main.h":
+        void SDL_SetMainReady()
+
+
 cdef extern from "SDL_error.h":
     const char *SDL_GetError()
 
--- a/pytouhou/lib/sdl.pyx	Sat Aug 03 15:49:11 2013 +0200
+++ b/pytouhou/lib/sdl.pyx	Fri Aug 30 18:21:07 2013 +0200
@@ -147,6 +147,11 @@
         raise SDLError(SDL_GetError())
 
 
+IF UNAME_SYSNAME == "Windows":
+    def set_main_ready():
+        SDL_SetMainReady()
+
+
 def quit():
     SDL_Quit()
 
--- a/pytouhou/ui/window.pyx	Sat Aug 03 15:49:11 2013 +0200
+++ b/pytouhou/ui/window.pyx	Fri Aug 30 18:21:07 2013 +0200
@@ -20,6 +20,9 @@
           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
+
 
 class Clock(object):
     def __init__(self, fps=None):
@@ -76,6 +79,8 @@
         self.use_fixed_pipeline = fixed_pipeline
         self.runner = None
 
+        IF UNAME_SYSNAME == "Windows":
+            sdl.set_main_ready()
         sdl.init(sdl.INIT_VIDEO)
         sdl.img_init(sdl.INIT_PNG)
         if sound:
@@ -94,6 +99,10 @@
                               sdl.WINDOW_OPENGL | sdl.WINDOW_SHOWN)
         self.win.gl_create_context()
 
+        IF USE_GLEW:
+            if glewInit() != 0:
+                raise Exception('GLEW init fail!')
+
         # Initialize OpenGL
         glEnable(GL_BLEND)
         if self.use_fixed_pipeline:
--- a/setup.py	Sat Aug 03 15:49:11 2013 +0200
+++ b/setup.py	Fri Aug 30 18:21:07 2013 +0200
@@ -49,8 +49,10 @@
 try:
     from cx_Freeze import setup, Executable
 except ImportError:
+    is_windows = False
     extra = {}
 else:
+    is_windows = True
     extra = {'options': {'build_exe': {'includes': extension_names}},
              'executables': [Executable(script='eosd', base='Win32GUI')]}
 
@@ -65,6 +67,7 @@
       ext_modules=cythonize(extensions, nthreads=4,
                             compiler_directives={'infer_types': True,
                                                  'infer_types.verbose': True},
-                            compile_time_env={'MAX_TEXTURES': 1024}),
+                            compile_time_env={'MAX_TEXTURES': 1024,
+                                              'USE_GLEW': is_windows}),
       scripts=['eosd', 'anmviewer'],
       **extra)