minor cleanup

This commit is contained in:
Hartmut Seichter 2024-07-31 23:34:25 +02:00
parent 1fb8d25b31
commit b564c2b87c
19 changed files with 229 additions and 330 deletions

View file

@ -8,5 +8,6 @@ Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
AlignConsecutiveAssignments: true
LambdaBodyIndentation: OuterScope
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: true

View file

@ -3,9 +3,9 @@ add_subdirectory(deps)
# build internal core
add_subdirectory(core)
add_subdirectory(scene)
# add_subdirectory(scene)
# add_subdirectory(system)
# add_subdirectory(io)
add_subdirectory(io)
#add_subdirectory(ui)
# add_subdirectory(binding)

View file

@ -6,10 +6,10 @@ set(hdrs
set(srcs
src/script.cpp
src/script_core.cpp
# src/script_system.cpp
# src/script_io.cpp
# src/script_scene.cpp
# src/script_visual.cpp
src/script_system.cpp
src/script_io.cpp
src/script_scene.cpp
src/script_visual.cpp
src/runtime_lua.hpp
src/runtime_lua.cpp
)

View file

@ -41,26 +41,19 @@ void register_core_function(sol::state& lua, sol::table& ns) {
ns.set("pi", pw::pi<float>());
// clang-format off
ns.new_usertype<color>(
"color", sol::call_constructor,sol::constructors<color()>(),
"rgba", &color::rgba,
"data", sol::property([](color& c) { return c.rgba.data(); }),
"table",
sol::property(
[](const color& c) {
return sol::as_table(
std::array<vector4f::value_type, 4>{
c.rgba.x(), c.rgba.y(), c.rgba.z(), c.rgba.w()});
},
[](color& c,const sol::table& t) {
c = color{.rgba = vector4f{t[0], t[1], t[2], t[3]}};
})
);
// clang-format on
"color", sol::call_constructor, sol::constructors<color()>(), //
"rgba", &color::rgba, //
"data", sol::property([](color& c) { return c.rgba.data(); }), //
"table",
sol::property([](const color& c) { //
return sol::as_table(std::array<vector4f::value_type, 4>{
c.rgba.x(), c.rgba.y(), c.rgba.z(), c.rgba.w()});
}, [](color& c, const sol::table& t) {
c = color{
.rgba = vector4f{t[0], t[1], t[2], t[3]}
};
}));
#if 0

View file

@ -23,6 +23,7 @@
#ifndef PW_CORE_AABB_HPP
#define PW_CORE_AABB_HPP
#include "primitives.hpp"
#include <pw/core/vector.hpp>
#include <numeric>

View file

@ -269,9 +269,12 @@ constexpr auto operator*(const matrix<ScalarA, Ra, Ca>& A,
}
//
// type aliases
// deduction guides
//
//
// type aliases
//
template <typename Scalar> using matrix2x2 = matrix<Scalar, 2, 2>;
template <typename Scalar> using matrix3x3 = matrix<Scalar, 3, 3>;
template <typename Scalar> using matrix4x4 = matrix<Scalar, 4, 4>;

View file

@ -23,10 +23,10 @@
#ifndef PW_CORE_MATRIX_TRANSFORM_HPP
#define PW_CORE_MATRIX_TRANSFORM_HPP
#include <pw/core/frustum.hpp>
#include <pw/core/math.hpp>
#include <pw/core/matrix.hpp>
#include <pw/core/vector.hpp>
#include <pw/core/frustum.hpp>
namespace pw {
@ -51,12 +51,12 @@ struct matrix_transform {
const auto C{-(f.z_far + f.z_near) / (f.z_far - f.z_near)};
const auto D{-Scalar{2} * f.z_far * f.z_near / (f.z_far - f.z_near)};
// clang-format off
return {vector{Sx, 0, A, 0},
vector{0, Sy, B, 0},
vector{0, 0, C, D},
vector{0, 0, -1, Scalar{1}}};
// clang-format on
return {
vector{Sx, 0, A, 0 }, //
vector{0, Sy, B, 0 }, //
vector{0, 0, C, D }, //
vector{0, 0, -1, Scalar{1}} //
};
}
template <typename Scalar>

View file

@ -23,6 +23,7 @@
#ifndef PW_CORE_POINT_HPP
#define PW_CORE_POINT_HPP
#include <cstddef>
#include <pw/core/globals.hpp>
#include <pw/core/vector.hpp>

View file

@ -31,7 +31,7 @@
namespace pw {
struct primitives {
struct primitives final {
enum struct topology_type {
point_list,
@ -47,7 +47,10 @@ struct primitives {
patch_list
};
std::vector<vector3<float>> vertices{};
using vertex_type = vector3<float>;
using index_type = std::size_t;
std::vector<vertex_type> vertices{};
std::vector<std::size_t> indices{};
topology_type topology{};
};

View file

@ -28,6 +28,7 @@
#include <cmath>
#include <concepts>
#include <functional>
#include <type_traits>
#include <utility>
namespace pw {
@ -65,6 +66,13 @@ template <typename Scalar, std::size_t N> struct vector final {
return std::forward<decltype(self)>(self).v_[e];
}
template <typename ScalarOut>
constexpr auto cast() const noexcept -> vector<ScalarOut, N> {
return [this]<std::size_t... Ss>(std::index_sequence<Ss...>) {
return vector<ScalarOut, N>{ScalarOut((*this)[Ss])...};
}(std::make_index_sequence<N>{});
}
static constexpr auto basis(const auto& d) noexcept {
return [&d]<std::size_t... Ss>(std::index_sequence<Ss...>) {
return vector{(d == Ss) ? Scalar(1) : Scalar(0)...};
@ -295,8 +303,9 @@ template <typename Scalar, std::size_t N> struct vector final {
//
// deduction guide
//
template <class T, class... U, class CT = std::common_type_t<T, U...>>
vector(T, U...) -> vector<CT, 1 + sizeof...(U)>;
template <class... Scalar>
vector(Scalar&&... s)
-> vector<std::common_type_t<Scalar...>, sizeof...(Scalar)>;
//
// type aliases

View file

@ -13,3 +13,4 @@ make_test(pwcore_test_aabb)
make_test(pwcore_test_frustum)
make_test(pwcore_test_mesh)
make_test(pwcore_test_serialize)
make_test(pwcore_test_image)

View file

@ -0,0 +1,16 @@
#include <cstddef>
#include <map>
#include <pw/core/image.hpp>
namespace pw {
struct image_layout {
enum pixel_layout { RGB8, RGBA, LUM, DEPTH };
};
} // namespace pw
auto main() -> int {
// pw::image
}

View file

@ -70,4 +70,9 @@ auto main() -> int {
std::print("\nm44=[{}]\n", m44);
// auto m_init_ded = pw::matrix{
// {1, 2},
// {3, 4}
// };
}

View file

@ -1,85 +1,40 @@
#include <pw/core/aabb.hpp>
#include <pw/core/axisangle.hpp>
#include <pw/core/formatter.hpp>
#include <pw/core/matrix_transform.hpp>
#include <pw/core/mesh.hpp>
#include <pw/core/primitives.hpp>
#include <pw/core/serialize.hpp>
#include <pw/core/vector.hpp>
#include <pw/core/mesh.hpp>
#include <print>
#include <variant>
#include <vector>
namespace pw {
} // namespace pw
namespace pw {} // namespace pw
auto main() -> int {
auto geom = pw::primitives{
.vertices = {{1.2f, 2.4f, 4.8f},
{2.4f, 1.2f, 4.8f},
{1.2f, 4.8f, 2.4f}},
.indices = {0, 1, 2},
.topology = pw::primitives::topology_type::triangle_list};
{1.2f, 4.8f, 2.4f} },
.indices = {0, 1, 2},
.topology = pw::primitives::topology_type::triangle_list
};
auto mesh = pw::mesh{.geometry = geom};
mesh.attributes.emplace_back(
pw::attribute{.type = pw::attribute::normals,
.data = std::vector{
pw::vector{1.2f, 2.4f, 4.8f}}});
.data = std::vector{pw::vector{1.2f, 2.4f, 4.8f}}});
for (auto i : geom.indices) {
std::print("({}) ", pw::serialize::to_string(geom.vertices[i]));
std::print("vertex[{}]({})\n", i, geom.vertices[i]);
}
// pw::geometry geo;
auto aabb = pw::aabb<float, 3>::make_from_indexed_vertices(geom.vertices,
geom.indices);
// pw::vector3_array vs = {
// { -1, 1, 0 },
// { -1,-1, 0 },
// { 1,-1, 0 },
// { 1, 1, 0 }
// };
// pw::geometry::indices_t idx = {
// 0, 1, 2,
// 0, 2, 3
// };
// geo.set_vertices(vs);
// geo.set_indices(idx);
// geo.compute_normals();
// amesh.set_vertices(vs);
// for (auto v : amesh.vertices()) {
// std::cout << pw::serialize::matrix(v.transposed()) << std::endl;
// }
// auto scale = pw::matrix_transform<float>::scale_matrix({2,2,2});
// amesh.transform(scale);
// std::cout << "after scale" << std::endl;
// for (auto v : amesh.vertices()) {
// std::cout << pw::serialize::matrix(v.transposed()) << std::endl;
// }
// pw::axisangle aa;
// aa.axis = pw::vector3({ 0, 0, 1 });
// aa.angle = pw::deg_to_rad(90.0f);
// auto rot_mat = aa.to_matrix();
// amesh.transform(rot_mat);
// std::cout << "after rotate" << std::endl;
// for (auto v : amesh.vertices()) {
// std::cout << pw::serialize::matrix(v.transposed()) << std::endl;
// }
std::print("aabb.max = ({}) aabb.min=({})\n", aabb.max, aabb.min);
}

View file

@ -1,21 +1,22 @@
#ifndef PW_GEOMETRY_PRIMITIVES_HPP
#define PW_GEOMETRY_PRIMITIVES_HPP
#include <pw/core/geometry.hpp>
#include <pw/core/primitives.hpp>
namespace pw {
struct primitives {
struct primitives {
static geometry box(real_t size_x, real_t size_y, real_t size_z);
static geometry box(real_t size_x, real_t size_y, real_t size_z);
static geometry sphere(real_t radius,int divisions_latitude,int divisions_longitude);
static geometry sphere(real_t radius, int divisions_latitude,
int divisions_longitude);
static geometry cone();
static geometry pyramid();
};
static geometry cone();
static geometry pyramid();
};
}; // namespace pw
#endif

View file

@ -16,7 +16,6 @@
#include <cstdint>
#include <locale>
namespace pw {
// struct window_context : context
@ -77,8 +76,7 @@ struct window::impl {
static void cursor_pos_callback(GLFWwindow* window, double xpos,
double ypos) {
input::get()._mouse_position =
point<double>(xpos, ypos).cast<int32_t>();
input::get()._mouse_position = vector{xpos, ypos}.cast<int32_t>();
}
static void key_callback(GLFWwindow* window, int key, int scancode,
@ -255,11 +253,11 @@ struct window::impl {
::pw::point<int32_t> position() const {
int x, y;
glfwGetWindowPos(_window, &x, &y);
return ::pw::point<int32_t>(x, y);
return {x, y};
}
void set_position(const point<int32_t>& p) {
glfwSetWindowPos(_window, p.x, p.y);
glfwSetWindowPos(_window, p.x(), p.y());
}
void set_fullscreen(bool use_fullscreen) {
@ -267,7 +265,7 @@ struct window::impl {
return;
if (use_fullscreen) {
glfwGetWindowPos(_window, &_old_pos.x, &_old_pos.y);
glfwGetWindowPos(_window, &_old_pos.x(), &_old_pos.y());
glfwGetWindowSize(_window, &_old_size.width, &_old_size.height);
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
@ -278,7 +276,7 @@ struct window::impl {
} else {
glfwSetWindowMonitor(_window, nullptr, _old_pos.x, _old_pos.y,
glfwSetWindowMonitor(_window, nullptr, _old_pos.x(), _old_pos.y(),
_old_size.width, _old_size.height, 0);
}

View file

@ -1,52 +1,42 @@
#ifndef PW_VISUAL_PIPELINE_HPP
#define PW_VISUAL_PIPELINE_HPP
#include <pw/core/size.hpp>
#include <pw/core/matrix.hpp>
#include <pw/core/geometry.hpp>
#include <pw/core/color.hpp>
#include <pw/core/matrix.hpp>
#include <pw/core/primitives.hpp>
#include <pw/core/size.hpp>
#include <pw/visual/shader.hpp>
#include <pw/visual/renderer.hpp>
#include <pw/visual/shader.hpp>
#include <map>
namespace pw {
class pipeline {
public:
pipeline();
public:
pipeline();
~pipeline();
void draw();
bool create(size s);
protected:
struct impl;
std::unique_ptr<impl> _impl;
bool create(size s);
protected:
struct impl;
std::unique_ptr<impl> _impl;
};
struct render_pass {
void submit(const geometry& g,
const matrix4x4& model_mat,
const matrix4x4& view_mat,
const matrix4x4& projection_mat);
void submit(const geometry& g, const matrix4x4& model_mat,
const matrix4x4& view_mat, const matrix4x4& projection_mat);
shader _shader;
renderer _renderer;
};
}
} // namespace pw
#endif

View file

@ -4,89 +4,58 @@
#include "glad/glad.h"
#include <cstdint>
namespace pw {
struct context::impl {
vector4f _clear_color { 0, 1, 0, 1};
vector4f _clear_color{0, 1, 0, 1};
void set_viewport(const rectangle<int32_t>& v)
{
glViewport(v.position.x,v.position.y,v.size.width,v.size.height);
void set_viewport(const rectangle<int32_t>& v) {
glViewport(v.position.x(), v.position.y(), v.size.width, v.size.height);
}
const rectangle<int32_t> viewport()
{
auto vp = rectangle<float>{0,0,1,1};
glGetFloatv(GL_VIEWPORT,static_cast<float*>(&vp.position.x));
const rectangle<int32_t> viewport() {
auto vp = rectangle<float>{0, 0, 1, 1};
glGetFloatv(GL_VIEWPORT, vp.position.data());
return vp.cast<int32_t>();
}
void clear()
{
void clear() {
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glClearColor(_clear_color[0],_clear_color[1],_clear_color[2],_clear_color[3]);
glClearColor(_clear_color[0], _clear_color[1], _clear_color[2],
_clear_color[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
uint32_t get_error() const
{
return glGetError();
}
uint32_t get_error() const { return glGetError(); }
};
context::context()
: _impl(std::make_unique<impl>())
{
}
context::context() : _impl(std::make_unique<impl>()) {}
context::~context()
{
}
context::~context() {}
void context::set_blend()
{
void context::set_blend() {}
}
void context::set_viewport(const rectangle<int32_t>& v)
{
void context::set_viewport(const rectangle<int32_t>& v) {
_impl->set_viewport(v);
}
rectangle<int32_t> context::viewport() const
{
return _impl->viewport();
}
rectangle<int32_t> context::viewport() const { return _impl->viewport(); }
void context::clear()
{
_impl->clear();
}
void context::clear() { _impl->clear(); }
u_int32_t context::get_error() const
{
return _impl->get_error();
}
u_int32_t context::get_error() const { return _impl->get_error(); }
color context::clearcolor() const
{
color context::clearcolor() const {
// return _impl->_clear_color;
return color{};
}
void context::set_clearcolor(const color& c)
{
void context::set_clearcolor(const color& c) {
// _impl->_clear_color = c;
}
}
} // namespace pw

View file

@ -1,30 +1,26 @@
#include "pw/core/size.hpp"
#include "pw/core/matrix.hpp"
#include "pw/core/geometry.hpp"
#include "pw/core/time.hpp"
#include "pw/core/axisangle.hpp"
#include "pw/core/serialize.hpp"
#include "pw/core/geometry.hpp"
#include "pw/core/matrix.hpp"
#include "pw/core/matrix_transform.hpp"
#include "pw/core/serialize.hpp"
#include "pw/core/size.hpp"
#include "pw/core/time.hpp"
#include "pw/core/debug.hpp"
#include "pw/visual/pipeline.hpp"
#include "pw/visual/shader.hpp"
#include "pw/visual/renderer.hpp"
#include "pw/visual/framebuffer.hpp"
#include "pw/visual/pipeline.hpp"
#include "pw/visual/renderer.hpp"
#include "pw/visual/shader.hpp"
#include "pw/visual/texture.hpp"
#include "glad/glad.h"
namespace pw {
void render_pass::submit(const geometry &g,
const matrix4x4 &model_mat,
const matrix4x4 &view_mat,
const matrix4x4 &projection_mat)
{
if (!_shader.ready())
{ //
void render_pass::submit(const geometry& g, const matrix4x4& model_mat,
const matrix4x4& view_mat,
const matrix4x4& projection_mat) {
if (!_shader.ready()) { //
_shader.build();
}
@ -35,22 +31,18 @@ void render_pass::submit(const geometry &g,
// new version with ...
shader::uniform_cache_t us;
// us.push_back(std::make_tuple("input_color",mat._color,-1));
us.push_back(std::make_tuple("model",model_mat,-1));
us.push_back(std::make_tuple("view",view_mat,-1));
us.push_back(std::make_tuple("projection",projection_mat,-1));
// us.push_back(std::make_tuple("input_color",mat._color,-1));
us.push_back(std::make_tuple("model", model_mat, -1));
us.push_back(std::make_tuple("view", view_mat, -1));
us.push_back(std::make_tuple("projection", projection_mat, -1));
_shader.set_uniforms(us);
_shader.use();
_renderer.draw();
}
struct triangle_renderer
{
struct triangle_renderer {
texture tex;
shader shader_p;
@ -58,15 +50,12 @@ struct triangle_renderer
renderer r;
time::tick_t tick;
triangle_renderer()
{
}
triangle_renderer() {}
void setup()
{
void setup() {
const float z_val = -5.f;
const float s = 1.0f;
const float s = 1.0f;
//
// 0 -- 1
@ -75,23 +64,23 @@ struct triangle_renderer
// geometry
vector3_array vertices = {
{-s, s, z_val} // 0
,{ s, s, z_val} // 1
,{-s, -s, z_val} // 2
,{ s, -s, z_val} // 3
{-s, s, z_val} // 0
,
{s, s, z_val} // 1
,
{-s, -s, z_val} // 2
,
{s, -s, z_val} // 3
};
// topology / indices
geometry::indices_t indices = { 2, 1, 0,
2, 3, 1};
geometry::indices_t indices = {2, 1, 0, 2, 3, 1};
amesh.set_indices(indices);
amesh.set_vertices(vertices);
amesh.compute_normals();
const char* vertex_shader_2 = R"(
#version 400
uniform mat4 model;
@ -106,7 +95,7 @@ struct triangle_renderer
}
)";
const char *fragment_shader_2 = R"(
const char* fragment_shader_2 = R"(
#version 400
uniform vec4 input_color = vec4(1.0, 0.0, 0.0, 1.0);
out vec4 frag_colour;
@ -114,38 +103,37 @@ struct triangle_renderer
frag_colour = input_color;
})";
shader_p.set_source(shader::code_type::vertex,vertex_shader_2);
shader_p.set_source(shader::code_type::fragment,fragment_shader_2);
shader_p.set_source(shader::code_type::vertex, vertex_shader_2);
shader_p.set_source(shader::code_type::fragment, fragment_shader_2);
if (!shader_p.build())
exit(-1);
}
void draw()
{
void draw() {
if (!r.ready())
r.create(amesh);
// input needed here -
// model view projection
shader_p.use();
auto v_col = ping_pong(static_cast<float>(time::now()),1.0f);
auto v_col = ping_pong(static_cast<float>(time::now()), 1.0f);
vector4f col = {0.5f,1-v_col,v_col,1.0f};
vector4f col = {0.5f, 1 - v_col, v_col, 1.0f};
matrix4x4f model_mat; model_mat.set_identity();
matrix4x4f model_mat;
model_mat.set_identity();
auto v_angle = ping_pong(static_cast<float>(time::now()),2 * ::pw::pi<float>());
auto v_angle =
ping_pong(static_cast<float>(time::now()), 2 * ::pw::pi<float>());
axisangle rot(vector3::forward(),v_angle);
axisangle rot(vector3::forward(), v_angle);
model_mat = rot.to_matrix();
matrix4x4f view_mat = matrix_transform<float>::look_at(vector3({0,0,0}),
vector3::forward(),
vector3::up());
matrix4x4f view_mat = matrix_transform<float>::look_at(
vector3({0, 0, 0}), vector3::forward(), vector3::up());
// materials should carry this
#if 1
@ -154,35 +142,31 @@ struct triangle_renderer
glFrontFace(GL_CCW);
#endif
// now bind textures
#if 1
auto proj_mat = matrix_transform<float>::orthographic_projection(1.3,1.0,
0.2f,100.f);
auto proj_mat = matrix_transform<float>::orthographic_projection(
1.3, 1.0, 0.2f, 100.f);
#else
auto proj_mat = matrix_transform<float>::perspective_projection(deg_to_rad(60.f),
1.3f,
0.2f,1000.f);
auto proj_mat = matrix_transform<float>::perspective_projection(
deg_to_rad(60.f), 1.3f, 0.2f, 1000.f);
#endif
#if 1
// highly inefficient - should be cached -
shader_p.set_uniform("input_color",col);
shader_p.set_uniform("model",model_mat);
shader_p.set_uniform("view",view_mat);
shader_p.set_uniform("projection",proj_mat);
shader_p.set_uniform("input_color", col);
shader_p.set_uniform("model", model_mat);
shader_p.set_uniform("view", view_mat);
shader_p.set_uniform("projection", proj_mat);
#else
// new version with ...
shader::uniform_cache_t us;
us.push_back(std::make_tuple("input_color",col,-1));
us.push_back(std::make_tuple("model",model_mat,-1));
us.push_back(std::make_tuple("view",view_mat,-1));
us.push_back(std::make_tuple("projection",proj_mat,-1));
us.push_back(std::make_tuple("input_color", col, -1));
us.push_back(std::make_tuple("model", model_mat, -1));
us.push_back(std::make_tuple("view", view_mat, -1));
us.push_back(std::make_tuple("projection", proj_mat, -1));
shader_p.set_uniforms(us);
@ -191,7 +175,7 @@ struct triangle_renderer
r.draw();
auto error = glGetError();
if (error != GL_NO_ERROR){
if (error != GL_NO_ERROR) {
debug::e() << "GL error " << error;
}
@ -199,7 +183,6 @@ struct triangle_renderer
}
};
struct pipeline::impl {
#if 0
@ -214,35 +197,30 @@ struct pipeline::impl {
framebuffer fb;
//testing
// testing
triangle_renderer tr;
bool create(size s);
void draw();
impl() = default;
impl() = default;
~impl() = default;
};
GLuint generate_multisample_texture(const size& s,int samples)
{
GLuint generate_multisample_texture(const size& s, int samples) {
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_RGB8, s.width, s.height, GL_TRUE);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_RGB8,
s.width, s.height, GL_TRUE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
return texture;
}
bool pipeline::impl::create(::pw::size s)
{
bool pipeline::impl::create(::pw::size s) {
#if 0
_size = s;
@ -293,23 +271,14 @@ bool pipeline::impl::create(::pw::size s)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
#endif
tr.setup();
return true;
}
void pipeline::impl::draw() {
void pipeline::impl::draw()
{
glClearColor(1.0,0,0,1);
glClearColor(1.0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glViewport(0,0,800,600);
@ -320,12 +289,8 @@ void pipeline::impl::draw()
tr.draw();
// reset
// actuall blitting
#if 0
@ -346,7 +311,6 @@ void pipeline::impl::draw()
#else
#if 0
glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo_msaa); // src FBO (multi-sample)
@ -372,87 +336,76 @@ void pipeline::impl::draw()
// fb.unbind();
GLenum err;
while((err = glGetError()) != GL_NO_ERROR)
{
while ((err = glGetError()) != GL_NO_ERROR) {
std::string error;
switch(err) {
case GL_INVALID_OPERATION: error="INVALID_OPERATION"; break;
case GL_INVALID_ENUM: error="INVALID_ENUM"; break;
case GL_INVALID_VALUE: error="INVALID_VALUE"; break;
case GL_OUT_OF_MEMORY: error="OUT_OF_MEMORY"; break;
case GL_INVALID_FRAMEBUFFER_OPERATION: error="INVALID_FRAMEBUFFER_OPERATION"; break;
switch (err) {
case GL_INVALID_OPERATION:
error = "INVALID_OPERATION";
break;
case GL_INVALID_ENUM:
error = "INVALID_ENUM";
break;
case GL_INVALID_VALUE:
error = "INVALID_VALUE";
break;
case GL_OUT_OF_MEMORY:
error = "OUT_OF_MEMORY";
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
error = "INVALID_FRAMEBUFFER_OPERATION";
break;
}
debug::e() << "OpenGL error:" << err << " " << error;
}
}
//
//
//
pipeline::pipeline()
: _impl(std::make_unique<pipeline::impl>())
{
}
pipeline::pipeline() : _impl(std::make_unique<pipeline::impl>()) {}
pipeline::~pipeline()
{
pipeline::~pipeline() {
//
}
void pipeline::draw()
{
_impl->draw();
}
void pipeline::draw() { _impl->draw(); }
bool pipeline::create(size s)
{
return _impl->create(s.cast<int>());
}
bool pipeline::create(size s) { return _impl->create(s.cast<int>()); }
}
} // namespace pw
// class pipeline;
//class pipeline;
//class pass
// class pass
//{
//public:
// public:
// virtual void apply(pipeline& p);
//};
// };
//class pipeline
// class pipeline
//{
//public:
// public:
// void apply()
// {
// for (auto p : _passes) p.apply(*this);
// }
//protected:
// protected:
// std::vector<pass> _passes;
//};
// };
//pipeline >
// pipeline >
// n*pass
// shadow_pass
// lighting_pass
// lighting_pass
// mesh_pass
// compositor_pass
//compositor
// render to fbo > add a
// glBlitFramebuffer .. https://stackoverflow.com/questions/29254574/using-glblitframebuffer-to-display-a-texture
// compositor
// render to fbo > add a
// glBlitFramebuffer ..
// https://stackoverflow.com/questions/29254574/using-glblitframebuffer-to-display-a-texture