35 if (
vertices.at(i).xCoordinate == 1) {
39 if (
vertices.at(i).yCoordinate == 1) {
48 #define COLOR_PALETTE_SIZE 256
68 glGenTextures(1, &
id);
85 std::vector<File> files;
91 if (files.size() == 0) {
110 glDeleteTextures(1, &
id);
123 glDeleteTextures(1, &
id);
127 while (!
tiles.empty()) {
142 unsigned int width,
unsigned int height,
152 assert((bpp == 8) || (bpp == 24) || (bpp == 32));
157 while (
getIds(s).size() <= slot) {
159 glGenTextures(1, &
id);
163 unsigned int glcMode;
174 if (image !=
nullptr)
188 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
190 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
197 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
198 glGenerateMipmap(GL_TEXTURE_2D);
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
201 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
215 glActiveTexture(GL_TEXTURE0 + unit);
216 glBindTexture(GL_TEXTURE_2D,
getIds(s).at(n));
251 return *
tiles.at(index);
273 for (
int i = 0; i <
animations.at(index).size(); i++) {
286 while (v.size() <= (tex + 1)) {
287 v.emplace_back(v.size(), store);
305 unsigned int height) {
306 unsigned char* img =
new unsigned char[width * height];
307 for (
unsigned int i = 0; i < (width * height); i++)
315 unsigned char* img = std::get<0>(tex);
316 unsigned int width = std::get<1>(tex);
317 unsigned int height = std::get<2>(tex);
318 unsigned char* image =
new unsigned char[width * height * 4];
319 for (
unsigned int i = 0; i < (width * height); i++) {
321 image[i * 4] = col.x * 255;
322 image[(i * 4) + 1] = col.y * 255;
323 image[(i * 4) + 2] = col.z * 255;
324 image[(i * 4) + 3] = col.w * 255;
333 return loadPCX(filename, s, slot);
336 unsigned char* data =
stbi_load(filename.c_str(), &x, &y, &n, 0);
338 if ((n < 3) || (n > 4)) {
345 (n == 3) ? 24 : 32, s, slot);
358 unsigned char* image;
359 unsigned int w, h, bpp;
362 error =
pcxLoad(filename.c_str(), &image, &w, &h, &c, &bpp);
364 unsigned char* image2 =
scaleBuffer(image, &w, &h, bpp);
397 static int index = 0;
433 : TextureStorage::SYSTEM);
439 static int index = 0;
464 auto uvA = tile.getUV(0);
465 auto uvB = tile.getUV(2);
470 ImGui::Text(
"No textiles are currently loaded...!");
476 static int index = 0;
515 auto uvA = t.getUV(0);
516 auto uvB = t.getUV(2);
529 ImGui::Text(
"No animated textures are currently loaded...!");
535 ImGui::Text(
"Please load a level containing sprites!");
537 static int index = 0;
538 static int sprite = 0;
544 if (index < (
getWorld().sizeSpriteSequence() - 1))
559 if (index >=
getWorld().sizeSpriteSequence()) {
564 if (sprite >=
getWorld().getSpriteSequence(index).size()) {
574 auto uv = s.getUVs();
584 if (sprite < (
getWorld().getSpriteSequence(index).size() - 1))
static std::vector< unsigned int > mTextureIdsSystem
IMGUI_API void PopItemWidth()
IMGUI_API bool Checkbox(const char *label, bool *v)
static int initializeSplash()
static std::vector< unsigned int > mTextureIdsGame
IMGUI_API bool CollapsingHeader(const char *label, const char *str_id=NULL, bool display_frame=true, bool default_open=false)
unsigned char * scaleBuffer(unsigned char *image, unsigned int *w, unsigned int *h, unsigned int bpp)
String handling utilities.
static int numAnimatedTiles()
int randomInteger(int max, int min=0)
std::vector< TextureTileVertex > vertices
static std::vector< std::vector< int > > animations
static std::string getPakDir()
static void addAnimatedTile(int index, int tile)
static TextureTile & getTile(int index)
static std::vector< TextureTile * > tiles
static void addTile(TextureTile *t)
int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, unsigned int *height, ColorMode *mode, unsigned int *bpp)
Load a PCX image file into a buffer.
static std::vector< BufferManager > systemBuffers
static std::vector< int > gameUnits
unsigned char * generateColorTexture(glm::vec4 rgba, unsigned int width, unsigned int height, unsigned int bpp)
static LogLevel & get(int level)
static std::array< glm::vec4, 256 > colorPalette
static int loadImage(std::string filename, TextureStorage s=TextureStorage::GAME, int slot=-1)
static int getFirstTileAnimation(int index)
unsigned long sizeSpriteSequence()
static unsigned long getFPS()
static std::vector< unsigned int > & getIds(TextureStorage s)
bool stringEndsWith(std::string s, std::string suffix, bool casesensitive=false)
static int numTextures(TextureStorage s=TextureStorage::GAME)
static void addIndexedTexture(unsigned char *image, unsigned int width, unsigned int height)
static int bindTexture(unsigned int n, TextureStorage s)
Bind texture to next free texture unit.
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0), bool repeat_when_held=false)
static void error(char *msg)
static unsigned int getTextureID(int n, TextureStorage s)
Recursive file-system walking utilities.
IMGUI_API float GetColumnWidth(int column_index=-1)
static BufferManager * getBufferManager(int tex, TextureStorage store)
static unsigned int nextFreeTextureUnit
static std::vector< int > systemUnits
void findRecursiveFilesEndingWith(std::vector< File > &found, std::string end, bool casesensitive=false)
void argb2rgba32(unsigned char *image, unsigned int w, unsigned int h)
Sprite & getSprite(unsigned long index)
Runtime Configuration Storage.
#define assertGreaterThanEqual(x, y)
IMGUI_API void SameLine(int column_x=0, int spacing_w=-1)
static std::vector< int > & getUnits(TextureStorage s)
#define assertEqual(x, y)
#define assertGreaterThan(x, y)
IMGUI_API void Text(const char *fmt,...)
glm::vec2 getUV(unsigned int i)
#define COLOR_PALETTE_SIZE
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
STBIDEF void stbi_image_free(void *retval_from_stbi_load)
static void setPalette(int index, glm::vec4 color)
static int loadPCX(std::string filename, TextureStorage s, int slot)
#define assertLessThan(x, y)
static glm::vec4 getPalette(int index)
static int getNextTileAnimation(int index, int tile)
Random number generation.
static std::vector< BufferManager > gameBuffers
static int loadBufferSlot(unsigned char *image=nullptr, unsigned int width=256, unsigned int height=256, ColorMode mode=ColorMode::RGBA, unsigned int bpp=32, TextureStorage s=TextureStorage::GAME, int slot=-1, bool filter=true)
Loads Buffer as texture.
STBIDEF stbi_uc * stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)
static std::vector< std::tuple< unsigned char *, unsigned int, unsigned int > > indexedTextures
IMGUI_API float GetWindowWidth()
int pcxCheck(const char *filename)
Check if a file is a valid PCX image.
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *display_format="%.0f")
IMGUI_API void PushItemWidth(float item_width)
static void bindTextureId(unsigned int n, TextureStorage s, unsigned int unit)
static std::string getDataDir()