comparison libcore/core/texture.c @ 169:eb0a7ab71023

misc: extreme cleanup, closes #2506 While here, remove unneeded stuff.
author David Demelier <markand@malikania.fr>
date Tue, 20 Oct 2020 17:39:13 +0200
parents b9b826cd9832
children 5d1b7d123401
comparison
equal deleted inserted replaced
168:aab824406d3d 169:eb0a7ab71023
17 */ 17 */
18 18
19 #include <assert.h> 19 #include <assert.h>
20 20
21 #include "error.h" 21 #include "error.h"
22 #include "error_p.h"
23 #include "texture.h" 22 #include "texture.h"
24 #include "texture_p.h" 23 #include "texture_p.h"
25 #include "util.h" 24 #include "util.h"
26 #include "window.h" 25 #include "window.h"
27 #include "window_p.h" 26 #include "window_p.h"
34 tex->handle = SDL_CreateTexture(RENDERER(), 33 tex->handle = SDL_CreateTexture(RENDERER(),
35 SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h); 34 SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h);
36 35
37 if (!tex->handle) { 36 if (!tex->handle) {
38 tex->w = tex->h = 0; 37 tex->w = tex->h = 0;
39 return error_sdl(); 38 return errorf("%s", SDL_GetError());
40 } 39 }
41 40
42 tex->w = w; 41 tex->w = w;
43 tex->h = h; 42 tex->h = h;
44 43
62 .w = tex->w, 61 .w = tex->w,
63 .h = tex->h 62 .h = tex->h
64 }; 63 };
65 64
66 if (SDL_RenderCopy(RENDERER(), tex->handle, NULL, &dst) < 0) 65 if (SDL_RenderCopy(RENDERER(), tex->handle, NULL, &dst) < 0)
67 return error_sdl(); 66 return errorf("%s", SDL_GetError());
68 67
69 return true; 68 return true;
70 } 69 }
71 70
72 bool 71 bool
93 .w = dst_w, 92 .w = dst_w,
94 .h = dst_h 93 .h = dst_h
95 }; 94 };
96 95
97 if (SDL_RenderCopyEx(RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0) 96 if (SDL_RenderCopyEx(RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0)
98 return error_sdl(); 97 return errorf("%s", SDL_GetError());
99 98
100 return true; 99 return true;
101 } 100 }
102 101
103 void 102 void
119 assert(tex); 118 assert(tex);
120 assert(surface); 119 assert(surface);
121 120
122 if (!(tex->handle = SDL_CreateTextureFromSurface(RENDERER(), surface))) { 121 if (!(tex->handle = SDL_CreateTextureFromSurface(RENDERER(), surface))) {
123 tex->w = tex->h = 0; 122 tex->w = tex->h = 0;
124 return error_sdl(); 123 return errorf("%s", SDL_GetError());
125 } 124 }
126 125
127 tex->w = surface->w; 126 tex->w = surface->w;
128 tex->h = surface->h; 127 tex->h = surface->h;
129 128