Exemple #1
0
    def test_query_texture(self):
        window = video.create_window("Test", 10, 10, 10, 10,
                                     video.SDL_WINDOW_HIDDEN)
        self.assertIsInstance(window, video.SDL_Window)
        renderer = render.create_renderer(window, -1,
                                          render.SDL_RENDERER_SOFTWARE)
        self.assertIsInstance(renderer, render.SDL_Renderer)

        formats = (pixels.SDL_PIXELFORMAT_ARGB8888,
                   pixels.SDL_PIXELFORMAT_RGB555,
                   pixels.SDL_PIXELFORMAT_RGBA4444,
                   pixels.SDL_PIXELFORMAT_ARGB2101010,
                   pixels.SDL_PIXELFORMAT_YUY2
                   )
        access = (render.SDL_TEXTUREACCESS_STATIC,
                  render.SDL_TEXTUREACCESS_STREAMING,
                  render.SDL_TEXTUREACCESS_TARGET)
        for fmt in formats:
            for acc in access:
                for w in range(1, 300, 5):
                    for h in range(1, 300, 5):
                        tex = render.create_texture(renderer, fmt, acc, w, h)
                        self.assertIsInstance(tex, render.SDL_Texture)
                        qf, qa, qw, qh = render.query_texture(tex)
                        self.assertEqual(qf, fmt)
                        self.assertEqual(qa, acc)
                        self.assertEqual(w, qw)
                        self.assertEqual(h, qh)
                        render.destroy_texture(tex)

        render.destroy_renderer(renderer)
        video.destroy_window(window)
Exemple #2
0
 def __repr__(self):
     tformat, access, w, h = render.query_texture(self.texture)
     static = "True"
     if access == render.SDL_TEXTUREACCESS_STREAMING:
         static = "False"
     return "TextureSprite(format=%d, static=%s, size=%s)" % (tformat, static, (w, h))
Exemple #3
0
 def __init__(self, texture):
     """Creates a new TextureSprite."""
     super(TextureSprite, self).__init__()
     self.texture = texture
     self._size = render.query_texture(texture)[2:]