Freeciv-3.3
Loading...
Searching...
No Matches
sprite.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* SDL3 */
19#include <SDL3/SDL.h>
20#include <SDL3_image/SDL_image.h>
21
22/* utility */
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26
27/* client/gui-sdl3 */
28#include "colors.h"
29#include "graphics.h"
30
31#include "sprite.h"
32
33static struct sprite *ctor_sprite(SDL_Surface *surf);
34
35/************************************************************************/
40const char **gfx_fileextensions(void)
41{
42 static const char *ext[] = {
43 "png",
44 "gif",
45 "jpeg",
46 "xpm",
47 "qoi",
48 "tga",
49 "bmp",
50 "xcf",
51 "pcx",
52 "lbm",
53 "ppm",
54 "pgm",
55 "pbm",
56 "svg",
57 NULL
58 };
59
60 return ext;
61}
62
63/************************************************************************/
68struct sprite *load_gfxfile(const char *filename, bool svgflag)
69{
72
73 if ((pbuf = IMG_Load(filename)) == NULL) {
74 log_error(_("load_gfxfile(): Unable to load graphic file %s!"), filename);
75 return NULL; /* Should I use abort() ? */
76 }
77
80
81 return ctor_sprite(pconv);
82}
83
84/************************************************************************/
110 int x, int y, int width, int height,
111 struct sprite *mask,
113 float scale, bool smooth)
114{
118
119 if (mask) {
122 return ctor_sprite(pdest);
123 }
124
125 return ctor_sprite(psrc);
126}
127
128/************************************************************************/
131struct sprite *create_sprite(int width, int height, struct color *pcolor)
132{
134
138
140
143 NULL,
144 pcolor->color->r,
145 pcolor->color->g,
146 pcolor->color->b,
147 pcolor->color->a));
148
149 return ctor_sprite(mypixbuf);
150}
151
152/************************************************************************/
156{
157 *width = GET_SURF(sprite)->w;
158 *height = GET_SURF(sprite)->h;
159}
160
161/************************************************************************/
164void free_sprite(struct sprite *s)
165{
166 fc_assert_ret(s != NULL);
168 FC_FREE(s);
169}
170
171/************************************************************************/
174static struct sprite *ctor_sprite(SDL_Surface *surf)
175{
176 struct sprite *result = fc_malloc(sizeof(struct sprite));
177
178 result->psurface = surf;
179
180 return result;
181}
182
183/************************************************************************/
186struct sprite *load_gfxnumber(int num)
187{
188 /* Not supported in sdl3-client */
189 return NULL;
190}
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
char * incite_cost
Definition comments.c:76
#define _(String)
Definition fcintl.h:67
static GtkWidget * source
Definition gotodlg.c:58
void free_sprite(struct sprite *s)
Definition sprite.c:278
struct sprite * create_sprite(int width, int height, struct color *pcolor)
Definition sprite.c:84
struct sprite * load_gfxnumber(int num)
Definition sprite.c:526
struct sprite * load_gfxfile(const char *filename, bool svgflag)
Definition sprite.c:170
const char ** gfx_fileextensions(void)
Definition sprite.c:117
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
Definition graphics.c:262
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
SDL_Surface * convert_surf(SDL_Surface *surf_in)
Definition graphics.c:359
#define FREESURFACE(ptr)
Definition graphics.h:322
static struct sprite * ctor_sprite(SDL_Surface *surf)
Definition sprite.c:189
#define GET_SURF(m_sprite)
Definition sprite.h:29
#define GET_SURF_REAL(m_sprite)
Definition sprite.h:26
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define log_error(message,...)
Definition log.h:104
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
struct sprite int int int int struct sprite int mask_offset_x
Definition sprite_g.h:32
struct sprite int x
Definition sprite_g.h:31
crop_sprite
Definition sprite_g.h:30
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
struct sprite int int int int struct sprite int int mask_offset_y
Definition sprite_g.h:32
Definition colors.h:21
struct SDL_Surface * psurface
Definition sprite.h:21