#include "draw.h" #include #include "gif.h" #include namespace draw { SDL_Window *win = nullptr; SDL_Renderer *ren = nullptr; SDL_Texture *tex = nullptr; SDL_Texture *source = nullptr; SDL_Texture *dest = nullptr; std::vector textures; uint32_t palette[16]; void init() { SDL_Init(SDL_INIT_VIDEO); win = SDL_CreateWindow("DILEMMAKER v0.1", 1280, 960, 0); ren = SDL_CreateRenderer(win, NULL); tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 256, 192); SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); } void fillRect(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { SDL_SetRenderDrawColor(ren, r, g, b, a); SDL_FRect rect {float(x), float(y), float(w), float(h)}; SDL_RenderFillRect(ren, &rect); } void setSource(SDL_Texture *texture) { source = texture; } void setDest(SDL_Texture *texture) { dest = texture; SDL_SetRenderTarget(ren, dest); } void regenerateTexture(texture_t &texture) { if (texture.target) return; uint32_t *argb; int pitch; SDL_LockTexture(texture.texture, NULL, (void**)&argb, &pitch); for (int i=0; i