Files
palladium/source/drivers/gfx.cpp
T

53 lines
1.5 KiB
C++
Raw Normal View History

2026-03-16 15:19:12 +01:00
#include <pd/drivers/gfx.hpp>
2026-03-18 09:31:47 +01:00
#include <pd/lithium/formatters.hpp>
2026-03-16 15:19:12 +01:00
namespace PD {
PD_API std::unique_ptr<GfxDriver> Gfx::driver;
2026-03-17 16:47:19 +01:00
PD_API GfxDriver::GfxDriver(std::string_view name) : DriverInterface(name) {}
2026-03-16 15:19:12 +01:00
2026-03-18 09:31:47 +01:00
PD_API GfxDriver::~GfxDriver() {
if (pTextureRegestry.size()) {
PDERR("GfxDriver: {} is still holding {} texture{}!", GetName(),
2026-03-18 09:31:47 +01:00
pTextureRegestry.size(), (pTextureRegestry.size() == 1 ? "" : "s"));
}
}
2026-03-17 16:47:19 +01:00
PD_API void GfxDriver::SetViewPort(const ivec2& size) {
2026-03-16 17:33:46 +01:00
ViewPort = size;
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
}
2026-03-17 16:47:19 +01:00
2026-03-18 09:31:47 +01:00
PD_API void GfxDriver::SetViewPort(int x, int y) {
2026-03-16 15:19:12 +01:00
ViewPort.x = x;
ViewPort.y = y;
2026-03-16 17:33:46 +01:00
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
2026-03-16 15:19:12 +01:00
}
2026-03-17 16:47:19 +01:00
PD_API void GfxDriver::Reset() {
CountIndices = CurrentIndex;
CountVertices = CurrentVertex;
2026-03-16 15:19:12 +01:00
CurrentVertex = 0;
CurrentIndex = 0;
CountCommands = pCountCommands;
CountDrawcalls = pCountDrawcalls;
pCountCommands = 0;
pCountDrawcalls = 0;
2026-03-16 17:33:46 +01:00
ResetPools();
2026-03-16 15:19:12 +01:00
SysReset();
}
2026-03-18 09:31:47 +01:00
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 {
PDWARN("GfxDriver: WARNING Texture {{ {} }} does not exist in regestry!",
tex);
2026-03-18 09:31:47 +01:00
}
}
2026-03-16 15:19:12 +01:00
} // namespace PD