commit 169a49a564acc57a58352e3940a1e1819c0cdfdb
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Thu Feb 12 09:44:16 2015 +0100
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Thu Feb 12 09:44:16 2015 +0100
Video: Set correct texture access mode for the SDL_Texture
SDL_Textures created by SDL_CreateTextureFromSurface will always have
their texture access mode set to SDL_TEXTUREACCESS_STATIC, which means
"changes rarely" and is plain wrong in our case. However, it is
impossible to change this mode once a texture is created.
Now, we create the texture with the correct texture access mode, but
since we are not creating it from the RGBA surface anymore, we have to
set pixel format and dimensions explicitely. We can cope with that. ;-)
TODO: Find out what's the matter with SDL_TEXTUREACCESS_TARGET.
---
src/i_video.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/i_video.c b/src/i_video.c
index 270a4e21..e66891b8 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1857,8 +1857,13 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h)
SDL_FillRect(rgbabuffer, NULL, 0);
// Create the texture that the RGBA surface gets loaded into.
+ // SDL_TEXTUREACCESS_STREAMING means that this texture's content
+ // are going to change frequently.
- texture = SDL_CreateTextureFromSurface(renderer, rgbabuffer);
+ texture = SDL_CreateTexture(renderer,
+ SDL_PIXELFORMAT_ARGB8888,
+ SDL_TEXTUREACCESS_STREAMING,
+ SCREENWIDTH, SCREENHEIGHT);
// Save screen mode.