Shipwright/libultraship/libultraship/TextureMod.h
Emill e56af6a7a3
Redesign hooks mechanism (#352)
* Redesign hooks mechanism

* Use reference instead of copy
2022-05-21 13:22:25 -04:00

56 lines
1.3 KiB
C++

#pragma once
#include "ModModule.h"
#include <PR/ultra64/gbi.h>
#include "Lib/Fast3D/gfx_pc.h"
#if 0
namespace Ship {
enum TextureMod {
GRAYSCALE,
NONE
};
struct TextureData {
char* data;
uint32_t size;
int width;
int height;
char* loaded_data;
std::shared_ptr<Ship::Archive> parent;
TextureMod color_modifier = NONE;
};
class TextureModule : public ModModule {
public:
explicit TextureModule(ModManager* Manager) : ModModule(Manager) {}
private:
std::vector<std::shared_ptr<Ship::Archive>> LoadedOTRS;
std::map<std::string, TextureData*> TexturePool;
std::map<std::string, std::vector<TextureCacheNode*>> TextureCache;
void Init() override;
void Open(std::shared_ptr<Ship::Archive> archive) override;
void Close(Ship::Archive mod) override;
void Exit() override;
protected:
void Hook_LookupTexture(HookEvent event);
void Hook_GrayScaleFilter(HookEvent event);
void Hook_InvalidateTexture(HookEvent event);
};
inline void GrayOutTexture(uint8_t* data, int width, int height) {
for (int x = 0; x < width * height * 4; x += 4) {
int red = data[x];
int green = data[x + 1];
int blue = data[x + 2];
int gray = (red + green + blue) / 3;
data[x] = gray;
data[x + 1] = gray;
data[x + 2] = gray;
}
}
}
#endif