def _info(self): '''Get SDL2 version and system's Display Server type''' self.info = sdl2.SDL_SysWMinfo() logging.info( 'Initialise variable for SDL2 version and subsystem info.') sdl2.SDL_VERSION(self.info.version) logging.info('- version = {0}.{1}.{2}'.format(self.info.version.major, self.info.version.minor, self.info.version.patch)) if sdl2.SDL_GetWindowWMInfo(self.window, ctypes.byref(self.info)) != 1: logging.error('sdl2.SDL_GetWindowWMInfo failed: Could not get ' 'window subsystem.') exit() logging.info('- subsystem = {0}'.format(self.info.subsystem))
def open(self, configuration): '''Open the SDL2 Window *Parameters:* - `configuration`: Configurations parameters from Application ''' if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0: msg = "Can't open window: %s" % sdl2.SDL_GetError() logger.critical(msg) raise SDL2Error(msg) flags = 0 if configuration.fullscreen and \ configuration.width and configuration.height: flags |= sdl2.SDL_WINDOW_FULLSCREEN elif configuration.fullscreen: flags |= sdl2.SDL_WINDOW_FULLSCREEN_DESKTOP if not configuration.decorated: flags |= sdl2.SDL_WINDOW_BORDERLESS if configuration.resizable: flags |= sdl2.SDL_WINDOW_RESIZABLE if configuration.highdpi: flags |= sdl2.SDL_WINDOW_ALLOW_HIGHDPI self.window = sdl2.SDL_CreateWindow(configuration.name.encode('ascii'), configuration.x, configuration.y, configuration.width, configuration.height, 0) if not self.window: msg = "Can't open window: %s" % sdl2.SDL_GetError() logger.critical(msg) raise SDL2Error(msg) logger.debug("SDL2 window opened with configuration: %s", (configuration, )) self.info = sdl2.SDL_SysWMinfo() sdl2.SDL_VERSION(self.info.version) sdl2.SDL_GetWindowWMInfo(self.window, ctypes.byref(self.info))
HEIGHT = 400 # ---------- # Init sdl2 if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0: raise Exception(sdl2.SDL_GetError()) window = sdl2.SDL_CreateWindow('test'.encode('ascii'), sdl2.SDL_WINDOWPOS_UNDEFINED, sdl2.SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, 0) if not window: raise Exception(sdl2.SDL_GetError()) wm_info = sdl2.SDL_SysWMinfo() sdl2.SDL_VERSION(wm_info.version) sdl2.SDL_GetWindowWMInfo(window, ctypes.byref(wm_info)) # ---------- # Create instance appInfo = VkApplicationInfo(sType=VK_STRUCTURE_TYPE_APPLICATION_INFO, pApplicationName="Hello Triangle", applicationVersion=VK_MAKE_VERSION(1, 0, 0), pEngineName="No Engine", engineVersion=VK_MAKE_VERSION(1, 0, 0), apiVersion=VK_API_VERSION_1_0) extensions = vkEnumerateInstanceExtensionProperties(None) extensions = [e.extensionName for e in extensions] print("availables extensions: %s\n" % extensions)