# HG changeset patch # User Emmanuel Gil Peyrot # Date 1380889948 -7200 # Node ID 2276229282fdb81e0214c8af541c76b6d96aade2 # Parent 1b532e7dd521e369e63af414033272cc70a3eaa6 Fix gcc’s warnings with -Wall -Wextra. diff --git a/pytouhou/game/laser.pyx b/pytouhou/game/laser.pyx --- a/pytouhou/game/laser.pyx +++ b/pytouhou/game/laser.pyx @@ -166,20 +166,20 @@ cdef class Laser(Element): self.end_offset += self.speed length = min(self.end_offset - self.start_offset, self.max_length) # TODO + width = 0. if self.state == STARTING: if self.frame == self.start_duration: self.frame = 0 self.state = STARTED else: width = self.width * float(self.frame) / self.start_duration #TODO - if self.state == STARTED: + elif self.state == STARTED: width = self.width #TODO if self.frame == self.duration: self.frame = 0 self.state = STOPPING - if self.state == STOPPING: + elif self.state == STOPPING: if self.frame == self.stop_duration: - width = 0. self.removed = True else: width = self.width * (1. - float(self.frame) / self.stop_duration) #TODO diff --git a/pytouhou/game/text.pxd b/pytouhou/game/text.pxd --- a/pytouhou/game/text.pxd +++ b/pytouhou/game/text.pxd @@ -30,7 +30,8 @@ cdef class GlyphCollection(Widget): cdef class Text(GlyphCollection): cdef bytes text - cdef long shift, timeout, duration, start + cdef unsigned long timeout, duration, start + cdef long shift cdef Interpolator fade_interpolator cdef unsigned char alpha @@ -39,7 +40,7 @@ cdef class Text(GlyphCollection): #def move_timeout_update(self) #def fadeout_timeout_update(self) cdef void fade(self, unsigned long duration, unsigned char alpha, formula=*) except * - cpdef set_timeout(self, long timeout, str effect=*, long duration=*, long start=*) + cpdef set_timeout(self, unsigned long timeout, str effect=*, unsigned long duration=*, unsigned long start=*) cdef class Counter(GlyphCollection): @@ -63,8 +64,7 @@ cdef class NativeText(Element): cdef unsigned char alpha cdef bint shadow cdef bytes align #TODO: use a proper enum. - cdef unsigned long frame, timeout, duration - cdef long start + cdef unsigned long frame, timeout, duration, start cdef double to[2], end[2] cdef list gradient cdef Interpolator fade_interpolator, offset_interpolator @@ -78,4 +78,4 @@ cdef class NativeText(Element): cdef void fade(self, unsigned long duration, unsigned char alpha, formula=*) except * cdef void move_in(self, unsigned long duration, double x, double y, formula=*) except * - cpdef set_timeout(self, long timeout, str effect=*, long duration=*, long start=*, to=*, end=*) + cpdef set_timeout(self, unsigned long timeout, str effect=*, unsigned long duration=*, unsigned long start=*, to=*, end=*) diff --git a/pytouhou/game/text.py b/pytouhou/game/text.py --- a/pytouhou/game/text.py +++ b/pytouhou/game/text.py @@ -12,10 +12,7 @@ ## GNU General Public License for more details. ## -from pytouhou.game.element import Element -from pytouhou.game.sprite import Sprite from pytouhou.vm.anmrunner import ANMRunner -from pytouhou.utils.interpolator import Interpolator class Glyph(Element): diff --git a/pytouhou/lib/opengl.pxd b/pytouhou/lib/opengl.pxd --- a/pytouhou/lib/opengl.pxd +++ b/pytouhou/lib/opengl.pxd @@ -93,8 +93,6 @@ cdef extern from 'GL/gl.h' nogil: void glVertexPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) void glTexCoordPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) void glColorPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) - void glVertexAttribPointer(GLuint index, GLint size, GLenum type_, GLboolean normalized, GLsizei stride, const GLvoid *pointer) - void glEnableVertexAttribArray(GLuint index) void glBlendFunc(GLenum sfactor, GLenum dfactor) void glDrawArrays(GLenum mode, GLint first, GLsizei count) @@ -102,11 +100,6 @@ cdef extern from 'GL/gl.h' nogil: void glEnable(GLenum cap) void glDisable(GLenum cap) - void glGenBuffers(GLsizei n, GLuint * buffers) - void glDeleteBuffers(GLsizei n, const GLuint * buffers) - void glBindBuffer(GLenum target, GLuint buffer_) - void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) - void glGenTextures(GLsizei n, GLuint *textures) void glDeleteTextures(GLsizei n, const GLuint *textures) void glBindTexture(GLenum target, GLuint texture) @@ -128,6 +121,16 @@ cdef extern from 'GL/gl.h' nogil: void glHint(GLenum target, GLenum mode) void glEnableClientState(GLenum cap) + +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) + + void glGenBuffers(GLsizei n, GLuint * buffers) + void glDeleteBuffers(GLsizei n, const GLuint * buffers) + void glBindBuffer(GLenum target, GLuint buffer_) + void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) + GLuint glCreateProgram() GLuint glCreateShader(GLenum shaderType) void glLinkProgram(GLuint program) diff --git a/pytouhou/lib/sdl.pxd b/pytouhou/lib/sdl.pxd --- a/pytouhou/lib/sdl.pxd +++ b/pytouhou/lib/sdl.pxd @@ -80,7 +80,7 @@ cdef class Font: cdef void init(Uint32 flags) except * -cdef void img_init(Uint32 flags) except * +cdef void img_init(int flags) except * cdef void mix_init(int flags) except * cdef void ttf_init() except * cdef void gl_set_attribute(SDL_GLattr attr, int value) except * diff --git a/pytouhou/lib/sdl.pyx b/pytouhou/lib/sdl.pyx --- a/pytouhou/lib/sdl.pyx +++ b/pytouhou/lib/sdl.pyx @@ -167,7 +167,7 @@ cdef void init(Uint32 flags) except *: raise SDLError(SDL_GetError()) -cdef void img_init(Uint32 flags) except *: +cdef void img_init(int flags) except *: if IMG_Init(flags) != flags: raise SDLError(SDL_GetError()) @@ -182,22 +182,6 @@ cdef void ttf_init() except *: raise SDLError(SDL_GetError()) -cdef void quit() nogil: - SDL_Quit() - - -cdef void img_quit() nogil: - IMG_Quit() - - -cdef void mix_quit() nogil: - Mix_Quit() - - -cdef void ttf_quit() nogil: - TTF_Quit() - - cdef void gl_set_attribute(SDL_GLattr attr, int value) except *: if SDL_GL_SetAttribute(attr, value) < 0: raise SDLError(SDL_GetError()) diff --git a/pytouhou/ui/window.pxd b/pytouhou/ui/window.pxd --- a/pytouhou/ui/window.pxd +++ b/pytouhou/ui/window.pxd @@ -2,7 +2,8 @@ from pytouhou.lib cimport sdl cdef class Clock: - cdef long _target_fps, _ref_tick, _ref_frame, _fps_tick, _fps_frame + cdef unsigned long _ref_tick + cdef long _target_fps, _ref_frame, _fps_tick, _fps_frame cdef double _rate cdef void set_target_fps(self, long fps) nogil diff --git a/pytouhou/ui/window.pyx b/pytouhou/ui/window.pyx --- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -65,7 +65,7 @@ cdef class Clock: target_tick = self._ref_tick if self._target_fps: - target_tick += (self._ref_frame * 1000 / self._target_fps) + target_tick += (self._ref_frame * 1000 / self._target_fps) if current <= target_tick: sdl.delay(target_tick - current) diff --git a/pytouhou/vm/msgrunner.py b/pytouhou/vm/msgrunner.py --- a/pytouhou/vm/msgrunner.py +++ b/pytouhou/vm/msgrunner.py @@ -113,7 +113,7 @@ class MSGRunner(object): self._game.texts[0] = None self._game.texts[1] = None self._game.texts[index] = self._game.new_native_text((64, 372 + index * 24), text) - self._game.texts[index].set_timeout(-1, effect='fadeout', duration=15) + self._game.texts[index].set_timeout(0, effect='fadeout', duration=15) @instruction(4)