def get_caption(): """ get_caption() -> (title, icontitle) Get the current window caption """ title = ffi.new("char*[1]") icon = ffi.new("char*[1]") sdl.SDL_WM_GetCaption(title, icon) return ffi.string(title[0]), ffi.string(icon[0])
def set_mode(resolution=(0, 0), flags=0, depth=0): """ set_mode(resolution=(0,0), flags=0, depth=0) -> Surface Initialize a window or screen for display """ w, h = unpack_rect(resolution) if w < 0 or h < 0: raise SDLError("Cannot set negative sized display mode") if flags == 0: flags = sdl.SDL_SWSURFACE if not get_init(): init() # depth and double buffering attributes need to be set specially for OpenGL if flags & sdl.SDL_OPENGL: if flags & sdl.SDL_DOUBLEBUF: gl_set_attribute(sdl.SDL_GL_DOUBLEBUFFER, 1) else: gl_set_attribute(sdl.SDL_GL_DOUBLEBUFFER, 0) if depth: gl_set_attribute(sdl.SDL_GL_DEPTH_SIZE, depth) c_surface = sdl.SDL_SetVideoMode(w, h, depth, flags) if c_surface and gl_get_attribute(sdl.SDL_GL_DOUBLEBUFFER): c_surface.flags |= sdl.SDL_DOUBLEBUF else: if depth == 0: flags |= sdl.SDL_ANYFORMAT c_surface = sdl.SDL_SetVideoMode(w, h, depth, flags) if not c_surface: raise SDLError.from_sdl_error() title = ffi.new("char*[1]") icon = ffi.new("char*[1]") sdl.SDL_WM_GetCaption(title, icon) if not title: sdl.SDL_WM_SetCaption("pygame window", "pygame") # pygame does this, so it's possibly a good idea sdl.SDL_PumpEvents() global _display_surface _display_surface = SurfaceNoFree._from_sdl_surface(c_surface) # TODO: set icon stuff return _display_surface