opengl3.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "opengl3.h"
5 
6 #include <glad/glad.h>
7 #include <assert.h>
8 
9 using namespace rs2;
10 
12 {
13  switch (type) {
16  default: throw std::runtime_error("Not supported VBO type!");
17  }
18 }
19 
21  : _type(type)
22 {
23  glGenBuffers(1, &_id);
24 }
25 
26 void vbo::bind()
27 {
29 }
30 
32 {
34 }
35 
36 void vbo::upload(int attribute, const float* xyz, int size, int count, bool dynamic)
37 {
39  bind();
40  glBufferData(convert_type(_type), count * size * sizeof(float), xyz,
41  dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
42  glVertexAttribPointer(attribute, size, GL_FLOAT, GL_FALSE, 0, 0);
43  _size = count;
45  unbind();
46 }
47 
48 void vbo::upload(const int3* indx, int count)
49 {
51  bind();
52  glBufferData(convert_type(_type), count * sizeof(int3), indx, GL_STATIC_DRAW);
54  _size = count;
55 }
56 
58 {
60  bind();
63  unbind();
64 }
65 
67 {
69  bind();
72  unbind();
73 }
74 
76 {
78  glDrawElements(GL_TRIANGLES, _size * (sizeof(int3) / sizeof(int)), GL_UNSIGNED_INT, 0);
80 }
81 
82 vbo::vbo(vbo&& other)
83  : _id(other._id), _type(other._type), _size(other._size)
84 {
85  other._id = 0;
86 }
87 
89 {
90  if (_id) glDeleteBuffers(1, &_id);
91 }
92 
93 vao::vao(const float3* vert, const float2* uvs, const float3* normals,
94  const float3* tangents, int vert_count, const int3* indx, int indx_count)
95  : _vertexes(vbo_type::array_buffer),
96  _uvs(vbo_type::array_buffer),
97  _indexes(vbo_type::element_array_buffer),
98  _tangents(vbo_type::array_buffer),
99  _vertex_count(vert_count)
100 {
101  glGenVertexArrays(1, &_id);
102  check_gl_error();
103  bind();
104  _indexes.upload(indx, indx_count);
105  _vertexes.upload(0, (float*)vert, 3, vert_count, true);
106  if (normals) _normals.upload(2, (float*)normals, 3, vert_count);
107  if (tangents) _tangents.upload(3, (float*)tangents, 3, vert_count);
108  if (uvs) _uvs.upload(1, (float*)uvs, 2, vert_count);
109  unbind();
110 }
111 
112 std::unique_ptr<vao> vao::create(const obj_mesh& mesh)
113 {
114  return std::unique_ptr<vao>(new vao(mesh.positions.data(),
115  mesh.uvs.data(),
116  mesh.normals.data(),
117  mesh.tangents.data(),
118  int(mesh.positions.size()),
119  mesh.indexes.data(),
120  int(mesh.indexes.size())));
121 }
122 
123 vao::vao(vao&& other)
124  : _id(other._id),
125  _indexes(std::move(other._indexes)),
126  _vertexes(std::move(other._vertexes)),
127  _uvs(std::move(other._uvs)),
128  _normals(std::move(other._normals)),
129  _tangents(std::move(other._tangents))
130 {
131  other._id = 0;
132 }
133 
135 {
136  if (_id) glDeleteVertexArrays(1, &_id);
137 }
138 
139 void vao::bind()
140 {
142  check_gl_error();
143 }
144 
146 {
148 }
149 
151 {
152  bind();
153 
154  glEnableVertexAttribArray(0); // vertex
155  if (_uvs.size()) glEnableVertexAttribArray(1); // uv
156  if (_normals.size()) glEnableVertexAttribArray(2); // normals
157  if (_tangents.size()) glEnableVertexAttribArray(3); // tangents
158  check_gl_error();
159 
161  check_gl_error();
162 
167 
168  check_gl_error();
169 
170  unbind();
171 }
172 
173 void vao::draw()
174 {
175  bind();
176 
177  glEnableVertexAttribArray(0); // vertex
178  if (_uvs.size()) glEnableVertexAttribArray(1); // uv
179  if (_normals.size()) glEnableVertexAttribArray(2); // normals
180  if (_tangents.size()) glEnableVertexAttribArray(3); // tangents
181 
182  check_gl_error();
183 
185 
186  check_gl_error();
187 
192 
193  check_gl_error();
194 
195  unbind();
196 }
197 
198 void vao::update_positions(const float3* vert)
199 {
200  _vertexes.upload(0, (float*)vert, 3, _vertex_count, true);
201 }
202 
203 static const char* vertex_shader_text =
204 "#version 110\n"
205 "attribute vec3 position;\n"
206 "attribute vec2 textureCoords;\n"
207 "varying vec2 textCoords;\n"
208 "uniform vec2 elementPosition;\n"
209 "uniform vec2 elementScale;\n"
210 "void main(void)\n"
211 "{\n"
212 " gl_Position = vec4(position * vec3(elementScale, 1.0) + vec3(elementPosition, 0.0), 1.0);\n"
213 " textCoords = textureCoords;\n"
214 "}";
215 
216 static const char* splash_shader_text =
217 "#version 110\n"
218 "varying vec2 textCoords;\n"
219 "uniform sampler2D textureSampler;\n"
220 "uniform float opacity;\n"
221 "uniform vec2 rayOrigin;\n"
222 "uniform float power;\n"
223 "void main(void) {\n"
224 " vec4 FragColor = texture2D(textureSampler, textCoords);\n"
225 " int samples = 120;\n"
226 " vec2 delta = vec2(textCoords - rayOrigin);\n"
227 " delta *= 1.0 / float(samples) * 0.99;"
228 " vec2 coord = textCoords;\n"
229 " float illuminationDecay = power;\n"
230 " for(int i=0; i < samples ; i++)\n"
231 " {\n"
232 " coord -= delta;\n"
233 " vec4 texel = texture2D(textureSampler, coord);\n"
234 " texel *= illuminationDecay * 0.4;\n"
235 " texel.x *= 80.0 / 255.0;\n"
236 " texel.y *= 99.0 / 255.0;\n"
237 " texel.z *= 115.0 / 255.0;\n"
238 " FragColor += texel;\n"
239 " illuminationDecay *= power;\n"
240 " }\n"
241 " FragColor = clamp(FragColor, 0.0, 1.0);\n"
242 " gl_FragColor = vec4(FragColor.xyz, opacity);\n"
243 "}";
244 
245 static const char* fragment_shader_text =
246 "#version 110\n"
247 "varying vec2 textCoords;\n"
248 "uniform sampler2D textureSampler;\n"
249 "uniform float opacity;\n"
250 "void main(void) {\n"
251 " vec2 tex = vec2(textCoords.x, 1.0 - textCoords.y);\n"
252 " vec4 color = texture2D(textureSampler, tex);\n"
253 " gl_FragColor = vec4(color.xyz, opacity);\n"
254 "}";
255 
256 using namespace rs2;
257 
258 texture_2d_shader::texture_2d_shader(std::unique_ptr<shader_program> shader)
259  : _shader(std::move(shader))
260 {
261  init();
262 }
263 
265 {
266  return vertex_shader_text;
267 }
268 
270 {
273  fragment_shader_text, "position", "textureCoords");
274 
275  init();
276 }
277 
278 void visualizer_2d::draw_texture(uint32_t tex, float opacity)
279 {
282  tex_2d_shader->begin();
283  tex_2d_shader->set_opacity(opacity);
284  tex_2d_shader->end();
285  draw_texture({ 0.f, 0.f }, { 1.f, 1.f }, tex);
287  check_gl_error();
288 }
289 
290 void visualizer_2d::draw_texture(uint32_t tex1, uint32_t tex2, float opacity)
291 {
294  tex_2d_shader->begin();
295  tex_2d_shader->set_opacity(opacity);
296  tex_2d_shader->end();
297  draw_texture({ 0.f, 0.f }, { 1.0f, 1.0f }, tex1, tex2);
299 }
300 
302  const float2& position,
303  const float2& scale)
304 {
305  _shader->load_uniform(_position_location, position);
306  _shader->load_uniform(_scale_location, scale);
307 }
308 
310 {
311  _shader->load_uniform(_rays_location, center);
312 }
313 
315 {
316  _shader->load_uniform(_power_location, power);
317 }
318 
320 {
321  _position_location = _shader->get_uniform_location("elementPosition");
322  _scale_location = _shader->get_uniform_location("elementScale");
323  _opacity_location = _shader->get_uniform_location("opacity");
324 
325  auto texture0_sampler_location = _shader->get_uniform_location("textureSampler");
326 
327  _shader->begin();
328  _shader->load_uniform(texture0_sampler_location, 0);
329  set_opacity(1.f);
330  _shader->end();
331 }
332 
336  splash_shader_text, "position", "textureCoords"))
337 {
338 
339  _rays_location = _shader->get_uniform_location("rayOrigin");
340  _power_location = _shader->get_uniform_location("power");
341 }
342 
343 void texture_2d_shader::begin() { _shader->begin(); }
344 void texture_2d_shader::end() { _shader->end(); }
345 
347 {
348  _shader->load_uniform(_opacity_location, opacity);
349  check_gl_error();
350 }
351 
353 {
354  shader.begin();
355  shader.set_position_and_scale(_position, _scale);
358  _geometry->draw();
360  shader.end();
361  check_gl_error();
362 }
363 
365 {
366  shader.begin();
367  shader.set_position_and_scale(_position, _scale);
368 
371 
374 
375  _geometry->draw();
377  shader.end();
378 }
379 
381 {
382  obj_mesh res;
383 
384  res.positions.reserve(4);
385  res.positions.emplace_back(float3{ -1.f, -1.f, 0.f });
386  res.positions.emplace_back(float3{ 1.f, -1.f, 0.f });
387  res.positions.emplace_back(float3{ 1.f, 1.f, 0.f });
388  res.positions.emplace_back(float3{ -1.f, 1.f, 0.f });
389 
390  res.uvs.reserve(4);
391  res.uvs.emplace_back(float2{ 0.f, 1.f });
392  res.uvs.emplace_back(float2{ 1.f, 1.f });
393  res.uvs.emplace_back(float2{ 1.f, 0.f });
394  res.uvs.emplace_back(float2{ 0.f, 0.f });
395 
396  res.indexes.reserve(2);
397  res.indexes.emplace_back(int3{ 0, 1, 2 });
398  res.indexes.emplace_back(int3{ 2, 3, 0 });
399 
400  return res;
401 }
402 
403 #include <iostream>
404 
405 using namespace rs2;
406 
408 {
409  return glGetUniformLocation(_id, name.c_str());
410 }
411 
413 {
414  glUniform1i(location, value);
415  check_gl_error();
416 }
417 
419 {
420  glUniform1f(location, value);
421  check_gl_error();
422 }
423 
425 {
426  load_uniform(location, value ? 1.f : 0.f);
427  check_gl_error();
428 }
429 
431 {
432  glUniform3f(location, vec.x, vec.y, vec.z);
433  check_gl_error();
434 }
435 
437 {
438  glUniform2f(location, vec.x, vec.y);
439  check_gl_error();
440 }
441 
443 {
444  glUniformMatrix4fv(location, 1, GL_FALSE, (float*)&matrix);
445  check_gl_error();
446 }
447 
449 {
450  glBindAttribLocation(_id, attr, name.c_str());
451  check_gl_error();
452 }
453 
455 {
456  auto lambda = [&]() {
457  switch (type)
458  {
461  default:
462  throw std::runtime_error("Unknown shader type!");
463  }
464  };
465  const auto gl_type = lambda();
466 
467  GLuint shader_id = glCreateShader(gl_type);
468 
469  char const * source_ptr = shader_code.c_str();
470  int length = int(shader_code.size());
471  glShaderSource(shader_id, 1, &source_ptr, &length);
472 
473  glCompileShader(shader_id);
474 
475  GLint result;
476  int log_length;
477 
478  glGetShaderiv(shader_id, GL_COMPILE_STATUS, &result);
479  glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH, &log_length);
480  if ((result == GL_FALSE) && (log_length > 0)) {
481  std::vector<char> error_message(log_length + 1);
482  glGetShaderInfoLog(shader_id, log_length, NULL, &error_message[0]);
483  std::string error(&error_message[0]);
484  std::cerr << error;
485  glDeleteShader(shader_id);
486  throw std::runtime_error(error);
487  }
488 
489  check_gl_error();
490 
491  _id = shader_id;
492 }
493 
495 {
496  glDeleteShader(_id);
497 }
498 
500 {
501  GLuint program_id = glCreateProgram();
502  check_gl_error();
503  _id = program_id;
504 }
506 {
507  glUseProgram(0);
508  glDeleteProgram(_id);
509 }
510 
512 {
513  _shaders.push_back(&shader);
514 }
516 {
517  for (auto ps : _shaders)
518  {
519  glAttachShader(_id, ps->get_id());
520  }
521 
522  glLinkProgram(_id);
523 
524  GLint result;
525  int log_length;
526 
527  glGetProgramiv(_id, GL_LINK_STATUS, &result);
528  glGetProgramiv(_id, GL_INFO_LOG_LENGTH, &log_length);
529  if ((result == GL_FALSE) && (log_length > 0)) {
530  std::vector<char> error_message(log_length + 1);
531  glGetProgramInfoLog(_id, log_length, NULL, &error_message[0]);
532  std::string error(&error_message[0]);
533  std::cerr << error;
534  for (auto ps : _shaders)
535  {
536  glDetachShader(_id, ps->get_id());
537  }
538  throw std::runtime_error(error);
539  }
540 
541  glValidateProgram(_id);
542 
543  glGetProgramiv(_id, GL_VALIDATE_STATUS, &result);
544  glGetProgramiv(_id, GL_INFO_LOG_LENGTH, &log_length);
545  if ((result == GL_FALSE) && (log_length > 0)) {
546  std::vector<char> error_message(log_length + 1);
547  glGetProgramInfoLog(_id, log_length, NULL, &error_message[0]);
548  std::string error(&error_message[0]);
549  std::cerr << error;
550  for (auto ps : _shaders)
551  {
552  glDetachShader(_id, ps->get_id());
553  }
554  throw std::runtime_error(error);
555  }
556 
557  for (auto ps : _shaders)
558  {
559  glDetachShader(_id, ps->get_id());
560  }
561  _shaders.clear();
562 
563  check_gl_error();
564 }
565 
567 {
568  glUseProgram(_id);
569  check_gl_error();
570 }
572 {
573  glUseProgram(0);
574 }
575 
576 std::unique_ptr<shader_program> shader_program::load(
577  const std::string& vertex_shader,
578  const std::string& fragment_shader,
579  const char* input0,
580  const char* input1,
581  const char* output0,
582  const char* output1)
583 {
584  std::unique_ptr<shader_program> res(new shader_program());
585  shader vertex(vertex_shader, shader_type::vertex);
586  shader fragment(fragment_shader, shader_type::fragment);
587  res->attach(vertex);
588  res->attach(fragment);
589 
590  if (input0) glBindAttribLocation(res->get_id(), 0, input0);
591  if (input1) glBindAttribLocation(res->get_id(), 1, input1);
592  check_gl_error();
593 
594  if (output0) glBindFragDataLocation(res->get_id(), 0, output0);
595  if (output1) glBindFragDataLocation(res->get_id(), 1, output1);
596  check_gl_error();
597 
598  res->link();
599  return std::move(res);
600 }
601 
602 fbo::fbo(int w, int h) : _w(w), _h(h)
603 {
604  glGenFramebuffers(1, &_id);
605  check_gl_error();
607  check_gl_error();
609  check_gl_error();
610 }
611 
613 {
614  glBindTexture(GL_TEXTURE_2D, handle);
618 
621  check_gl_error();
622 }
623 
625 {
626  glBindTexture(GL_TEXTURE_2D, handle);
632  check_gl_error();
633 }
634 
635 void fbo::bind()
636 {
638 
640  check_gl_error();
642  check_gl_error();
643  glViewport(0, 0, _w, _h);
644  check_gl_error();
645 }
646 
648 {
650  check_gl_error();
652  check_gl_error();
653 }
654 
656 {
657  if (_db) glDeleteRenderbuffers(1, &_db);
658  glGenRenderbuffers(1, &_db);
662  check_gl_error();
663 }
664 
666 {
669 }
670 
672 {
673  std::string res = "UNKNOWN";
674 
675  bind();
677 
678  if (s == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) res = "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
679  else if (s == 0x8CD9) res = "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
680  else if (s == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) res = "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
681  else if (s == GL_FRAMEBUFFER_UNSUPPORTED) res = "GL_FRAMEBUFFER_UNSUPPORTED";
682  else if (s == GL_FRAMEBUFFER_COMPLETE) res = "GL_FRAMEBUFFER_COMPLETE";
683 
684  unbind();
685 
686  return res;
687 }
688 
689 
690 void _check_gl_error(const char *file, int line)
691 {
692  GLenum err (glGetError());
693  std::stringstream ss;
694 
695  bool has_errors = false;
696  while (err != GL_NO_ERROR)
697  {
699 
700  switch (err)
701  {
702  case GL_INVALID_OPERATION: error="INVALID_OPERATION"; break;
703  case GL_INVALID_ENUM: error="INVALID_ENUM"; break;
704  case GL_INVALID_VALUE: error="INVALID_VALUE"; break;
705  case GL_OUT_OF_MEMORY: error="OUT_OF_MEMORY"; break;
706  case GL_INVALID_FRAMEBUFFER_OPERATION: error="INVALID_FRAMEBUFFER_OPERATION"; break;
707  default: error="Unknown"; break;
708  }
709 
710  ss << "GL_" << error.c_str() << " - " << file << ":" << line << "\n";
711  err = glGetError();
712  has_errors = true;
713  }
714 
715  if (has_errors)
716  {
717  auto error = ss.str();
718  throw std::runtime_error(error);
719  }
720 }
721 
723 {
724  GLenum err(glGetError());
725  while (err != GL_NO_ERROR)
726  {
727  err = glGetError();
728  }
729 }
void set_ray_center(const float2 &center)
Definition: opengl3.cpp:309
int32_t _viewport[4]
Definition: opengl3.h:333
#define glDetachShader
#define GL_FRAMEBUFFER_COMPLETE
#define glDeleteShader
std::vector< float3 > positions
Definition: opengl3.h:43
#define glGetShaderInfoLog
uint32_t _id
Definition: opengl3.h:158
#define GL_TEXTURE_MAG_FILTER
#define glBufferData
#define glCreateProgram
fbo(int w, int h)
Definition: opengl3.cpp:602
#define GL_VERTEX_SHADER
#define GL_STATIC_DRAW
void bind_attribute(int attr, const std::string &name)
Definition: opengl3.cpp:448
GLuint const GLchar * name
static const char * vertex_shader_text
Definition: opengl3.cpp:203
static std::unique_ptr< vao > create(const obj_mesh &m)
Definition: opengl3.cpp:112
#define glFramebufferTexture2D
GLdouble s
#define GL_TEXTURE_2D
#define glBindRenderbuffer
void begin() const
Definition: opengl3.cpp:566
#define GL_RGBA
uint32_t _id
Definition: opengl3.h:126
GLuint GLenum matrix
Definition: glext.h:11553
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
#define GL_DEPTH_COMPONENT32
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:10806
int _vertex_count
Definition: opengl3.h:159
std::unique_ptr< shader_program > _shader
Definition: opengl3.h:179
#define GL_UNSIGNED_BYTE
#define glGetIntegerv
vbo _tangents
Definition: opengl3.h:160
GLuint64 GLenum void * handle
Definition: glext.h:7785
GLint location
GLfloat value
#define glDeleteRenderbuffers
void createDepthBufferAttachment()
Definition: opengl3.cpp:655
#define glCheckFramebufferStatus
void draw()
Definition: opengl3.cpp:173
std::vector< float3 > tangents
Definition: opengl3.h:46
void draw_triangles()
Definition: opengl3.cpp:66
#define glDrawArrays
#define GL_LINK_STATUS
void bind()
Definition: opengl3.cpp:26
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
uint32_t _size
Definition: opengl3.h:127
#define GL_INVALID_VALUE
#define glUniformMatrix4fv
Definition: cah-model.h:10
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
#define GL_BLEND
#define GL_DEPTH_ATTACHMENT
#define glGenRenderbuffers
#define GL_LINEAR
#define GL_VALIDATE_STATUS
#define GL_NO_ERROR
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:1960
#define glUseProgram
#define glTexImage2D
#define GL_SRC_ALPHA
vbo _indexes
Definition: opengl3.h:160
vbo_type _type
Definition: opengl3.h:128
static const char * default_vertex_shader()
Definition: opengl3.cpp:264
#define glEnable
void attach(const shader &shader)
Definition: opengl3.cpp:511
#define glUniform2f
void bind()
Definition: opengl3.cpp:635
#define glBindFragDataLocation
#define glActiveTexture
#define glCreateShader
void set_position_and_scale(const float2 &position, const float2 &scale)
Definition: opengl3.cpp:301
void unbind()
Definition: opengl3.cpp:145
#define glDeleteVertexArrays
void unbind()
Definition: opengl3.cpp:31
#define GL_INFO_LOG_LENGTH
#define glUniform1i
#define glGetProgramiv
GLdouble f
#define glGenVertexArrays
#define GL_TEXTURE0
#define glVertexAttribPointer
std::vector< float3 > normals
Definition: opengl3.h:44
uint32_t _scale_location
Definition: opengl3.h:187
shader(const std::string &code, shader_type type)
Definition: opengl3.cpp:454
#define GL_FLOAT
vbo _normals
Definition: opengl3.h:160
GLsizeiptr size
#define glEnableVertexAttribArray
#define GL_INVALID_ENUM
#define glUniform3f
#define glDeleteFramebuffers
#define glBindVertexArray
#define glGenFramebuffers
#define GL_VIEWPORT
uint32_t _opacity_location
Definition: opengl3.h:188
#define glBindFramebuffer
std::vector< float2 > uvs
Definition: opengl3.h:45
#define glTexParameteri
void update_positions(const float3 *vert)
Definition: opengl3.cpp:198
#define GL_FRAMEBUFFER_UNSUPPORTED
int GLint
void createDepthTextureAttachment(uint32_t texture)
Definition: opengl3.cpp:624
#define glBindBuffer
unsigned int uint32_t
Definition: stdint.h:80
void draw_points()
Definition: opengl3.cpp:150
#define glDisableVertexAttribArray
void unbind()
Definition: opengl3.cpp:647
#define GL_TEXTURE_MIN_FILTER
void load_uniform(int location, float value)
Definition: opengl3.cpp:418
void end() const
Definition: opengl3.cpp:571
uint32_t size() const
Definition: opengl3.h:121
#define glDeleteProgram
#define glGetError
#define glGetUniformLocation
#define glGetShaderiv
#define GL_RENDERBUFFER
#define GL_FRAGMENT_SHADER
#define glShaderSource
shader_type
Definition: opengl3.h:28
void draw_indexed_triangles()
Definition: opengl3.cpp:75
void draw(texture_2d_shader &shader, uint32_t tex)
Definition: opengl3.cpp:352
static const char * fragment_shader_text
Definition: opengl3.cpp:245
#define glViewport
#define GL_DYNAMIC_DRAW
vbo _vertexes
Definition: opengl3.h:160
#define GL_OUT_OF_MEMORY
#define GL_ONE_MINUS_SRC_ALPHA
#define glAttachShader
#define glCompileShader
uint32_t _db
Definition: opengl3.h:331
#define glRenderbufferStorage
int get_uniform_location(const std::string &name)
Definition: opengl3.cpp:407
#define glUniform1f
uint32_t _id
Definition: opengl3.h:330
#define glValidateProgram
#define glBindAttribLocation
#define glDeleteBuffers
static obj_mesh create_mesh()
Definition: opengl3.cpp:380
int _w
Definition: opengl3.h:332
#define GL_INVALID_FRAMEBUFFER_OPERATION
#define GL_FALSE
std::vector< int3 > indexes
Definition: opengl3.h:42
static std::unique_ptr< shader_program > load(const std::string &vertex_shader, const std::string &fragment_shader, const char *input0=nullptr, const char *input1=nullptr, const char *output0=nullptr, const char *output1=nullptr)
Definition: opengl3.cpp:576
void upload(int attribute, const float *xyz, int size, int count, bool dynamic=false)
Definition: opengl3.cpp:36
void createTextureAttachment(uint32_t texture)
Definition: opengl3.cpp:612
unsigned int GLuint
vbo_type
Definition: opengl3.h:98
GLenum type
#define glGenBuffers
static GLuint mesh
Definition: heightmap.c:113
#define glDrawElements
#define glBindTexture
#define GL_COMPILE_STATUS
#define glLinkProgram
vbo _uvs
Definition: opengl3.h:160
GLint GLsizei count
#define GL_TEXTURE1
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
void clear_gl_errors()
Definition: opengl3.cpp:722
std::ostream & cerr()
xyz
Definition: rmse.py:152
#define glGetProgramInfoLog
uint32_t _position_location
Definition: opengl3.h:186
vbo(vbo_type type=vbo_type::array_buffer)
Definition: opengl3.cpp:20
#define GL_ELEMENT_ARRAY_BUFFER
#define NULL
Definition: tinycthread.c:47
#define GL_COLOR_ATTACHMENT0
unsigned int GLenum
static const char * splash_shader_text
Definition: opengl3.cpp:216
GLenum GLuint GLenum GLsizei length
GLuint res
Definition: glext.h:8856
void bind()
Definition: opengl3.cpp:139
void _check_gl_error(const char *file, int line)
Definition: opengl3.cpp:690
#define glDrawBuffer
static int convert_type(vbo_type type)
Definition: opengl3.cpp:11
#define GL_INVALID_OPERATION
#define glBlendFunc
#define check_gl_error()
Definition: opengl3.h:17
#define GL_NEAREST
#define GL_DEPTH_COMPONENT
void set_opacity(float opacity)
Definition: opengl3.cpp:346
GLuint64EXT * result
Definition: glext.h:10921
void draw_texture(uint32_t tex, float opacity=1.f)
Definition: opengl3.cpp:278
#define GL_ARRAY_BUFFER
void draw_points()
Definition: opengl3.cpp:57
#define glFramebufferRenderbuffer
#define GL_POINTS
vao(const float3 *vert, const float2 *uvs, const float3 *normals, const float3 *tangents, int vert_count, const int3 *indx, int indx_count)
Definition: opengl3.cpp:93
#define GL_UNSIGNED_INT
#define GL_FRAMEBUFFER
#define GL_TRIANGLES
#define glDisable
void set_power(float power)
Definition: opengl3.cpp:314
std::string get_status()
Definition: opengl3.cpp:671
int _h
Definition: opengl3.h:332


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:38