Mercurial > molko
comparison libcore/core/texture.h @ 121:789b23e01f52
misc: reorganize hierarchy, closes #2490
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 05 Oct 2020 13:25:06 +0200 |
parents | src/core/texture.h@ed72843a7194 |
children | b386d25832c8 |
comparison
equal
deleted
inserted
replaced
120:b3429b26d60d | 121:789b23e01f52 |
---|---|
1 /* | |
2 * texture.h -- basic texture management | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef MOLKO_TEXTURE_H | |
20 #define MOLKO_TEXTURE_H | |
21 | |
22 /** | |
23 * \file texture.h | |
24 * \brief Basic texture management. | |
25 * \ingroup drawing | |
26 * | |
27 * See also \a image.h for usage of textures. | |
28 */ | |
29 | |
30 #include <stdbool.h> | |
31 | |
32 /** | |
33 * \brief Texture object. | |
34 */ | |
35 struct texture { | |
36 unsigned int w; /*!< (RO) Texture width. */ | |
37 unsigned int h; /*!< (RO) Texture height. */ | |
38 void *handle; /*!< (RO) Native handle. */ | |
39 }; | |
40 | |
41 /** | |
42 * Create a new texture. | |
43 * | |
44 * \pre tex != NULL | |
45 * \param tex the texture to initialize | |
46 * \param w the width | |
47 * \param h the height | |
48 * \return False on error. | |
49 */ | |
50 bool | |
51 texture_new(struct texture *tex, unsigned int w, unsigned int h); | |
52 | |
53 /** | |
54 * Check if the texture is valid. | |
55 * | |
56 * This function simply checks if the texture is initialized and has non-null | |
57 * dimensions. | |
58 * | |
59 * \pre tex != NULL | |
60 * \param tex the texture to check | |
61 * \return True if the texture is initialized | |
62 */ | |
63 bool | |
64 texture_ok(const struct texture *tex); | |
65 | |
66 /** | |
67 * Simple texture drawing. | |
68 * | |
69 * \pre tex != NULL | |
70 * \param tex the texture | |
71 * \param x the X coordinate | |
72 * \param y the Y coordinate | |
73 */ | |
74 void | |
75 texture_draw(struct texture *tex, int x, int y); | |
76 | |
77 /** | |
78 * Advanced texture drawing. | |
79 * | |
80 * \pre tex != NULL | |
81 * \param tex the texture | |
82 * \param src_x the source rectangle X coordinate | |
83 * \param src_y the source rectangle Y coordinate | |
84 * \param src_w the source rectangle width | |
85 * \param src_h the source rectangle height | |
86 * \param dst_x the destination rectangle X coordinate | |
87 * \param dst_y the destination rectangle Y coordinate | |
88 * \param dst_w the destination rectangle width | |
89 * \param dst_h the destination rectangle height | |
90 * \param angle the angle | |
91 */ | |
92 void | |
93 texture_scale(struct texture *tex, | |
94 int src_x, | |
95 int src_y, | |
96 unsigned src_w, | |
97 unsigned src_h, | |
98 int dst_x, | |
99 int dst_y, | |
100 unsigned dst_w, | |
101 unsigned dst_h, | |
102 double angle); | |
103 | |
104 /** | |
105 * Close the texture, do not use afterwards. | |
106 * | |
107 * \pre tex != NULL | |
108 * \param tex the texture | |
109 */ | |
110 void | |
111 texture_finish(struct texture *tex); | |
112 | |
113 #endif /* !MOLKO_TEXTURE_H */ |