-
-
Notifications
You must be signed in to change notification settings - Fork 464
Expand file tree
/
Copy pathuser_sprites.h
More file actions
150 lines (137 loc) · 5.89 KB
/
Copy pathuser_sprites.h
File metadata and controls
150 lines (137 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* @file user_sprites.h
* @copyright 2003-2025 projectM Team
* @brief Types and enumerations used in the other API headers.
* @since 4.2.0
*
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2024 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
#pragma once
#include "projectM-4/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Loads and displays a new sprite.
*
* Currently, these sprite types are supported:
* <ul>
* <li><tt>milkdrop</tt>: Original Milkdrop user sprite syntax. Pass the contents of an <tt>imgNN</tt> section in
* the <tt>code</tt> argument.</li>
* </ul>
*
* Unsupported types and loading errors will result in failure, and no sprite will be added or replaced.
*
* @important The same OpenGL context used to create the projectM instance @a must be active when calling this method!
* @param instance The projectM instance handle.
* @param type The case-insensitive type name of the sprite to be displayed. See description for supported values.
* @param code The type-specific sprite code, e.g. the contents of an <tt>imgNN</tt> section from a Milkdrop user
* sprite INI file.
* @return A non-zero identifier if the sprite was successfully created, or zero if the type was
* unrecognized or the code couldn't be parsed.
* @since 4.2.0
*/
PROJECTM_EXPORT uint32_t projectm_sprite_create(projectm_handle instance,
const char* type,
const char* code);
/**
* @brief Destroys a single sprite.
*
* If there is no active sprite with the given ID, this method is a no-op.
*
* @param instance The projectM instance handle.
* @param sprite_id The ID of the sprite as returned by <tt>projectm_sprite_create()</tt>.
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_sprite_destroy(projectm_handle instance, uint32_t sprite_id);
/**
* @brief Destroys all active sprites.
* @param instance The projectM instance handle.
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_sprite_destroy_all(projectm_handle instance);
/**
* @brief Returns the number of currently active sprites.
*
* @note Sprites may destroy themselves after a frame has been rendered, and projectM can also
* remove a sprite if a new one is added and the sprite limit was already reached.
* Keep this in mind when calling <tt>projectm_sprite_get_sprite_ids()</tt> - ideally,
* call <tt>projectm_sprite_get_sprite_count()</tt> @a immediately before allocating the
* ID list.
* @param instance The projectM instance handle.
* @return The current number of sprites being rendered.
* @since 4.2.0
*/
PROJECTM_EXPORT uint32_t projectm_sprite_get_sprite_count(projectm_handle instance);
/**
* @brief Returns the number of currently active sprites.
*
* Identifiers are ordered by sprite age, with the oldest sprite first and the newest last.
*
* @param instance The projectM instance handle.
* @param sprite_ids A pointer to an already-allocated list which will receive the sprite IDs.
* Call <tt>projectm_sprite_get_sprite_count()</tt> to get the required length
* or allocate a list with the current sprite limit as its size and init all entries
* to zero.
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_sprite_get_sprite_ids(projectm_handle instance, uint32_t* sprite_ids);
/**
* @brief Sets the limit of concurrently displayed sprites.
*
* Once the limit is exceeded, the oldest sprite will be destroyed in order to display a new one.
*
* @param instance The projectM instance handle.
* @param max_sprites Maximum number of sprites to be displayed at once. Defaults to 16.
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_sprite_set_max_sprites(projectm_handle instance,
uint32_t max_sprites);
/**
* @brief Returns the currently set limit of concurrently displayed sprites.
*
* @param instance The projectM instance handle.
* @return The current maximum number of sprites to be displayed at once.
* @since 4.2.0
*/
PROJECTM_EXPORT uint32_t projectm_sprite_get_max_sprites(projectm_handle instance);
/**
* @brief Retrieves the current value of an expression variable of a given sprite.
*
* @param instance The projectM instance handle.
* @param sprite_id The sprite ID returned by projectm_sprite_create() to retrieve the value for.
* @param var_name The variable name to retrieve the value for.
* @return The current value of the requested variable. Returns 0.0 if the variable is not defined.
* @since 4.2.0
*/
PROJECTM_EXPORT double projectm_sprite_get_var(projectm_handle instance, uint32_t sprite_id, const char* var_name);
/**
* @brief Sets the value of the given variable for a single sprite instance.
*
* @param instance The projectM instance handle.
* @param sprite_id The sprite ID returned by projectm_sprite_create() to set the value for.
* @param var_name The variable to set a new value for.
* @param value The new value.
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_sprite_set_var(projectm_handle instance, uint32_t sprite_id, const char* var_name, double value);
#ifdef __cplusplus
} // extern "C"
#endif