Main MRPT website > C++ reference for MRPT 1.9.9
gl_utils.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "opengl-precomp.h" // Precompiled header
11 
12 #include <mrpt/opengl/gl_utils.h> // Include these before windows.h!!
13 #include <mrpt/system/os.h>
14 #include "opengl_internals.h"
15 
16 #if MRPT_HAS_OPENGL_GLUT
17 #include <cvd/gl_helpers.h>
18 #endif
19 
20 #include <map>
21 
22 using namespace std;
23 using namespace mrpt;
24 using namespace mrpt::math;
25 using namespace mrpt::poses;
26 using namespace mrpt::system;
27 using namespace mrpt::opengl;
28 
29 /** For each object in the list:
30 * - checks visibility of each object
31 * - prepare the GL_MODELVIEW matrix according to its coordinates
32 * - call its ::render()
33 * - shows its name (if enabled).
34 */
36 {
37 #if MRPT_HAS_OPENGL_GLUT
38  MRPT_PROFILE_FUNC_START // Just the non-try/catch part of MRPT_START
39 
41  try
42  {
43  for (itP = objectsToRender.begin(); itP != objectsToRender.end(); ++itP)
44  {
45  if (!*itP) continue;
46  const CRenderizable* it =
47  itP->get(); // Use plain pointers, faster than smart pointers:
48  if (!it->isVisible()) continue;
49 
50  // 3D coordinates transformation:
52  glPushMatrix();
53 
54  glPushAttrib(GL_CURRENT_BIT); // drawing color, etc
55  glPushAttrib(GL_LIGHTING_BIT); // lighting
56  // gl_utils::checkOpenGLError();
57 
58  // It's more efficient to prepare the 4x4 matrix ourselves and load
59  // it directly into opengl stack:
60  // A homogeneous transformation matrix, in this order:
61  //
62  // 0 4 8 12
63  // 1 5 9 13
64  // 2 6 10 14
65  // 3 7 11 15
66  //
67  const CPose3D& pos = it->getPoseRef();
68  const CMatrixDouble33& R = pos.getRotationMatrix();
69  const GLdouble m[16] = {
70  R.coeff(0, 0), R.coeff(1, 0), R.coeff(2, 0), 0,
71  R.coeff(0, 1), R.coeff(1, 1), R.coeff(2, 1), 0,
72  R.coeff(0, 2), R.coeff(1, 2), R.coeff(2, 2), 0,
73  pos.m_coords[0], pos.m_coords[1], pos.m_coords[2], 1};
74  glMultMatrixd(m); // Multiply so it's composed with the previous,
75  // current MODELVIEW matrix
76 
77  // Do scaling after the other transformations!
78  if (it->getScaleX() != 1 || it->getScaleY() != 1 ||
79  it->getScaleZ() != 1)
80  glScalef(it->getScaleX(), it->getScaleY(), it->getScaleZ());
81 
82  // Set color:
83  glColor4f(
84  it->getColorR(), it->getColorG(), it->getColorB(),
85  it->getColorA());
86 
87  it->render();
89 
90  if (it->isShowNameEnabled())
91  {
93  glColor3f(
94  1.f, 1.f, 1.f); // Must be called BEFORE glRasterPos3f
95  glRasterPos3f(0.0f, 0.0f, 0.0f);
96 
97  GLfloat raster_pos[4];
99  float eye_distance = raster_pos[3];
100 
101  void* font = nullptr;
102  if (eye_distance < 2)
103  font = GLUT_BITMAP_TIMES_ROMAN_24;
104  else if (eye_distance < 200)
105  font = GLUT_BITMAP_TIMES_ROMAN_10;
106 
107  if (font)
109  it->getName().c_str(), font);
110 
112  }
113 
114  glPopAttrib();
115  glPopAttrib();
116  // gl_utils::checkOpenGLError();
117 
118  glPopMatrix();
120 
121  } // end foreach object
122  }
123  catch (exception& e)
124  {
125  char str[1000];
126  os::sprintf(
127  str, 1000, "Exception while rendering a class '%s'\n%s",
128  (*itP)->GetRuntimeClass()->className, e.what());
129  THROW_EXCEPTION(str);
130  }
131  catch (...)
132  {
133  THROW_EXCEPTION("Runtime error!");
134  }
135 #else
136  MRPT_UNUSED_PARAM(objectsToRender);
137 #endif
138 }
139 
140 /*---------------------------------------------------------------
141  checkOpenGLError
142  ---------------------------------------------------------------*/
144 {
145 #if MRPT_HAS_OPENGL_GLUT
146  int openglErr;
147  if ((openglErr = glGetError()) != GL_NO_ERROR)
148  {
149  const std::string sErr = std::string("OpenGL error: ") +
150  std::string((char*)gluErrorString(openglErr));
151  std::cerr << "[gl_utils::checkOpenGLError] " << sErr << std::endl;
152  // THROW_EXCEPTION(sErr);
153  }
154 #endif
155 }
156 
158  const mrpt::math::TPoint3D& p1, const mrpt::math::TPoint3D& p2,
159  const mrpt::math::TPoint3D& p3)
160 {
161 #if MRPT_HAS_OPENGL_GLUT
162  const float ax = p2.x - p1.x;
163  const float ay = p2.y - p1.y;
164  const float az = p2.z - p1.z;
165 
166  const float bx = p3.x - p1.x;
167  const float by = p3.y - p1.y;
168  const float bz = p3.z - p1.z;
169 
170  glNormal3f(ay * bz - az * by, -ax * bz + az * bx, ax * by - ay * bx);
171 
172  glVertex3f(p1.x, p1.y, p1.z);
173  glVertex3f(p2.x, p2.y, p2.z);
174  glVertex3f(p3.x, p3.y, p3.z);
175 #else
176  MRPT_UNUSED_PARAM(p1);
177  MRPT_UNUSED_PARAM(p2);
178  MRPT_UNUSED_PARAM(p3);
179 #endif
180 }
182  const mrpt::math::TPoint3Df& p1, const mrpt::math::TPoint3Df& p2,
183  const mrpt::math::TPoint3Df& p3)
184 {
185 #if MRPT_HAS_OPENGL_GLUT
186  const float ax = p2.x - p1.x;
187  const float ay = p2.y - p1.y;
188  const float az = p2.z - p1.z;
189 
190  const float bx = p3.x - p1.x;
191  const float by = p3.y - p1.y;
192  const float bz = p3.z - p1.z;
193 
194  glNormal3f(ay * bz - az * by, -ax * bz + az * bx, ax * by - ay * bx);
195 
196  glVertex3f(p1.x, p1.y, p1.z);
197  glVertex3f(p2.x, p2.y, p2.z);
198  glVertex3f(p3.x, p3.y, p3.z);
199 #else
200  MRPT_UNUSED_PARAM(p1);
201  MRPT_UNUSED_PARAM(p2);
202  MRPT_UNUSED_PARAM(p3);
203 #endif
204 }
206  const mrpt::math::TPoint3Df& p1, const mrpt::math::TPoint3Df& p2,
207  const mrpt::math::TPoint3Df& p3, const mrpt::math::TPoint3Df& p4)
208 {
209  renderTriangleWithNormal(p1, p2, p3);
210  renderTriangleWithNormal(p3, p4, p1);
211 }
212 
213 /** Gather useful information on the render parameters.
214  * It can be called from within the render() method of derived classes.
215  */
217 {
218 #if MRPT_HAS_OPENGL_GLUT
219  // Viewport geometry:
220  GLint win_dims[4];
221  glGetIntegerv(GL_VIEWPORT, win_dims);
222  ri.vp_x = win_dims[0];
223  ri.vp_y = win_dims[1];
224  ri.vp_width = win_dims[2];
225  ri.vp_height = win_dims[3];
226 
227  // Get the inverse camera position:
228  GLfloat mat_proj[16];
230  ri.proj_matrix = Eigen::Matrix<float, 4, 4, Eigen::ColMajor>(mat_proj);
231 
232  // Extract the camera position:
233  Eigen::Matrix<float, 4, 1> cam_pose_hm = ri.proj_matrix.inverse().col(3);
234  if (cam_pose_hm[3] != 0)
235  {
236  ri.camera_position.x = cam_pose_hm[0] / cam_pose_hm[3];
237  ri.camera_position.y = cam_pose_hm[1] / cam_pose_hm[3];
238  ri.camera_position.z = cam_pose_hm[2] / cam_pose_hm[3];
239  }
240  else
242 
243  // Get the model transformation:
244  GLfloat mat_mod[16];
246  ri.model_matrix = Eigen::Matrix<float, 4, 4, Eigen::ColMajor>(mat_mod);
247 
248  // PROJ * MODEL
249  ri.full_matrix = ri.proj_matrix * ri.model_matrix;
250 #else
251  MRPT_UNUSED_PARAM(ri);
252 #endif
253 }
254 
255 /*---------------------------------------------------------------
256  renderTextBitmap
257  ---------------------------------------------------------------*/
258 void gl_utils::renderTextBitmap(const char* str, void* fontStyle)
259 {
260 #if MRPT_HAS_OPENGL_GLUT
261  while (*str) glutBitmapCharacter(fontStyle, *(str++));
262 #else
263  MRPT_UNUSED_PARAM(str);
264  MRPT_UNUSED_PARAM(fontStyle);
265 #endif
266 }
267 
269 {
270 #if MRPT_HAS_OPENGL_GLUT
271  switch (font)
272  {
273  default:
275  return GLUT_BITMAP_TIMES_ROMAN_10;
276  break;
278  return GLUT_BITMAP_TIMES_ROMAN_24;
279  break;
280 
282  return GLUT_BITMAP_HELVETICA_10;
283  break;
285  return GLUT_BITMAP_HELVETICA_12;
286  break;
288  return GLUT_BITMAP_HELVETICA_18;
289  break;
290  }
291 #else
292  MRPT_UNUSED_PARAM(font);
293  return nullptr;
294 #endif
295 }
296 
297 /** Return the exact width in pixels for a given string, as will be rendered by
298  * renderTextBitmap().
299  * \sa renderTextBitmap
300  */
302  const std::string& str, mrpt::opengl::TOpenGLFont font)
303 {
304 #if MRPT_HAS_OPENGL_GLUT
305  if (str.empty()) return 0;
306  return glutBitmapLength(
307  aux_mrptfont2glutfont(font), (const unsigned char*)str.c_str());
308 #else
309  MRPT_UNUSED_PARAM(str);
310  MRPT_UNUSED_PARAM(font);
311  return 10;
312 #endif
313 }
314 
315 /*---------------------------------------------------------------
316  renderTextBitmap
317  ---------------------------------------------------------------*/
319  int screen_x, int screen_y, const std::string& str, float color_r,
320  float color_g, float color_b, TOpenGLFont font)
321 {
322 #if MRPT_HAS_OPENGL_GLUT
324 
325  // If (x,y) are negative, wrap to the opposite side:
326  if (screen_x < 0 || screen_y < 0)
327  {
328  // Size of the viewport:
329  GLint win_dims[4]; // [2]:width ,[3]:height
330  glGetIntegerv(GL_VIEWPORT, win_dims);
331 
332  if (screen_x < 0) screen_x += win_dims[2];
333  if (screen_y < 0) screen_y += win_dims[3];
334  }
335 
336  // Draw text:
337  glColor3f(color_r, color_g, color_b);
338 
339  // From: http://www.mesa3d.org/brianp/sig97/gotchas.htm
340  GLfloat fx, fy;
341 
342  /* Push current matrix mode and viewport attributes */
344 
345  /* Setup projection parameters */
347  glPushMatrix();
348  glLoadIdentity();
350  glPushMatrix();
351  glLoadIdentity();
352 
353  // glDepthRange( z, z );
354  glViewport((int)screen_x - 1, (int)screen_y - 1, 2, 2);
355 
356  /* set the raster (window) position */
357  fx = screen_x - (int)screen_x;
358  fy = screen_y - (int)screen_y;
359  // glRasterPos4f( fx, fy, 0.0, w );
360  glRasterPos3f(fx, fy, 0.0);
361 
362  /* restore matrices, viewport and matrix mode */
363  glPopMatrix();
365  glPopMatrix();
366 
367  glPopAttrib();
368 
369  // Select font:
370  void* glut_font_sel = aux_mrptfont2glutfont(font);
371 
372  for (size_t i = 0; i < str.size(); i++)
373  glutBitmapCharacter(glut_font_sel, str[i]);
374 
376 #else
377  MRPT_UNUSED_PARAM(screen_x);
378  MRPT_UNUSED_PARAM(screen_y);
379  MRPT_UNUSED_PARAM(str);
380  MRPT_UNUSED_PARAM(color_r);
381  MRPT_UNUSED_PARAM(color_g);
382  MRPT_UNUSED_PARAM(color_b);
383  MRPT_UNUSED_PARAM(font);
384 #endif
385 }
386 
388  const float msg_x, const float msg_y, const float msg_w, const float msg_h,
389  const std::string& text, float text_scale,
390  const mrpt::img::TColor& back_col, const mrpt::img::TColor& border_col,
391  const mrpt::img::TColor& text_col, const float border_width,
392  const std::string& text_font, mrpt::opengl::TOpenGLFontStyle text_style,
393  const double text_spacing, const double text_kerning)
394 {
395 #if MRPT_HAS_OPENGL_GLUT
396  const int nLines = 1 + std::count(text.begin(), text.end(), '\n');
397 
398  GLint win_dims[4];
399  glGetIntegerv(GL_VIEWPORT, win_dims);
400  const int w = win_dims[2];
401  const int h = win_dims[3];
402 
403  const int min_wh = std::min(w, h);
404  const float vw_w = w / float(min_wh);
405  const float vw_h = h / float(min_wh);
406 
408  glPushMatrix();
409 
410  glLoadIdentity();
411  glOrtho(0, vw_w, 0, vw_h, -1, 1);
412 
414  glPushMatrix();
415 
416  glLoadIdentity();
417 
421 
422  // The center of the message box:
423  const float msg_x0 = vw_w * msg_x;
424  const float msg_y0 = vw_h * msg_y;
425 
426  const float msg_x1 = vw_w * (msg_x + msg_w);
427  const float msg_y1 = vw_h * (msg_y + msg_h);
428 
429  const float msg_real_w = msg_x1 - msg_x0;
430  const float msg_real_h = msg_y1 - msg_y0;
431 
432  const float msg_cx = .5 * (msg_x0 + msg_x1);
433  const float msg_cy = .5 * (msg_y0 + msg_y1);
434 
435  // Background:
436  glColor4ub(back_col.R, back_col.G, back_col.B, back_col.A);
438  glVertex2f(msg_x0, msg_y0);
439  glVertex2f(msg_x1, msg_y0);
440  glVertex2f(msg_x1, msg_y1);
441  glVertex2f(msg_x0, msg_y1);
442  glEnd();
443 
444  // Border:
445  glColor4ub(border_col.R, border_col.G, border_col.B, border_col.A);
446  glLineWidth(border_width);
447  glDisable(GL_LIGHTING); // Disable lights when drawing lines
449  glVertex2f(msg_x0, msg_y0);
450  glVertex2f(msg_x1, msg_y0);
451  glVertex2f(msg_x1, msg_y1);
452  glVertex2f(msg_x0, msg_y1);
453  glEnd();
454  glEnable(GL_LIGHTING); // Disable lights when drawing lines
455 
456  // Draw text (centered):
457  gl_utils::glSetFont(text_font);
458  mrpt::img::TPixelCoordf txtSize =
459  gl_utils::glGetExtends(text, text_scale, text_spacing, text_kerning);
460 
461  // Adjust text size if it doesn't fit into the box:
462  if (txtSize.x > msg_real_w)
463  {
464  const float K = 0.99f * msg_real_w / txtSize.x;
465  text_scale *= K;
466  txtSize.x *= K;
467  txtSize.y *= K;
468  }
469  if (txtSize.y > msg_real_h)
470  {
471  const float K = 0.99f * msg_real_h / txtSize.y;
472  text_scale *= K;
473  txtSize.x *= K;
474  txtSize.y *= K;
475  }
476 
477  const float text_w = txtSize.x;
478  const float text_h =
479  (nLines > 1 ? -(nLines - 1) * txtSize.y / float(nLines) : txtSize.y);
480  const float text_x0 = msg_cx - .5f * text_w;
481  const float text_y0 = msg_cy - .5f * text_h;
482 
483  glTranslatef(text_x0, text_y0, 0);
484  glColor4ub(text_col.R, text_col.G, text_col.B, text_col.A);
486  text, text_scale, text_style, text_spacing, text_kerning);
487 
488  // Restore gl flags:
491 
492  glPopMatrix();
493 
495  glPopMatrix();
496 #else
497  MRPT_UNUSED_PARAM(msg_x);
498  MRPT_UNUSED_PARAM(msg_y);
499  MRPT_UNUSED_PARAM(msg_w);
500  MRPT_UNUSED_PARAM(msg_h);
501  MRPT_UNUSED_PARAM(text);
502  MRPT_UNUSED_PARAM(text_scale);
503  MRPT_UNUSED_PARAM(back_col);
504  MRPT_UNUSED_PARAM(border_col);
505  MRPT_UNUSED_PARAM(text_col);
506  MRPT_UNUSED_PARAM(border_width);
507  MRPT_UNUSED_PARAM(text_font);
508  MRPT_UNUSED_PARAM(text_style);
509  MRPT_UNUSED_PARAM(text_spacing);
510  MRPT_UNUSED_PARAM(text_kerning);
511 #endif
512 }
513 
514 void gl_utils::glSetFont(const std::string& fontname)
515 {
516 #if MRPT_HAS_OPENGL_GLUT
517  CVD::glSetFont(fontname);
518 #else
519  MRPT_UNUSED_PARAM(fontname);
520 #endif
521 }
522 
524 {
525 #if MRPT_HAS_OPENGL_GLUT
526  return CVD::glGetFont();
527 #else
528  THROW_EXCEPTION("MRPT built without OpenGL");
529 #endif
530 }
531 
533  const std::string& text, const double textScale,
534  enum TOpenGLFontStyle style, double spacing, double kerning)
535 {
536 #if MRPT_HAS_OPENGL_GLUT
537  glPushMatrix();
539  glScaled(textScale, textScale, textScale);
540  auto ret = CVD::glDrawText(text, static_cast<CVD::TEXT_STYLE>(style), spacing, kerning);
541  glPopMatrix();
542  return ret;
543 #else
544  MRPT_UNUSED_PARAM(text);
545  MRPT_UNUSED_PARAM(textScale);
546  MRPT_UNUSED_PARAM(style);
547  MRPT_UNUSED_PARAM(spacing);
548  MRPT_UNUSED_PARAM(kerning);
549  THROW_EXCEPTION("MRPT built without OpenGL");
550 #endif
551 }
552 
554  const std::string& text, const double textScale, double spacing,
555  double kerning)
556 {
557 #if MRPT_HAS_OPENGL_GLUT
558  mrpt::img::TPixelCoordf ret(CVD::glGetExtends(text, spacing, kerning));
559  ret.x *= textScale;
560  ret.y *= textScale;
561  return ret;
562 #else
563  MRPT_UNUSED_PARAM(text);
564  MRPT_UNUSED_PARAM(textScale);
565  MRPT_UNUSED_PARAM(spacing);
566  MRPT_UNUSED_PARAM(kerning);
567  THROW_EXCEPTION("MRPT built without OpenGL");
568 #endif
569 }
570 // =============== END OF CODE FROM "libcvd -> gltext.cpp" ===============
void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
Definition: gl_utils.cpp:258
double getColorA() const
Color components in the range [0,1].
GLuint GLuint GLsizei count
Definition: glext.h:3528
void renderTriangleWithNormal(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p3)
Can be used by derived classes to draw a triangle with a normal vector computed automatically - to be...
Definition: gl_utils.cpp:157
GLAPI void GLAPIENTRY glGetFloatv(GLenum pname, GLfloat *params)
#define min(a, b)
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
float getScaleX() const
Get the current scaling factor in one axis.
double GLdouble
Definition: glew.h:219
GLbyte GLbyte bz
Definition: glext.h:6105
GLAPI void GLAPIENTRY glEnable(GLenum cap)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:25
GLAPI void GLAPIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
void renderQuadWithNormal(const mrpt::math::TPoint3Df &p1, const mrpt::math::TPoint3Df &p2, const mrpt::math::TPoint3Df &p3, const mrpt::math::TPoint3Df &p4)
Can be used by derived classes to draw a quad with a normal vector computed automatically - to be cal...
Definition: gl_utils.cpp:205
#define GL_LIGHTING_BIT
Definition: glew.h:257
const std::string & glGetFont()
returns the name of the currently active font
Definition: gl_utils.cpp:523
GLAPI void GLAPIENTRY glScaled(GLdouble x, GLdouble y, GLdouble z)
#define GL_MODELVIEW
Definition: glew.h:610
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
GLAPI void GLAPIENTRY glPopMatrix(void)
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:43
#define GL_VIEWPORT_BIT
Definition: glew.h:262
A pair (x,y) of pixel coordinates (subpixel resolution).
Definition: TPixelCoord.h:20
STL namespace.
uint8_t B
Definition: TColor.h:48
mrpt::img::TPixelCoordf glDrawText(const std::string &text, const double textScale, enum TOpenGLFontStyle style=NICE, double spacing=1.5, double kerning=0.1)
renders a string in GL using the current settings.
Definition: gl_utils.cpp:532
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
uint8_t G
Definition: TColor.h:48
#define GL_DEPTH_TEST
Definition: glew.h:401
GLAPI void GLAPIENTRY glPopAttrib(void)
#define GL_LIGHTING
Definition: glew.h:385
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gl_utils.cpp:514
GLAPI void GLAPIENTRY glLoadIdentity(void)
#define GL_CURRENT_RASTER_POSITION
Definition: glew.h:360
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
float GLfloat
Definition: glew.h:217
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
#define MRPT_PROFILE_FUNC_START
Definition: exceptions.h:255
This base provides a set of functions for maths stuff.
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
Definition: opengl_fonts.h:25
Lightweight 3D point (float version).
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z] access directly or with x(), y(), z() setter/getter methods...
Definition: CPose3D.h:98
bool isVisible() const
Is the object visible?
Definition: CRenderizable.h:71
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
mrpt::img::TPixelCoordf glGetExtends(const std::string &text, const double textScale, double spacing=1.5, double kerning=0.1)
returns the size of the bounding box of a text to be rendered, similar to glDrawText but without any ...
Definition: gl_utils.cpp:553
Information about the rendering process being issued.
Definition: gl_utils.h:30
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > model_matrix
The 4x4 model transformation matrix.
Definition: gl_utils.h:37
#define GL_MODELVIEW_MATRIX
Definition: glew.h:421
#define GL_PROJECTION
Definition: glew.h:611
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
const std::string & getName() const
Returns the name of the object.
Definition: CRenderizable.h:70
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:432
int vp_x
Rendering viewport geometry (in pixels)
Definition: gl_utils.h:33
GLsizei const GLchar ** string
Definition: glext.h:4101
#define GL_LINE_LOOP
Definition: glew.h:274
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
uint8_t R
Definition: TColor.h:48
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
#define GL_SRC_ALPHA
Definition: glew.h:286
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define GL_NO_ERROR
Definition: glew.h:326
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
#define GL_VIEWPORT
Definition: glew.h:417
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > full_matrix
PROJ * MODEL.
Definition: gl_utils.h:39
GLAPI void GLAPIENTRY glMultMatrixd(const GLdouble *m)
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
void renderMessageBox(const float msg_x, const float msg_y, const float msg_w, const float msg_h, const std::string &text, float text_scale, const mrpt::img::TColor &back_col=mrpt::img::TColor(0, 0, 50, 150), const mrpt::img::TColor &border_col=mrpt::img::TColor(0, 0, 0, 140), const mrpt::img::TColor &text_col=mrpt::img::TColor(255, 255, 255, 220), const float border_width=4.0f, const std::string &text_font=std::string("sans"), mrpt::opengl::TOpenGLFontStyle text_style=mrpt::opengl::FILL, const double text_spacing=1.5, const double text_kerning=0.1)
Draws a message box with a centered (possibly multi-lined) text.
Definition: gl_utils.cpp:387
const float R
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
GLAPI void GLAPIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
int textBitmapWidth(const std::string &str, mrpt::opengl::TOpenGLFont font=mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24)
Return the exact width in pixels for a given string, as will be rendered by renderTextBitmap().
Definition: gl_utils.cpp:301
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
Definition: gl_utils.cpp:143
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
GLAPI GLenum GLAPIENTRY glGetError(void)
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > proj_matrix
The 4x4 projection matrix.
Definition: gl_utils.h:35
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
void getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.
Definition: gl_utils.cpp:216
GLAPI void GLAPIENTRY glEnd(void)
#define GL_TRANSFORM_BIT
Definition: glew.h:263
const mrpt::poses::CPose3D & getPoseRef() const
Returns a const ref to the 3D pose of the object as mrpt::poses::CPose3D (which explicitly contains t...
float getScaleY() const
Get the current scaling factor in one axis.
GLbyte by
Definition: glext.h:6105
#define GL_TRIANGLE_FAN
Definition: glew.h:278
int GLint
Definition: glew.h:209
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
#define GL_PROJECTION_MATRIX
Definition: glew.h:422
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
A RGB color - 8bit.
Definition: TColor.h:22
#define GL_CURRENT_BIT
Definition: glew.h:251
GLAPI void GLAPIENTRY glPushMatrix(void)
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
Definition: CPose3D.h:232
double getColorB() const
Color components in the range [0,1].
Lightweight 3D point.
void renderSetOfObjects(const mrpt::opengl::CListOpenGLObjects &objs)
For each object in the list:
Definition: gl_utils.cpp:35
void * aux_mrptfont2glutfont(const TOpenGLFont font)
Definition: gl_utils.cpp:268
GLAPI void GLAPIENTRY glVertex2f(GLfloat x, GLfloat y)
virtual void render() const =0
Implements the rendering of 3D objects in each class derived from CRenderizable.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
double getColorG() const
Color components in the range [0,1].
const Scalar * const_iterator
Definition: eigen_plugins.h:27
float getScaleZ() const
Get the current scaling factor in one axis.
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:189
uint8_t A
Definition: TColor.h:48
double getColorR() const
Color components in the range [0,1].
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
mrpt::math::TPoint3Df camera_position
The 3D location of the camera.
Definition: gl_utils.h:41



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019