comparison libmlk-core/mlk/core/texture.c @ 547:c7664b679a95

misc: remove error codes for now
author David Demelier <markand@malikania.fr>
date Mon, 06 Mar 2023 20:03:00 +0100
parents 80242343d152
children 76ce31b0151f
comparison
equal deleted inserted replaced
546:b7da58230a66 547:c7664b679a95
36 tex->handle = SDL_CreateTexture(MLK__RENDERER(), 36 tex->handle = SDL_CreateTexture(MLK__RENDERER(),
37 SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h); 37 SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h);
38 38
39 if (!tex->handle) { 39 if (!tex->handle) {
40 tex->w = tex->h = 0; 40 tex->w = tex->h = 0;
41 return MLK_ERR_SDL; 41 return mlk_errf("%s", SDL_GetError());
42 } 42 }
43 43
44 tex->w = w; 44 tex->w = w;
45 tex->h = h; 45 tex->h = h;
46 46
65 [MLK_TEXTURE_BLEND_ADD] = SDL_BLENDMODE_ADD, 65 [MLK_TEXTURE_BLEND_ADD] = SDL_BLENDMODE_ADD,
66 [MLK_TEXTURE_BLEND_MODULATE] = SDL_BLENDMODE_MOD 66 [MLK_TEXTURE_BLEND_MODULATE] = SDL_BLENDMODE_MOD
67 }; 67 };
68 68
69 if (SDL_SetTextureBlendMode(tex->handle, table[blend]) < 0) 69 if (SDL_SetTextureBlendMode(tex->handle, table[blend]) < 0)
70 return MLK_ERR_SDL; 70 return mlk_errf("%s", SDL_GetError());
71 71
72 return 0; 72 return 0;
73 } 73 }
74 74
75 int 75 int
77 { 77 {
78 assert(mlk_texture_ok(tex)); 78 assert(mlk_texture_ok(tex));
79 assert(alpha <= 255); 79 assert(alpha <= 255);
80 80
81 if (SDL_SetTextureAlphaMod(tex->handle, alpha) < 0) 81 if (SDL_SetTextureAlphaMod(tex->handle, alpha) < 0)
82 return MLK_ERR_SDL; 82 return mlk_errf("%s", SDL_GetError());
83 83
84 return 0; 84 return 0;
85 } 85 }
86 86
87 int 87 int
88 mlk_texture_set_color_mod(struct mlk_texture *tex, unsigned long color) 88 mlk_texture_set_color_mod(struct mlk_texture *tex, unsigned long color)
89 { 89 {
90 assert(mlk_texture_ok(tex)); 90 assert(mlk_texture_ok(tex));
91 91
92 if (SDL_SetTextureColorMod(tex->handle, MLK_COLOR_R(color), MLK_COLOR_G(color), MLK_COLOR_B(color)) < 0) 92 if (SDL_SetTextureColorMod(tex->handle, MLK_COLOR_R(color), MLK_COLOR_G(color), MLK_COLOR_B(color)) < 0)
93 return MLK_ERR_SDL; 93 return mlk_errf("%s", SDL_GetError());
94 94
95 return 0; 95 return 0;
96 } 96 }
97 97
98 int 98 int
106 .w = tex->w, 106 .w = tex->w,
107 .h = tex->h 107 .h = tex->h
108 }; 108 };
109 109
110 if (SDL_RenderCopy(MLK__RENDERER(), tex->handle, NULL, &dst) < 0) 110 if (SDL_RenderCopy(MLK__RENDERER(), tex->handle, NULL, &dst) < 0)
111 return MLK_ERR_SDL; 111 return mlk_errf("%s", SDL_GetError());
112 112
113 return 0; 113 return 0;
114 } 114 }
115 115
116 int 116 int
137 .w = dst_w, 137 .w = dst_w,
138 .h = dst_h 138 .h = dst_h
139 }; 139 };
140 140
141 if (SDL_RenderCopyEx(MLK__RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0) 141 if (SDL_RenderCopyEx(MLK__RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0)
142 return MLK_ERR_SDL; 142 return mlk_errf("%s", SDL_GetError());
143 143
144 return 0; 144 return 0;
145 } 145 }
146 146
147 void 147 void
163 assert(tex); 163 assert(tex);
164 assert(surface); 164 assert(surface);
165 165
166 if (!(tex->handle = SDL_CreateTextureFromSurface(MLK__RENDERER(), surface))) { 166 if (!(tex->handle = SDL_CreateTextureFromSurface(MLK__RENDERER(), surface))) {
167 tex->w = tex->h = 0; 167 tex->w = tex->h = 0;
168 return MLK_ERR_SDL; 168 return mlk_errf("%s", SDL_GetError());
169 } 169 }
170 170
171 tex->w = surface->w; 171 tex->w = surface->w;
172 tex->h = surface->h; 172 tex->h = surface->h;
173 173