* @return returns -1 if there is no free texture slot available, otherwise returns a valid handle that is >= 0 **/
| 252 | * @return returns -1 if there is no free texture slot available, otherwise returns a valid handle that is >= 0 |
| 253 | **/ |
| 254 | i32 UI_create_texture(UI_Context *ctx, u8 *data, int w, int h) { |
| 255 | // check if we have a free texture slot available |
| 256 | i32 handle = -1; |
| 257 | for (int i = 0; i < UI_MAX_TEXTURES; i++) { |
| 258 | if (ctx->textures[i] == false) { |
| 259 | handle = i; |
| 260 | ctx->textures[i] = true; |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | // if we don't have a free slot, return -1 (error) |
| 265 | if (handle == -1) { |
| 266 | printf("UI Error: A maximum of 5 textures can be created for the UI context!\n"); |
| 267 | return handle; |
| 268 | } |
| 269 | |
| 270 | switch (ctx->backend) |
| 271 | { |
| 272 | case UI_Render_Backend_Type::D3D11: |
| 273 | UI_d3d11_create_texture(ctx, handle, data, w, h); break; |
| 274 | } |
| 275 | |
| 276 | return handle; |
| 277 | } |
| 278 | |
| 279 | UI_Font *UI_load_font_memory(UI_Context *ctx, unsigned char *data, size_t file_size, int ASCII_start, int ASCII_end, int *sizes, int sizes_count) |
| 280 | { |
no test coverage detected