- [WIP] nova UI

This commit is contained in:
raimon@prometeo committed 2026-09-25 06:45:32 +02:00
1 parent 6c205fb014
commit dedd6b6285
4 files changed
+57 -2

No files matched your search

+12 -1
View File
@@ -16,8 +16,8 @@ namespace ui
Context::~Context()
{
SDL_DestroyRenderer(this->ren);
SDL_DestroyTexture(this->fontTex);
SDL_DestroyRenderer(this->ren);
}
SDL_Texture *Context::CreateTexture(int width, int height)
@@ -88,6 +88,12 @@ namespace ui
return ( (tmp_x >= x) && (tmp_x < x+w) && (tmp_y >= y) && (tmp_y < y+h) );
}
void Context::Clear(uint32_t color)
{
SDL_SetRenderDrawColor(ren, (color>>16)&0xff, (color>>8)&0xff, color&0xff, (color>>24)&0xff);
SDL_RenderClear(ren);
}
void Context::DrawRect(int x, int y, int w, int h, uint32_t color)
{
SDL_FRect rect {float(this->offsetX+x), float(this->offsetY+y), float(w), float(h)};
@@ -123,4 +129,9 @@ namespace ui
SDL_SetTextureColorMod(this->fontTex, (color>>16)&0xff, (color>>8)&0xff, color&0xff);
for (int i=0; i<(int)strlen(text);++i) if (text[i]!=32) DrawChar(x+i*CHR_W, y, text[i]);
}
void Context::Present()
{
SDL_RenderPresent(this->ren);
}
}