Commit d1e4fd9b authored by Tim Übelhör's avatar Tim Übelhör

several addition for binding resources

parent e1f59e02
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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)),
......
......@@ -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);
......
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