made TextureAtlas a struct

This commit is contained in:
nosch
2025-08-31 01:28:13 +02:00
parent 835b40046a
commit b503e7e57b
2 changed files with 23 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

+23 -9
View File
@@ -1,11 +1,31 @@
#include "../../include/raylib-cpp.hpp"
#include <string>
#include <vector>
using namespace std;
typedef vector<raylib::Texture> TextureAtlas;
typedef int ID;
struct TextureAtlas {
vector<Texture> atlas;
Texture GetTexture(ID id) {
if (atlas.size() >= id) {
return atlas[0];
}
return atlas[id];
}
bool LoadImage(const char *path) {
atlas.push_back(LoadTexture(path));
}
bool AddTexture(Texture texture){
atlas.push_back(texture);
}
};
Texture defaultTexture;
void GenDefaultTexture(){
@@ -16,14 +36,8 @@ void GenDefaultTexture(){
TextureAtlas NewTextureAtlas() {
TextureAtlas atlas;
atlas.push_back(defaultTexture);
atlas.AddTexture(defaultTexture);
return atlas;
}
Texture GetTexture(ID id, TextureAtlas atlas) {
if (atlas.size() >= id) {
return atlas[0];
}
return atlas[id];
}