9 #include <unordered_map> 17 #define check_gl_error() _check_gl_error(__FILE__,__LINE__) 20 #define check_gl_error() _check_gl_error(__FILE__,__LINE__) 22 #define check_gl_error() 45 std::vector<float2>
uvs;
55 unsigned int get_id()
const {
return _id; }
73 static std::unique_ptr<shader_program> load(
76 const char* input0 =
nullptr,
77 const char* input1 =
nullptr,
78 const char* output0 =
nullptr,
79 const char* output1 =
nullptr);
81 unsigned int get_id()
const {
return _id; }
85 void load_uniform(
int location,
const float2& vec);
86 void load_uniform(
int location,
const float3& vec);
87 void load_uniform(
int location,
bool value);
88 void load_uniform(
int location,
int value);
91 void bind_attribute(
int attr,
const std::string& name);
115 void draw_triangles();
116 void draw_indexed_triangles();
123 vbo(
const vbo& other) =
delete;
140 static std::unique_ptr<vao> create(
const obj_mesh&
m);
143 const float3* tangents,
int vert_count,
const int3* indx,
int indx_count);
151 void update_positions(
const float3* vert);
156 vao(
const vao& other) =
delete;
171 void set_opacity(
float opacity);
173 void set_position_and_scale(
181 static const char* default_vertex_shader();
196 void set_ray_center(
const float2& center);
197 void set_power(
float power);
209 _geometry(
vao::create(create_mesh()))
240 : tex_2d_shader(shader)
244 void draw_texture(
uint32_t tex,
float opacity = 1.
f);
249 tex_2d_shader->begin();
250 _visualizer.set_position(pos);
251 _visualizer.set_scale(scale);
252 _visualizer.draw(*tex_2d_shader, tex);
253 tex_2d_shader->end();
258 tex_2d_shader->begin();
259 _visualizer.set_position(pos);
260 _visualizer.set_scale(scale);
261 _visualizer.draw(*tex_2d_shader, tex1, tex2);
262 tex_2d_shader->end();
276 auto toidx = [&](
int i,
int j) {
280 for (
auto i = 0; i <
a; i++)
282 for (
auto j = 0;
j <
b;
j++)
288 res.
uvs.emplace_back(
float2{ (i+0.5f)/(
float)(
a), (
j+0.5
f)/(float)(b) });
290 if (i < a - 1 &&
j < b - 1)
292 auto curr = toidx(i,
j);
293 auto next_a = toidx(i + 1,
j);
294 auto next_b = toidx(i,
j + 1);
295 auto next_ab = toidx(i + 1,
j + 1);
296 res.
indexes.emplace_back(
int3{ curr, next_a, next_b });
297 res.
indexes.emplace_back(
int3{ next_a, next_ab, next_b });
312 void createDepthTextureAttachment(
uint32_t texture);
318 void createDepthBufferAttachment();
std::vector< float3 > positions
void _check_gl_error(const char *file, int line)
obj_mesh make_grid(int a, int b)
GLboolean GLboolean GLboolean b
GLuint const GLchar * name
unsigned int get_id() const
GLenum GLenum GLenum GLenum GLenum scale
std::unique_ptr< shader_program > _shader
std::vector< float3 > tangents
texture_2d_shader & get_shader()
GLdouble GLdouble GLdouble w
void draw_texture(float2 pos, float2 scale, uint32_t tex1, uint32_t tex2)
GLsizei const GLchar *const * string
visualizer_2d(std::shared_ptr< texture_2d_shader > shader)
std::shared_ptr< texture_2d_shader > tex_2d_shader
GLfloat GLfloat GLfloat GLfloat h
std::vector< const shader * > _shaders
GLboolean GLboolean GLboolean GLboolean a
std::vector< float3 > normals
texture_visualizer(float2 pos, float2 scale)
uint32_t _opacity_location
std::vector< float2 > uvs
void set_scale(float2 scale)
static const textual_icon link
static const textual_icon upload
void set_dims(int w, int h)
void set_position(float2 pos)
std::vector< int3 > indexes
texture_visualizer _visualizer
std::shared_ptr< vao > _geometry
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
uint32_t _position_location
unsigned int get_id() const
void draw_texture(float2 pos, float2 scale, uint32_t tex)