moved library to different project

This commit is contained in:
Lauchmelder 2021-12-23 00:52:28 +01:00
parent 4dc3079fe8
commit f5996f0614
24 changed files with 25 additions and 6467 deletions

View file

@ -8,8 +8,7 @@ struct GLFWwindow;
struct WindowData
{
Camera* camera;
OrthogonalCamera* orthoCam;
lol::Camera* camera;
};
class Application

View file

@ -1,6 +1,7 @@
add_executable(visualizer
"main.cpp" "Application.cpp"
"Plot3D.cpp" "OrbitingCamera.cpp")
"Plot3D.cpp" "OrbitingCamera.cpp"
)
target_sources(visualizer PUBLIC
${VENDOR_DIR}/imgui/backends/imgui_impl_opengl3.cpp
@ -15,10 +16,10 @@ target_sources(visualizer PUBLIC
target_include_directories(visualizer PRIVATE
${GLFW3_INCLUDE_DIRS}
${VENDOR_DIR}/imgui
backend
lol
)
target_link_libraries(visualizer PRIVATE
${GLFW3_LIBRARIES}
backend
lol
)

View file

@ -1,8 +1,8 @@
#pragma once
#include "backend/Camera.hpp"
#include <lol/lol.hpp>
class OrbitingCamera : public Camera
class OrbitingCamera : public lol::Camera
{
public:
OrbitingCamera() {}

View file

@ -4,8 +4,7 @@
#include <array>
#include <iostream>
#include "backend/Camera.hpp"
#include "backend/ObjectManager.hpp"
#include <lol/lol.hpp>
#include "Util.hpp"
inline float Map(const glm::vec2& from, const glm::vec2& to, float val)
@ -25,7 +24,7 @@ inline float Map(const glm::vec2& from, const glm::vec2& to, float val)
*
* @return Number of vertices per slice in the plot
*/
unsigned int CreateVertexList(const BBox& domainAndRange, float scale, float resolution, PlottableFunction func, std::vector<std::optional<unsigned int>>& functionValues, std::vector<float>& vertices);
unsigned int CreateVertexList(const lol::BBox& domainAndRange, float scale, float resolution, PlottableFunction func, std::vector<std::optional<unsigned int>>& functionValues, std::vector<float>& vertices);
/**
* Triangulate the set of vertices to create the plot
@ -36,7 +35,7 @@ unsigned int CreateVertexList(const BBox& domainAndRange, float scale, float res
*/
void Triangulate(const std::vector<std::optional<unsigned int>>& functionValues, unsigned int sliceLength, std::vector<unsigned int>& indices);
Plot3D::Plot3D(const BBox& domainAndRange, float scale, float resolution, PlottableFunction func)
Plot3D::Plot3D(const lol::BBox& domainAndRange, float scale, float resolution, PlottableFunction func)
{
// magic epsilon
if (resolution < 0.0001f) return;
@ -49,17 +48,17 @@ Plot3D::Plot3D(const BBox& domainAndRange, float scale, float resolution, Plotta
unsigned int sliceLength = CreateVertexList(domainAndRange, scale, resolution, func, functionValues, vertices);
Triangulate(functionValues, sliceLength, indices);
vao = VAOFactory::Produce(vertices, indices,
vao = lol::VAOFactory::Produce(vertices, indices,
{
{ 3, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)0 },
{ 1, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(3 * sizeof(float))}
}
);
shader = ShaderManager::GetInstance().Get(PLOT3D_ID);
shader = lol::ShaderManager::GetInstance().Get(PLOT3D_ID);
if (shader == nullptr)
{
shader = ShaderFactory::Produce(
shader = lol::ShaderFactory::Produce(
R"(
#version 440 core
@ -92,18 +91,18 @@ Plot3D::Plot3D(const BBox& domainAndRange, float scale, float resolution, Plotta
)"
);
ShaderManager::GetInstance().Register(PLOT3D_ID, shader);
lol::ShaderManager::GetInstance().Register(PLOT3D_ID, shader);
}
}
void Plot3D::PreRender(const CameraBase& camera) const
void Plot3D::PreRender(const lol::CameraBase& camera) const
{
shader->SetUniform("model", transformation);
shader->SetUniform("view", camera.GetView());
shader->SetUniform("projection", camera.GetProjection());
}
unsigned int CreateVertexList(const BBox& domainAndRange, float scale, float resolution, PlottableFunction func, std::vector<std::optional<unsigned int>>& functionValues, std::vector<float>& vertices)
unsigned int CreateVertexList(const lol::BBox& domainAndRange, float scale, float resolution, PlottableFunction func, std::vector<std::optional<unsigned int>>& functionValues, std::vector<float>& vertices)
{
unsigned int sliceLength = 0;

View file

@ -2,18 +2,16 @@
#include <functional>
#include "backend/Drawable.hpp"
#include "backend/Transformable.hpp"
#include "backend/BoundingBox.hpp"
#include <lol/lol.hpp>
typedef std::function<float(float, float)> PlottableFunction;
class Plot3D :
public Transformable, public Drawable
public lol::Transformable, public lol::Drawable
{
public:
Plot3D(const BBox& domainAndRange, float scale, float resolution, PlottableFunction func);
Plot3D(const lol::BBox& domainAndRange, float scale, float resolution, PlottableFunction func);
private:
void PreRender(const CameraBase& camera) const override;
void PreRender(const lol::CameraBase& camera) const override;
};