Mercurial > molko
comparison libmlk-core/mlk/core/texture.c @ 613:f76cada0bbb2
misc: switch to SDL3
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 20 Aug 2023 11:14:58 +0200 |
parents | 76ce31b0151f |
children | e16808365d42 |
comparison
equal
deleted
inserted
replaced
612:297fa28cac90 | 613:f76cada0bbb2 |
---|---|
99 int | 99 int |
100 mlk_texture_draw(const struct mlk_texture *tex, int x, int y) | 100 mlk_texture_draw(const struct mlk_texture *tex, int x, int y) |
101 { | 101 { |
102 assert(tex); | 102 assert(tex); |
103 | 103 |
104 SDL_Rect dst = { | 104 SDL_FRect dst = { |
105 .x = x, | 105 .x = x, |
106 .y = y, | 106 .y = y, |
107 .w = tex->w, | 107 .w = tex->w, |
108 .h = tex->h | 108 .h = tex->h |
109 }; | 109 }; |
110 | 110 |
111 if (SDL_RenderCopy(MLK__RENDERER(), tex->handle, NULL, &dst) < 0) | 111 if (SDL_RenderTexture(MLK__RENDERER(), tex->handle, NULL, &dst) < 0) |
112 return mlk_errf("%s", SDL_GetError()); | 112 return mlk_errf("%s", SDL_GetError()); |
113 | 113 |
114 return 0; | 114 return 0; |
115 } | 115 } |
116 | 116 |
124 int dst_y, | 124 int dst_y, |
125 unsigned dst_w, | 125 unsigned dst_w, |
126 unsigned dst_h, | 126 unsigned dst_h, |
127 double angle) | 127 double angle) |
128 { | 128 { |
129 const SDL_Rect src = { | 129 const SDL_FRect src = { |
130 .x = src_x, | 130 .x = src_x, |
131 .y = src_y, | 131 .y = src_y, |
132 .w = src_w, | 132 .w = src_w, |
133 .h = src_h | 133 .h = src_h |
134 }; | 134 }; |
135 const SDL_Rect dst = { | 135 const SDL_FRect dst = { |
136 .x = dst_x, | 136 .x = dst_x, |
137 .y = dst_y, | 137 .y = dst_y, |
138 .w = dst_w, | 138 .w = dst_w, |
139 .h = dst_h | 139 .h = dst_h |
140 }; | 140 }; |
141 | 141 |
142 if (SDL_RenderCopyEx(MLK__RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0) | 142 if (SDL_RenderTextureRotated(MLK__RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0) |
143 return mlk_errf("%s", SDL_GetError()); | 143 return mlk_errf("%s", SDL_GetError()); |
144 | 144 |
145 return 0; | 145 return 0; |
146 } | 146 } |
147 | 147 |
170 } | 170 } |
171 | 171 |
172 tex->w = surface->w; | 172 tex->w = surface->w; |
173 tex->h = surface->h; | 173 tex->h = surface->h; |
174 | 174 |
175 SDL_FreeSurface(surface); | 175 SDL_DestroySurface(surface); |
176 | 176 |
177 return 0; | 177 return 0; |
178 } | 178 } |