made TextureAtlas a struct
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 483 B |
+23
-9
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user