Commit 7668c45d authored by Tim Übelhör's avatar Tim Übelhör

Added shader setters for uint

parent c90b9ed4
......@@ -6,7 +6,8 @@
"${workspaceFolder}/include",
"~/.conan/data/",
"/home/tim/.conan/data/gl3w/0.2/tuebel/testing/package/1a651c5b4129ad794b88522bece2281a7453aee4/include",
"/home/tim/.conan/data/glfw/3.2.1/bincrafters/stable/package/db2ca884c9793e0b0fb54ec3f846326d1addacc8/include"
"/home/tim/.conan/data/glfw/3.2.1/bincrafters/stable/package/db2ca884c9793e0b0fb54ec3f846326d1addacc8/include",
"/home/tim/.conan/data/glm/0.9.9.1/g-truc/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include"
],
"defines": [],
"cStandard": "c11",
......
#pragma once
#include <GL/gl3w.h>
#include <sstream>
#include <stdexcept>
#include <iostream>
namespace scigl_render
{
inline void check_gl_error(const std::string& msg)
{
GLenum err;
if ((err = glGetError()) != GL_NO_ERROR)
while ((err = glGetError()) != GL_NO_ERROR)
{
std::stringstream stream;
stream << msg << std::hex << err;
throw std::runtime_error(stream.str());
std::cerr << "OpenGL error: " << msg << std::hex << err << "\n";
}
}
} // namespace scigl_render
\ No newline at end of file
......@@ -102,6 +102,8 @@ public:
size_t get_views_per_column() const;
size_t get_view_width() const;
size_t get_view_height() const;
size_t get_texture_width() const;
size_t get_texture_height() const;
void set_views_per_row(size_t views_per_row);
void set_views_per_column(size_t views_per_column);
void set_view_width(size_t width);
......
......@@ -32,6 +32,9 @@ public:
/*! Set the uniform variable value in the shader program. */
void setInt(const std::string &name, int value) const;
/*! Set the uniform variable value in the shader program. */
void setUInt(const std::string &name, uint32_t value) const;
/*! Set the uniform variable value in the shader program. */
void setFloat(const std::string &name, float value) const;
......@@ -64,7 +67,27 @@ public:
void setMat4(const std::string &name, const glm::mat4 &mat) const;
/*! Set the uniform variable value in the shader program. */
void setArray(const std::string &name, const float array[], int count) const;
void setUVec2(const std::string &name, const glm::uvec2 &value) const;
/*! Set the uniform variable value in the shader program. */
void setUVec3(const std::string &name, const glm::uvec3 &value) const;
/*! Set the uniform variable value in the shader program. */
void setUVec4(const std::string &name, const glm::uvec4 &value) const;
/*! Set the uniform variable value in the shader program. */
void setUVec2(const std::string &name, uint32_t x, uint32_t y) const;
/*! Set the uniform variable value in the shader program. */
void setUVec3(const std::string &name,
uint32_t x, uint32_t y, uint32_t z) const;
/*! Set the uniform variable value in the shader program. */
void setUVec4(const std::string &name,
uint32_t x, uint32_t y, uint32_t z, uint32_t w) const;
/*! Set the uniform variable value in the shader program. */
void setFloatArray(const std::string &name, const float array[], int count) const;
private:
/*!
......
......@@ -71,6 +71,14 @@ size_t Rasterizer::get_view_height() const
{
return height;
}
size_t Rasterizer::get_texture_width() const
{
return texture_width;
}
size_t Rasterizer::get_texture_height() const
{
return texture_height;
}
void Rasterizer::set_views_per_row(size_t views_per_row)
{
this->views_per_row = views_per_row;
......
......@@ -79,7 +79,7 @@ void CvCamera::set_in_shader(const Shader &shader) const
{
shader.activate();
shader.setVec3("camera_position", this->pose.position);
shader.setArray("dist_coeffs", this->intrinsics.dist_coeffs,
shader.setFloatArray("dist_coeffs", this->intrinsics.dist_coeffs,
sizeof(this->intrinsics.dist_coeffs));
shader.setMat4("projection_matrix", get_projection_matrix());
shader.setMat4("view_matrix", get_view_matrix());
......
......@@ -38,6 +38,11 @@ void Shader::setInt(const std::string &name, int value) const
glUniform1i(glGetUniformLocation(program_id, name.c_str()), value);
}
void Shader::setUInt(const std::string &name, uint32_t value) const
{
glUniform1ui(glGetUniformLocation(program_id, name.c_str()), value);
}
void Shader::setFloat(const std::string &name, float value) const
{
glUniform1f(glGetUniformLocation(program_id, name.c_str()), value);
......@@ -92,7 +97,39 @@ void Shader::setMat4(const std::string &name, const glm::mat4 &mat) const
GL_FALSE, &mat[0][0]);
}
void Shader::setArray(
void Shader::setUVec2(const std::string &name, const glm::uvec2 &value) const
{
glUniform2uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
}
void Shader::setUVec3(const std::string &name, const glm::uvec3 &value) const
{
glUniform3uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
}
void Shader::setUVec4(const std::string &name, const glm::uvec4 &value) const
{
glUniform4uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
}
void Shader::setUVec2(const std::string &name, uint32_t x, uint32_t y) const
{
glUniform2ui(glGetUniformLocation(program_id, name.c_str()), x, y);
}
void Shader::setUVec3(const std::string &name,
uint32_t x, uint32_t y, uint32_t z) const
{
glUniform3ui(glGetUniformLocation(program_id, name.c_str()), x, y, z);
}
void Shader::setUVec4(const std::string &name,
uint32_t x, uint32_t y, uint32_t z, uint32_t w) const
{
glUniform4ui(glGetUniformLocation(program_id, name.c_str()), x, y, z, w);
}
void Shader::setFloatArray(
const std::string &name, const float array[], int count) const
{
glUniform1fv(glGetUniformLocation(program_id, name.c_str()), count, array);
......
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