64 lines
1.6 KiB
C
64 lines
1.6 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "dusk.h"
|
|
|
|
typedef union texturedata_u texturedata_t;
|
|
|
|
typedef enum {
|
|
TEXTURE_FORMAT_RGBA = GX_TF_RGBA8,
|
|
TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
|
|
// TEXTURE_FORMAT_RGB4A3 = GX_TF_RGB5A3,
|
|
// TEXTURE_FORMAT_RGB5 = GX_TF_RGB565,
|
|
} textureformatdolphin_t;
|
|
|
|
typedef struct {
|
|
GXTexObj texObj;
|
|
textureformatdolphin_t format;
|
|
int32_t width;
|
|
int32_t height;
|
|
|
|
union {
|
|
uint8_t *rgba;
|
|
// u16 *rgba;
|
|
};
|
|
} texturedolphin_t;
|
|
|
|
/**
|
|
* Initializes a texture.
|
|
*
|
|
* @param texture The texture to initialize.
|
|
* @param width The width of the texture.
|
|
* @param height The height of the texture.
|
|
* @param format The format of the texture (e.g., GX_TF_RGBA8, GX_TF_CI8).
|
|
* @param data The data for the texture, the format changes per format.
|
|
* @return An error if the texture failed to initialize, otherwise success.
|
|
*/
|
|
errorret_t textureInitDolphin(
|
|
texturedolphin_t *texture,
|
|
const int32_t width,
|
|
const int32_t height,
|
|
const textureformatdolphin_t format,
|
|
const texturedata_t data
|
|
);
|
|
|
|
/**
|
|
* Binds a texture for rendering. Providing NULL will unbind any texture.
|
|
*
|
|
* @param texture The texture to bind.
|
|
* @return An error if the texture failed to bind, otherwise success.
|
|
*/
|
|
errorret_t textureBindDolphin(texturedolphin_t *texture);
|
|
|
|
/**
|
|
* Disposes a texture.
|
|
*
|
|
* @param texture The texture to dispose.
|
|
* @return An error if the texture failed to dispose, otherwise success.
|
|
*/
|
|
errorret_t textureDisposeDolphin(texturedolphin_t *texture); |