Main MRPT website > C++ reference for MRPT 1.9.9
COpenGLStandardObject.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 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 using namespace mrpt::math;
20 using namespace mrpt::poses;
21 
24 
25 #define COMPILE_TIME_ASSERT(N, expr) char dummy_constraint##N[expr]
26 
27 #if MRPT_HAS_OPENGL_GLUT
28 COMPILE_TIME_ASSERT(GLENUM, sizeof(GLenum) == sizeof(_GLENUM));
29 #endif
30 
31 /*---------------------------------------------------------------
32  render
33  ---------------------------------------------------------------*/
34 void renderFunc(TPoint3D p)
35 {
36 #if MRPT_HAS_OPENGL_GLUT
37  glVertex3f(p.x, p.y, p.z);
38 #else
40 #endif
41 }
42 
44 {
45 #if MRPT_HAS_OPENGL_GLUT
46  for_each(enabled.begin(), enabled.end(), glEnable);
48  // This line won't take any effect if GL_BLEND is not enabled, so it's safe
49  // to always execute it.
51  glColor4ub(m_color.R, m_color.G, m_color.B, m_color.A);
52  if (normal[0] || normal[1] || normal[2])
53  glNormal3f(normal[0], normal[1], normal[2]);
54  if (chunkSize == 0)
55  {
56  glBegin(type);
57  for_each(vertices.begin(), vertices.end(), renderFunc);
58  glEnd();
59  }
60  else
61  {
62  std::vector<TPoint3D>::const_iterator it = vertices.begin();
63  do
64  {
65  glBegin(type);
66  for_each(it, it + chunkSize, renderFunc);
67  it += chunkSize;
68  glEnd();
69  } while (it != vertices.end());
70  }
71  for_each(enabled.begin(), enabled.end(), glDisable);
72 #endif
73 }
74 
78 {
79  writeToStreamRender(out);
80  out << type << vertices << chunkSize << enabled;
81 }
82 
85 {
86  switch (version)
87  {
88  case 1:
89  {
90  readFromStreamRender(in);
91  in >> type >> vertices >> chunkSize >> enabled;
92  }
93  break;
94  default:
96  };
98 }
99 
101  const mrpt::poses::CPose3D& o, double& dist) const
102 {
104  MRPT_UNUSED_PARAM(dist);
105  // This object isn't intended to hold geometric properties. No trace ray
106  // should be performed on it.
107  return false;
108 }
109 
111  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
112 {
113  bb_min.x = 0;
114  bb_min.y = 0;
115  bb_min.z = 0;
116 
117  bb_max.x = 0;
118  bb_max.y = 0;
119  bb_max.z = 0;
120 
121  // Convert to coordinates of my parent:
122  m_pose.composePoint(bb_min, bb_min);
123  m_pose.composePoint(bb_max, bb_max);
124 }
125 
127 {
128  std::vector<_GLENUM>::iterator it = enabled.begin();
129  while (it != enabled.end())
130  {
131  if (*it == flag)
132  it = enabled.erase(it);
133  else
134  ++it;
135  }
137 }
glBegin
GLAPI void GLAPIENTRY glBegin(GLenum mode)
COMPILE_TIME_ASSERT
#define COMPILE_TIME_ASSERT(N, expr)
mrpt::opengl::COpenGLStandardObject
Objects of this class represent a generic openGL object without specific geometric properties.
Definition: COpenGLStandardObject.h:26
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
mrpt::opengl::_GLENUM
uint32_t _GLENUM
Definition: COpenGLStandardObject.h:19
GL_SRC_ALPHA
#define GL_SRC_ALPHA
Definition: glew.h:286
glColor4ub
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
glDisable
GLAPI void GLAPIENTRY glDisable(GLenum cap)
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
stl_serialization.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
type
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3528
glVertex3f
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::opengl::COpenGLStandardObject::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: COpenGLStandardObject.cpp:83
glEnd
GLAPI void GLAPIENTRY glEnd(void)
IMPLEMENTS_SERIALIZABLE
IMPLEMENTS_SERIALIZABLE(COpenGLStandardObject, CRenderizableDisplayList, mrpt::opengl) void renderFunc(TPoint3D p)
Definition: COpenGLStandardObject.cpp:22
GL_ONE_MINUS_SRC_ALPHA
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
glShadeModel
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::opengl::COpenGLStandardObject::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: COpenGLStandardObject.cpp:76
glNormal3f
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
opengl-precomp.h
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
COpenGLStandardObject.h
opengl_internals.h
mrpt::opengl::COpenGLStandardObject::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray Tracing.
Definition: COpenGLStandardObject.cpp:100
mrpt::opengl::COpenGLStandardObject::getBoundingBox
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: COpenGLStandardObject.cpp:110
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
GLenum
unsigned int GLenum
Definition: glew.h:206
in
GLuint in
Definition: glext.h:7274
mrpt::opengl::COpenGLStandardObject::render_dl
virtual void render_dl() const override
Render.
Definition: COpenGLStandardObject.cpp:43
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
GL_SMOOTH
#define GL_SMOOTH
Definition: glew.h:635
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::opengl::COpenGLStandardObject::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: COpenGLStandardObject.cpp:75
mrpt::opengl::COpenGLStandardObject::disable
void disable(_GLENUM flag)
Disable some openGL flag.
Definition: COpenGLStandardObject.cpp:126
glBlendFunc
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST