Work at 3ds support and backend upgrades

- Track textures (not sure if this is done tbh)
- Add lithium formatters and move TextureID, TextureFormat and TextureFilter to lithium
- Only include gl-helper if any glDriver is included
- Add Li::Rect for UV stuff
- Add Li::Texture as Info holder (still thinking of making them to ptrs
- Add Check if textures are still loaded on exit
This commit is contained in:
2026-03-18 09:31:47 +01:00
parent d4c59e5b61
commit e04046720b
28 changed files with 791 additions and 243 deletions

24
source/drivers/gfx.cpp Executable file → Normal file
View File

@@ -1,16 +1,24 @@
#include <pd/drivers/gfx.hpp>
#include <pd/lithium/formatters.hpp>
namespace PD {
PD_API std::unique_ptr<GfxDriver> Gfx::driver;
PD_API GfxDriver::GfxDriver(std::string_view name) : DriverInterface(name) {}
PD_API GfxDriver::~GfxDriver() {
if (pTextureRegestry.size()) {
PDLOG("GfxDriver: {} is still holding {} texture{}!", GetName(),
pTextureRegestry.size(), (pTextureRegestry.size() == 1 ? "" : "s"));
}
}
PD_API void GfxDriver::SetViewPort(const ivec2& size) {
ViewPort = size;
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
}
PD_API void GfxDriver::SetViewPort(int x, int y) {
PD_API void GfxDriver::SetViewPort(int x, int y) {
ViewPort.x = x;
ViewPort.y = y;
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
@@ -22,4 +30,18 @@ PD_API void GfxDriver::Reset() {
ResetPools();
SysReset();
}
PD_API void GfxDriver::RegisterTexture(const Li::Texture& tex) {
pTextureRegestry[tex.GetID()] = tex;
}
PD_API void GfxDriver::UnregisterTexture(const Li::Texture& tex) {
if (pTextureRegestry.count(tex.GetID())) {
pTextureRegestry.erase(pTextureRegestry.find(tex.GetID()));
PDLOG("GfxDriver: Texture {{ {} }} has been deleted!", tex);
} else {
PDLOG("GfxDriver: WARNING Texture {{ {} }} does not exist in regestry!",
tex);
}
}
} // namespace PD

View File

@@ -1,9 +1,6 @@
#include <pd/core/core.hpp>
#include <pd/lithium/pools.hpp>
#include "pd/common.hpp"
#include "pd/core/pool.hpp"
#include "pd/lithium/vertex.hpp"
namespace PD {
namespace Li {
PD::Pool<Vertex> pVtxPool;
@@ -14,7 +11,9 @@ PD_API void InitPools(size_t max_vertices) {
pIdxPool.Init(max_vertices * 2);
}
PD_API Vertex* AllocateVertices(size_t count) { return pVtxPool.Allocate(count); }
PD_API Vertex* AllocateVertices(size_t count) {
return pVtxPool.Allocate(count);
}
PD_API u16* AllocateIndices(size_t count) { return pIdxPool.Allocate(count); }