1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 06:24:32 +00:00

Rework texture loading, part 1

Major code/logic cleanups + it has a multithreaded batch mode now.
The VFS code doesn't like multiple threads at all,
so for now there's a big lock in front of where it matters.
Changed precacher, map/tileset, and worldmap loading to batched mode.

Still TODO:
- fix broken mod preview images
- reloading resources on debug key
- make mod recache entirely unnecessary
- actually drop resources when no longer needed
This commit is contained in:
fgenesis 2023-05-31 00:55:16 +02:00
parent 1100e286a6
commit 70b8dcdc3a
22 changed files with 758 additions and 817 deletions

View file

@ -39,39 +39,30 @@ public:
Texture();
~Texture();
bool load(std::string file, bool mipmap);
void apply(bool repeat = false) const;
void unload();
void destroy();
unsigned gltexid;
int width, height;
unsigned textures[1];
void writeRGBA(int tx, int ty, int w, int h, const unsigned char *pixels);
void readRGBA(unsigned char *pixels);
void reload();
unsigned char *getBufferAndSize(int *w, int *h, size_t *size); // returned memory must be free()'d
void write(int tx, int ty, int w, int h, const unsigned char *pixels);
void read(int tx, int ty, int w, int h, unsigned char *pixels);
std::string name, filename;
bool upload(const ImageData& img, bool mipmap);
unsigned char *getBufferAndSize(int *w, int *h, unsigned int *size); // returned memory must be free()'d
std::string name;
TextureLoadResult getLoadResult() const { return loadResult; }
bool success;
protected:
std::string loadName;
bool loadInternal(const ImageData& img, bool mipmap);
int ow, oh;
TextureLoadResult loadResult;
bool _mipmap;
private:
mutable bool _repeating; // modified during rendering
};
#define UNREFTEX(x) if (x) {x = NULL;}
#define UNREFTEX(x) {x = NULL;}
#endif