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:
6
source/common.cpp
Normal file
6
source/common.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <pd/common.hpp>
|
||||
|
||||
void PD::Log(const std::string& txt) {
|
||||
std::cout << "[PD] " << txt << std::endl;
|
||||
}
|
||||
@@ -5,15 +5,20 @@ PD_API std::unique_ptr<GfxDriver> Gfx::driver;
|
||||
|
||||
GfxDriver::GfxDriver(std::string_view name) : DriverInterface(name) {}
|
||||
|
||||
void GfxDriver::SetViewPort(const ivec2& size) { ViewPort = size; }
|
||||
void GfxDriver::SetViewPort(const ivec2& size) {
|
||||
ViewPort = size;
|
||||
Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void GfxDriver::Reset() {
|
||||
CurrentVertex = 0;
|
||||
CurrentIndex = 0;
|
||||
ResetPools();
|
||||
SysReset();
|
||||
}
|
||||
} // namespace PD
|
||||
26
source/lithium/pools.cpp
Normal file
26
source/lithium/pools.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
PD::Pool<u16> pIdxPool;
|
||||
|
||||
void InitPools(size_t max_vertices) {
|
||||
pVtxPool.Init(max_vertices);
|
||||
pIdxPool.Init(max_vertices * 2);
|
||||
}
|
||||
|
||||
Vertex* AllocateVertices(size_t count) { return pVtxPool.Allocate(count); }
|
||||
|
||||
u16* AllocateIndices(size_t count) { return pIdxPool.Allocate(count); }
|
||||
|
||||
void ResetPools() {
|
||||
pVtxPool.Reset();
|
||||
pIdxPool.Reset();
|
||||
}
|
||||
} // namespace Li
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user