From d1e4fd9b5364af6b66051b6ef6ad2ae8b8745350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20=C3=9Cbelh=C3=B6r?= <tim.uebelhoer@irt.rwt-aachen.de> Date: Mon, 4 Mar 2019 23:18:53 +0100 Subject: [PATCH] several addition for binding resources --- include/scigl_render/buffer/texture2d.hpp | 7 +++++++ include/scigl_render/render/depth_simulator.hpp | 10 +++++----- include/scigl_render/render/rasterizer.hpp | 6 +++--- src/buffer/texture2d.cpp | 5 +++++ src/render/depth_simulator.cpp | 6 ++++++ src/render/rasterizer.cpp | 6 +++--- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/scigl_render/buffer/texture2d.hpp b/include/scigl_render/buffer/texture2d.hpp index f0abbf7..eed3d93 100644 --- a/include/scigl_render/buffer/texture2d.hpp +++ b/include/scigl_render/buffer/texture2d.hpp @@ -15,6 +15,13 @@ public: /** activates texture_n for use in shaders */ static void activate(GLenum texture_n); + /** + * bind this texture to an image unit for imageLoad + * \param unit the binding unit + * \param access GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE + */ + void bind_image_unit(GLuint unit, GLenum access) const; + /** binds this texture to GL_TEXTURE_2D */ void bind() const; diff --git a/include/scigl_render/render/depth_simulator.hpp b/include/scigl_render/render/depth_simulator.hpp index 2ca2d1f..1bc4543 100644 --- a/include/scigl_render/render/depth_simulator.hpp +++ b/include/scigl_render/render/depth_simulator.hpp @@ -26,11 +26,11 @@ public: int get_height(); // the OpenGL texture needed to render depth values - static const GLenum FORMAT = GL_RED; - static const GLenum TYPE = GL_FLOAT; - static const GLint INTERNAL_FORMAT = GL_R32F; - static const size_t CHANNELS = 1; - static const size_t PIXEL_SIZE = CHANNELS * sizeof(GLfloat); + static const GLenum FORMAT; + static const GLenum TYPE; + static const GLenum INTERNAL_FORMAT; + static const size_t CHANNELS; + static const size_t PIXEL_SIZE; private: // where and how to render diff --git a/include/scigl_render/render/rasterizer.hpp b/include/scigl_render/render/rasterizer.hpp index 4072fd6..d18ec06 100644 --- a/include/scigl_render/render/rasterizer.hpp +++ b/include/scigl_render/render/rasterizer.hpp @@ -42,13 +42,13 @@ public: size_t views_per_column); /** activate a view by its 2D coordinates */ - void activate_view(size_t row, size_t column); + void activate_view(size_t row, size_t column) const; /** as if the rows were concatenated */ - void activate_view(size_t view); + void activate_view(size_t view) const; /** activate the whole texture view, for example when clearing it */ - void activate_all(); + void activate_all() const; /** * Minimal raster size for the given number of views diff --git a/src/buffer/texture2d.cpp b/src/buffer/texture2d.cpp index a820522..51e8183 100644 --- a/src/buffer/texture2d.cpp +++ b/src/buffer/texture2d.cpp @@ -55,6 +55,11 @@ void Texture2D::bind() const glBindTexture(GL_TEXTURE_2D, texture); } +void Texture2D::bind_image_unit(GLuint unit, GLenum access) const +{ + glBindImageTexture(unit, texture, 0, GL_FALSE, 0, access, internal_format); +} + void Texture2D::unbind() const { glBindTexture(GL_TEXTURE_2D, 0); diff --git a/src/render/depth_simulator.cpp b/src/render/depth_simulator.cpp index 92b7109..ab81b41 100644 --- a/src/render/depth_simulator.cpp +++ b/src/render/depth_simulator.cpp @@ -4,6 +4,12 @@ namespace scigl_render { +const GLenum DepthSimulator::FORMAT = GL_RED; +const GLenum DepthSimulator::TYPE = GL_FLOAT; +const GLenum DepthSimulator::INTERNAL_FORMAT = GL_R32F; +const size_t DepthSimulator::CHANNELS = 1; +const size_t DepthSimulator::PIXEL_SIZE = CHANNELS * sizeof(GLfloat); + DepthSimulator::DepthSimulator(scigl_render::CvCamera camera, scigl_render::Model model) : camera(std::move(camera)), diff --git a/src/render/rasterizer.cpp b/src/render/rasterizer.cpp index 0caaaca..6706b6e 100644 --- a/src/render/rasterizer.cpp +++ b/src/render/rasterizer.cpp @@ -17,14 +17,14 @@ Rasterizer::Rasterizer(size_t width, size_t height, size_t views_per_row, set_views_per_column(views_per_column); } -void Rasterizer::activate_view(size_t row, size_t column) +void Rasterizer::activate_view(size_t row, size_t column) const { auto xy = view_xy(row, column); glScissor(xy.first, xy.second, width, height); glViewport(xy.first, xy.second, width, height); } -void Rasterizer::activate_view(size_t view) +void Rasterizer::activate_view(size_t view) const { auto position = view_position(view); size_t row = position.first; @@ -32,7 +32,7 @@ void Rasterizer::activate_view(size_t view) activate_view(position.first, position.second); } -void Rasterizer::activate_all() +void Rasterizer::activate_all() const { glScissor(0, 0, texture_width, texture_height); glViewport(0, 0, texture_width, texture_height); -- GitLab