46 lines
1.1 KiB
C
46 lines
1.1 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 struct tileset_s {
|
|
uint16_t tileWidth;
|
|
uint16_t tileHeight;
|
|
uint16_t tileCount;
|
|
uint16_t columns;
|
|
uint16_t rows;
|
|
vec2 uv;
|
|
} tileset_t;
|
|
|
|
/**
|
|
* Gets the UV coordinates for a tile index in the tileset.
|
|
*
|
|
* @param tileset The tileset to get the UV coordinates from.
|
|
* @param tileIndex The index of the tile to get the UV coordinates for.
|
|
* @param outUV The output UV coordinates (vec4).
|
|
*/
|
|
void tilesetTileGetUV(
|
|
const tileset_t *tileset,
|
|
const uint16_t tileIndex,
|
|
vec4 outUV
|
|
);
|
|
|
|
/**
|
|
* Gets the UV coordinates for a tile position in the tileset.
|
|
*
|
|
* @param tileset The tileset to get the UV coordinates from.
|
|
* @param column The column of the tile to get the UV coordinates for.
|
|
* @param row The row of the tile to get the UV coordinates for.
|
|
* @param outUV The output UV coordinates (vec4).
|
|
*/
|
|
void tilesetPositionGetUV(
|
|
const tileset_t *tileset,
|
|
const uint16_t column,
|
|
const uint16_t row,
|
|
vec4 outUV
|
|
); |