updated lol library
This commit is contained in:
parent
f2974f0fe6
commit
458fe3f41c
|
@ -31,8 +31,7 @@ void Application::Quit()
|
||||||
{
|
{
|
||||||
delete topology;
|
delete topology;
|
||||||
|
|
||||||
lol::ShaderManager::GetInstance().Cleanup();
|
manager.Clear();
|
||||||
lol::ObjectManager<lol::Texture1D>::GetInstance().Cleanup();
|
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
window = nullptr;
|
window = nullptr;
|
||||||
|
@ -138,7 +137,7 @@ void Application::Init(int width, int height, const std::string& title)
|
||||||
data.camera = &camera;
|
data.camera = &camera;
|
||||||
data.aspectRatio = (float)width / (float)height;
|
data.aspectRatio = (float)width / (float)height;
|
||||||
|
|
||||||
topology = new Topology(glm::vec2(15.0f, 7.5f), glm::uvec2(200, 100));
|
topology = new Topology(manager, glm::vec2(15.0f, 7.5f), glm::uvec2(200, 100));
|
||||||
glm::uvec2 size = topology->GetSize();
|
glm::uvec2 size = topology->GetSize();
|
||||||
|
|
||||||
float* pixels = topology->GetTopology();
|
float* pixels = topology->GetTopology();
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
private:
|
private:
|
||||||
GLFWwindow* window = nullptr;
|
GLFWwindow* window = nullptr;
|
||||||
WindowData data;
|
WindowData data;
|
||||||
|
lol::ObjectManager manager;
|
||||||
|
|
||||||
OrbitingCamera camera;
|
OrbitingCamera camera;
|
||||||
float pitch, yaw, distance;
|
float pitch, yaw, distance;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "Util.hpp"
|
#include "Util.hpp"
|
||||||
#include "Colormaps.hpp"
|
#include "Colormaps.hpp"
|
||||||
|
|
||||||
Topology::Topology(const glm::vec2& size, const glm::uvec2& subdivisions) :
|
Topology::Topology(lol::ObjectManager& manager, const glm::vec2& size, const glm::uvec2& subdivisions) :
|
||||||
texture(nullptr)
|
texture(nullptr), manager(manager)
|
||||||
{
|
{
|
||||||
// Create VAO
|
// Create VAO
|
||||||
vao = std::make_shared<lol::VertexArray>();
|
vao = std::make_shared<lol::VertexArray>();
|
||||||
|
@ -52,10 +52,13 @@ Topology::Topology(const glm::vec2& size, const glm::uvec2& subdivisions) :
|
||||||
vao->SetElementBuffer(elementBuffer);
|
vao->SetElementBuffer(elementBuffer);
|
||||||
|
|
||||||
// Set up shader
|
// Set up shader
|
||||||
shader = lol::ShaderManager::GetInstance().Get(TOPOLOGY_ID);
|
try
|
||||||
if (shader == nullptr)
|
|
||||||
{
|
{
|
||||||
shader = std::make_shared<lol::Shader>(
|
shader = manager.Get<lol::Shader>(TOPOLOGY_ID);
|
||||||
|
}
|
||||||
|
catch(const lol::ObjectNotFoundException& ex)
|
||||||
|
{
|
||||||
|
shader = manager.Create<lol::Shader>(TOPOLOGY_ID,
|
||||||
R"(
|
R"(
|
||||||
#version 460 core
|
#version 460 core
|
||||||
|
|
||||||
|
@ -103,8 +106,6 @@ Topology::Topology(const glm::vec2& size, const glm::uvec2& subdivisions) :
|
||||||
}
|
}
|
||||||
)"
|
)"
|
||||||
);
|
);
|
||||||
|
|
||||||
lol::ShaderManager::GetInstance().Register(TOPOLOGY_ID, shader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate image
|
// Generate image
|
||||||
|
@ -119,8 +120,7 @@ Topology::Topology(const glm::vec2& size, const glm::uvec2& subdivisions) :
|
||||||
|
|
||||||
Topology::~Topology()
|
Topology::~Topology()
|
||||||
{
|
{
|
||||||
lol::ShaderManager::GetInstance().CleanupUnused();
|
manager.ClearUnused();
|
||||||
lol::ObjectManager<lol::Texture1D>::GetInstance().CleanupUnused();
|
|
||||||
|
|
||||||
if (texture != nullptr)
|
if (texture != nullptr)
|
||||||
delete texture;
|
delete texture;
|
||||||
|
@ -146,15 +146,18 @@ void Topology::PreRender(const lol::CameraBase& camera)
|
||||||
|
|
||||||
void Topology::SetColormap(const Colormap& cm)
|
void Topology::SetColormap(const Colormap& cm)
|
||||||
{
|
{
|
||||||
colormap = lol::ObjectManager<lol::Texture1D>::GetInstance().Get(cm.id);
|
colormap = manager.Get<lol::Texture1D>(cm.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Topology::RegisterColormap(const Colormap& cm)
|
void Topology::RegisterColormap(const Colormap& cm)
|
||||||
{
|
{
|
||||||
std::shared_ptr<lol::Texture1D> texColormap = lol::ObjectManager<lol::Texture1D>::GetInstance().Get(cm.id);
|
try
|
||||||
if(texColormap == nullptr)
|
|
||||||
{
|
{
|
||||||
texColormap = std::make_shared<lol::Texture1D>(
|
manager.Get<lol::Texture1D>(cm.id);
|
||||||
|
}
|
||||||
|
catch(const lol::ObjectNotFoundException& e)
|
||||||
|
{
|
||||||
|
std::shared_ptr<lol::Texture1D> colormap = manager.Create<lol::Texture1D>(cm.id,
|
||||||
cm.data.size() / 3,
|
cm.data.size() / 3,
|
||||||
cm.data.data(),
|
cm.data.data(),
|
||||||
lol::PixelFormat::RGB,
|
lol::PixelFormat::RGB,
|
||||||
|
@ -162,9 +165,7 @@ void Topology::RegisterColormap(const Colormap& cm)
|
||||||
lol::TextureFormat::RGB32F
|
lol::TextureFormat::RGB32F
|
||||||
);
|
);
|
||||||
|
|
||||||
texColormap->SetWrap(lol::TextureWrap::ClampToEdge, lol::TextureWrap::Repeat);
|
colormap->SetWrap(lol::TextureWrap::ClampToEdge, lol::TextureWrap::Repeat);
|
||||||
|
|
||||||
lol::ObjectManager<lol::Texture1D>::GetInstance().Register(cm.id, texColormap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ inline float Map(const glm::vec2& from, const glm::vec2& to, float val)
|
||||||
class Topology : public lol::Drawable
|
class Topology : public lol::Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Topology(const glm::vec2& size, const glm::uvec2& subdivision);
|
Topology(lol::ObjectManager& manager, const glm::vec2& size, const glm::uvec2& subdivision);
|
||||||
~Topology();
|
~Topology();
|
||||||
|
|
||||||
void PreRender(const lol::CameraBase& camera) override;
|
void PreRender(const lol::CameraBase& camera) override;
|
||||||
|
@ -32,6 +32,8 @@ private:
|
||||||
private:
|
private:
|
||||||
lol::Image image;
|
lol::Image image;
|
||||||
lol::Texture2D* texture;
|
lol::Texture2D* texture;
|
||||||
|
|
||||||
|
lol::ObjectManager& manager;
|
||||||
std::shared_ptr<lol::Texture1D> colormap;
|
std::shared_ptr<lol::Texture1D> colormap;
|
||||||
|
|
||||||
float offset = 0.0f;
|
float offset = 0.0f;
|
||||||
|
|
2
vendor/lol
vendored
2
vendor/lol
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit e23d22153c88822a2a15e798ad2643fdcbdf6dc3
|
Subproject commit 967bf6b161b7082e4e68f4a79330039cfc9c5569
|
Loading…
Reference in a new issue