iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Interface functions that should all be called from a same thread

Functions

void nrt::graphics::ShapeRendererBasic::createContext ()
 
void nrt::graphics::ShapeRendererBasic::activateContext ()
 Optional, activate the context (after it is created by createContext()); initFrame() does this too.
 
void nrt::graphics::ShapeRendererBasic::initFrame ()
 Reset our display buffer to blank.
 
void nrt::graphics::ShapeRendererBasic::renderFrame ()
 Render the display buffer to screen.
 
void nrt::graphics::ShapeRendererBasic::destroyContext ()
 Destroy our drawing context.
 

Function Documentation

void nrt::graphics::ShapeRendererBasic::createContext ( )
        An OpenGL context is attached to a given thread, hence all of the renderer's display functions should be
        called from the same thread. Typically, that would teh the run() thread of an nrt::Component, as follows:
{
// Get our renderer going:
itsRenderer->createContext();
itsRenderer->lookAt(Eigen::Vector3d(0, -100, 100), Eigen::Vector3d(0, 0, 0), Eigen::Vector3d::UnitZ());
// Main loop:
while (running())
{
// Reset our frame to blank:
itsRenderer->initFrame();
// Now render all our shapes:
for (auto const & s : my_shapes) s.render(*itsRenderer);
// Finalize rendering of the frame:
itsRenderer->renderFrame();
// Maybe sleep a bit, or compute FPS, etc
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
// Time to cleanup and close down:
itsRenderer->destroyContext();
}

Create a drawing context