def _createTexture(self): textSurface = TTF_RenderText_Shaded(self.font, self._text, self.textColor, self.backgroundColor) if textSurface is None: raise TTF_GetError() texture = render.SDL_CreateTextureFromSurface(self.renderer, textSurface) if texture is None: raise sdl2ext.SDLError() surface.SDL_FreeSurface(textSurface) return texture
def test_SDL_CreateTextureFromSurface(self): sf = surface.SDL_CreateRGBSurface(0, 100, 100, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF) self.assertIsInstance(sf.contents, surface.SDL_Surface) window = video.SDL_CreateWindow(b"Test", 10, 10, 10, 10, video.SDL_WINDOW_HIDDEN) self.assertIsInstance(window.contents, video.SDL_Window) renderer = render.SDL_CreateRenderer(window, -1, self._RENDERFLAGS) self.assertIsInstance(renderer.contents, render.SDL_Renderer) tex = render.SDL_CreateTextureFromSurface(renderer, sf) self.assertIsInstance(tex.contents, render.SDL_Texture) dogc()