# HG changeset patch # User Emmanuel Gil Peyrot # Date 1377879667 -7200 # Node ID 2a352118c55a37787d4d67a9da50ba24dc1111f8 # Parent d56536ef28e8908e78d2900017330e62e4ac6bb8 Add back Windows support, using GLEW for OpenGL. diff --git a/pytouhou/lib/opengl.pxd b/pytouhou/lib/opengl.pxd --- a/pytouhou/lib/opengl.pxd +++ b/pytouhou/lib/opengl.pxd @@ -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 diff --git a/pytouhou/lib/sdl.pxd b/pytouhou/lib/sdl.pxd --- a/pytouhou/lib/sdl.pxd +++ b/pytouhou/lib/sdl.pxd @@ -23,6 +23,11 @@ cdef extern from "SDL.h": 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() diff --git a/pytouhou/lib/sdl.pyx b/pytouhou/lib/sdl.pyx --- a/pytouhou/lib/sdl.pyx +++ b/pytouhou/lib/sdl.pyx @@ -147,6 +147,11 @@ def mix_init(int flags): raise SDLError(SDL_GetError()) +IF UNAME_SYSNAME == "Windows": + def set_main_ready(): + SDL_SetMainReady() + + def quit(): SDL_Quit() diff --git a/pytouhou/ui/window.pyx b/pytouhou/ui/window.pyx --- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -20,6 +20,9 @@ from pytouhou.lib.opengl cimport \ 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 @@ class Window(object): 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 @@ class Window(object): 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: diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -49,8 +49,10 @@ for directory, _, files in os.walk('pyto 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 @@ setup(name='PyTouhou', 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)