Hi,
I'd like to render additional objects (i.e. not included in mrpt::opengl) inside a 3D scene using OpenGL. I am not sure about how to do this though. Since a rendering context is already defined when invoking MRPT's CDisplayWindow3D, I have not been able to simply access this object and use OpenGL's commands (e.g glBegin(GL_QUADS), glVertex3f(), etc.).
Is this possible? Or is it discouraged? Is there an example showing how to do this? Perhaps the right way is to create a new class derived from CRenderizableDisplayList, but I'm not sure.
Any help will be much appreciated.
Thank you!
Yes, the most recommendable
Yes, the most recommendable way to do it is by deriving a new class from, for example, CRenderizableDisplayList.
The only issues you may need to be careful about:
- Classes should be registered at start-up. See the registerAllClasses.cpp file in any MRPT lib for an example on how to do it (it will be just one line of code).
- Your opengl code within ::render() (or equivalent method) will be normally called from a different thread than the "main thread". Keep this in mind!
I never tried to do this, so I'll be glad to read your opinion when you're done... perhaps even it turns up that some "generic opengl class" could be added to MRPT to make things like this easier...
Cheers,
JL