More work to drivers

- Add gfx_test
- add texture loading to GfxOpenGL
- add full submit code
- add debug logging
- add construct and destroy functionality to Pool
- add command functionality
- add vertex and index pools to lithium (static and not threadsafe yet)
- Update GfxDriver Matrix with SetViewPort
- Add glfw (only dependency of gfx_test) maybe later required for input driver
This commit is contained in:
2026-03-16 17:33:46 +01:00
parent 4924d86bc0
commit fe9194b907
20 changed files with 371 additions and 67 deletions

View File

@@ -29,6 +29,7 @@ class PD_API GfxDriver : public DriverInterface {
virtual ~GfxDriver() = default;
virtual void Init() {}
virtual void Deinit() { SysDeinit(); }
void SetViewPort(const ivec2& size);
void SetViewPort(int x, int y);
@@ -93,7 +94,6 @@ class PD_API GfxDriverBase : public GfxDriver {
void Draw(const Pool<Li::Command>& commands) override {
CountCommands += commands.size();
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
size_t index = 0;
while (index < commands.size()) {
CurrentTex = commands[index].Tex;
@@ -144,6 +144,22 @@ class PD_API Gfx {
driver = std::make_unique<T>(std::forward<Args>(args)...);
}
static void Init() { driver->Init(); }
static void Deinit() { driver->Deinit(); }
static void SetViewPort(const ivec2& vp) { driver->SetViewPort(vp); }
static void SetViewPort(int w, int h) { driver->SetViewPort(w, h); }
static void Reset() { driver->Reset(); }
static void Draw(const Pool<Li::Command>& commands) {
driver->Draw(commands);
}
static TextureID LoadTexture(const std::vector<PD::u8>& pixels, int w, int h,
TextureFormat type = TextureFormat::RGBA32,
TextureFilter filter = TextureFilter::Linear) {
return driver->LoadTexture(pixels, w, h, type, filter);
}
static const char* GetDriverName() { return driver->GetName(); }
private:
static std::unique_ptr<GfxDriver> driver;
};