Commit 28ac8eff authored by Philip Trettner's avatar Philip Trettner

Added camera, geometry, shader sublibs

parent 328a4b02
......@@ -6,3 +6,11 @@ add_library(glow-extras ${GLOW_LINK_TYPE} glow-extras.cc)
# Camera
add_subdirectory(camera)
target_link_libraries(glow-extras PUBLIC glow-extras-camera)
# Shader
add_subdirectory(shader)
target_link_libraries(glow-extras PUBLIC glow-extras-shader)
# Geometry
add_subdirectory(geometry)
target_link_libraries(glow-extras PUBLIC glow-extras-geometry)
......@@ -22,8 +22,8 @@ target_link_libraries(YourLib PUBLIC glow-extras)
# .. or single ones
target_link_libraries(YourLib PUBLIC glow-extras-camera)
target_link_libraries(YourLib PUBLIC glow-extras-mesh)
target_link_libraries(YourLib PUBLIC glow-extras-postprocess)
target_link_libraries(YourLib PUBLIC glow-extras-geometry)
target_link_libraries(YourLib PUBLIC glow-extras-shader)
```
## Sub-libs
......
#include "CameraBase.hh"
using namespace glow::extras;
using namespace glow::camera;
CameraBase::CameraBase()
{
......
......@@ -4,7 +4,7 @@
namespace glow
{
namespace extras
namespace camera
{
/**
* @brief Common interface for cameras
......
......@@ -2,7 +2,7 @@
#include <glm/glm.hpp>
using namespace glow::extras;
using namespace glow::camera;
FixedCamera::FixedCamera()
{
......
......@@ -8,7 +8,7 @@
namespace glow
{
namespace extras
namespace camera
{
/**
* @brief A fixed camera where all attributes are set explicitly except for the near/far plane
......
......@@ -57,7 +57,7 @@ bool isOrthonormalMatrix(const glm::mat3 &_matrix)
}
}
using namespace glow::extras;
using namespace glow::camera;
using namespace std;
GenericCamera::GenericCamera()
......
......@@ -43,7 +43,7 @@
namespace glow
{
namespace extras
namespace camera
{
class GenericCamera : public CameraBase
{
......
cmake_minimum_required(VERSION 3.0)
file(GLOB_RECURSE SOURCE_FILES "*.cc")
file(GLOB_RECURSE HEADER_FILES "*.hh")
add_library(glow-extras-geometry ${GLOW_LINK_TYPE} ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(glow-extras-geometry PUBLIC ./)
target_compile_options(glow-extras-geometry PRIVATE -Wall -Werror -std=c++11)
target_link_libraries(glow-extras-geometry PUBLIC glow)
#include "Quad.hh"
using namespace glow::geometry;
#pragma once
#include <glm/vec2.hpp>
#include <glow/common/shared.hh>
#include <glow/objects/VertexArray.hh>
#include <glow/objects/ArrayBuffer.hh>
namespace glow
{
GLOW_SHARED(class, VertexArray);
namespace geometry
{
/// Builder for a quad (GL_TRIANGLE_STRIP) with 4 vertices
/// VertexT needs a c'tor that can be called with (0, 0) to (1, 1)
///
/// Supported built-in types:
/// vec2
///
/// If you use your custom vertex struct you have 2 options:
/// A: specify all attributes in Quad(...) ctor
/// B: implemented the following function in your VertexT:
/// static std::vector<ArrayBufferAttribute> attributes();
template <typename VertexT>
struct Quad
{
public:
/// List of quad attributes
std::vector<ArrayBufferAttribute> attributes;
public:
Quad(std::vector<ArrayBufferAttribute> const& attrs = attributesOf((VertexT*)0)) : attributes(attrs) {}
/**
* @brief generates a Vertex Array with a single Array Buffer containing quad data
*
* Vertex layout:
* VertexT{0, 0}
* VertexT{0, 1}
* VertexT{1, 0}
* VertexT{1, 1}
*/
SharedVertexArray generate() const
{
auto ab = ArrayBuffer::create();
ab->defineAttributes(attributes);
VertexT data[] = {
{0, 0}, //
{0, 1}, //
{1, 0}, //
{1, 1},
};
ab->bind().setData(data);
return VertexArray::create(ab, nullptr, GL_TRIANGLE_STRIP);
}
public: // Predefined attributes
static std::vector<ArrayBufferAttribute> attributesOf(glm::vec2*)
{
return {ArrayBufferAttribute("aPosition", GL_FLOAT, 2, 0)};
}
static std::vector<ArrayBufferAttribute> attributesOf(void*) { return VertexT::attributes(); }
};
}
}
cmake_minimum_required(VERSION 3.0)
file(GLOB_RECURSE SOURCE_FILES "*.cc")
file(GLOB_RECURSE HEADER_FILES "*.hh")
add_library(glow-extras-shader ${GLOW_LINK_TYPE} ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(glow-extras-shader PUBLIC ./)
target_compile_options(glow-extras-shader PRIVATE -Wall -Werror -std=c++11)
target_link_libraries(glow-extras-shader PUBLIC glow)
#include "Output.hh"
using namespace glow::shader;
Output::Output()
{
}
#pragma once
namespace glow
{
namespace shader
{
class Output
{
public:
Output();
};
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment