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