photon/csdl/__init__.py

68 lines
1.4 KiB
Python
Raw Normal View History

import ctypes
2011-03-27 02:46:16 +00:00
from .internal import _SDL, errcheck
# Constants
2011-03-16 18:41:54 +00:00
class INIT(object):
TIMER = 0x00000001
AUDIO = 0x00000010
VIDEO = 0x00000020
JOYSTICK = 0x00000200
HAPTIC = 0x00001000
NOPARACHUTE = 0x00100000
EVERYTHING = 0x0000FFFF
##### Error Handling
_SDL.SDL_GetError.restype = ctypes.c_char_p
def get_error():
return _SDL.SDL_GetError()
def set_error(msg):
_SDL.SDL_SetError(msg)
def clear_error():
_SDL.SDL_ClearError()
##### Initialization
def init(flags):
errcheck(_SDL.SDL_Init(flags))
def init_sub_system(flags):
errcheck(_SDL.SDL_InitSubSystem(flags))
def quit_sub_system(flags):
errcheck(_SDL.SDL_QuitSubSystem(flags))
def was_init(flags=0):
errcheck(_SDL.SDL_WasInit(flags))
def quit():
_SDL.SDL_Quit()
##### Version Info
class Version(ctypes.Structure):
_fields_ = (
("major", ctypes.c_uint8),
("minor", ctypes.c_uint8),
("patch", ctypes.c_uint8)
)
def __str__(self):
2011-03-27 02:13:22 +00:00
return '{0}.{1}.{2}'.format(self.major, self.minor, self.patch)
2011-03-27 02:13:22 +00:00
def __repr__(self):
return 'Version({0},{1},{2})'.format(self.major, self.minor,
self.patch)
def get_version():
v = Version()
_SDL.SDL_GetVersion(ctypes.byref(v))
return v
_SDL.SDL_GetRevision.restype = ctypes.c_char_p
def get_revision():
return _SDL.SDL_GetRevision()