29 #if MRPT_HAS_OPENGL_GLUT 33 #pragma comment(lib, "opengl32.lib") 34 #pragma comment(lib, "GlU32.lib") 37 #endif // MRPT_HAS_OPENGL_GLUT 81 dynamic_cast<mrpt::opengl::COpenGLViewport*>(ptr->clone()));
94 #if MRPT_HAS_OPENGL_GLUT 101 m_viewport->render(win_dims[2], win_dims[3]);
104 glViewport(win_dims[0], win_dims[1], win_dims[2], win_dims[3]);
108 "The MRPT has been compiled with MRPT_HAS_OPENGL_GLUT=0! OpenGL " 109 "functions are not implemented");
122 for (
const auto& m_viewport :
m_viewports) out << *m_viewport;
141 view->m_objects.resize(
n);
143 view->m_objects.begin(), view->m_objects.end(),
155 for (i = 0; i <
n; i++)
157 CSerializable::Ptr newObj;
162 newView->m_parent =
this;
181 if (m_viewport->m_name == viewportName)
183 m_viewport->insert(newObject);
188 "Error: viewport '%s' not found.", viewportName.c_str());
196 const string& str,
const string& viewportName)
201 if ((
obj = m_viewport->getByName(str)))
break;
210 for (
auto& m_viewport :
m_viewports) m_viewport->initializeAllTextures();
222 lst.emplace_back(
string(
"VIEWPORT: ") +
v->m_name);
223 lst.emplace_back(
"============================================");
224 v->dumpListOfObjects(lst);
254 if (m_viewport->m_name == viewportName)
return m_viewport;
269 view->removeObject(
obj);
280 for (
auto it2 = vp->m_objects.begin(); it2 != vp->m_objects.end();
282 if ((*it2)->traceRay(o, tmp))
331 ASSERTMSG_(vp,
"No opengl viewport exists with the given name");
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
std::shared_ptr< COpenGLViewport > Ptr
#define THROW_EXCEPTION(msg)
COpenGLScene()
Constructor.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Traces a ray.
GLsizei GLsizei GLuint * obj
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max, const std::string &vpn=std::string("main")) const
Evaluates the bounding box of the scene in the given viewport (default: "main").
void initializeAllTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) ...
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream.
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
~COpenGLScene() override
Destructor:
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
COpenGLViewport::Ptr createViewport(const std::string &viewportName)
Creates a new viewport, adding it to the scene and returning a pointer to the new object...
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
void clear(bool createMainViewport=true)
Clear the list of objects and viewports in the scene, deleting objects' memory, and leaving just the ...
GLsizei const GLchar ** string
bool saveToFile(const std::string &fil) const
Saves the scene to a 3Dscene file, loadable by the application SceneViewer3D.
TListViewports m_viewports
The list of viewports, indexed by name.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
COpenGLViewport::Ptr getViewport(const std::string &viewportName=std::string("main")) const
Returns the viewport with the given name, or nullptr if it does not exist; note that the default view...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Virtual base class for "archives": classes abstracting I/O streams.
bool loadFromFile(const std::string &fil)
Loads the scene from a 3Dscene file, the format used by the application SceneViewer3D.
COpenGLScene & operator=(const COpenGLScene &obj)
Copy operator:
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
CRenderizable::Ptr getByName(const std::string &str, const std::string &viewportName=std::string("main"))
Returns the first object with a given name, or nullptr (an empty smart pointer) if not found...
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
void render() const
Render this scene.
The namespace for 3D scene representation and rendering.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Saves data to a file and transparently compress the data using the given compression level...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
unsigned __int32 uint32_t
void insert(const CRenderizable::Ptr &newObject, const std::string &viewportName=std::string("main"))
Insert a new object into the scene, in the given viewport (by default, into the "main" viewport)...
void removeObject(const CRenderizable::Ptr &obj, const std::string &viewportName=std::string("main"))
Removes the given object from the scene (it also deletes the object to free its memory).
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.