#include "qnelwidget.h" #if defined(Q_WS_WIN) #include // needed for WindowFromDC() #else #include #include #endif #include #include #include #include #include #include void QNelWidget::init() { nlinfo("start init."); // do something, like initialize the basic system. NL3D::init3d(); NL3D::CScene::registerBasics(); NL3D::registerSerial3d(); nlinfo("end init."); } void QNelWidget::initializeGL() { // initialize NeL context if needed if (!NLMISC::INelContext::isContextInitialised()) new NLMISC::CApplicationContext; nlinfo("start initialize gl"); NLMISC::CPath::addSearchPath("."); // The viewport NL3D::CViewport viewport; // Create a dummy driver. //NL3D::IDriver *driver=NL3D::CDRU::createGlDriver(); //void *windowId = (void*)(this->parentWidget()->winId()); // Init NELU if (!NL3D::CNELU::init(width(), height(), viewport, 32, true, (void *)winId(), false, false)) { return; } //_SceneRoot= (NL3D::CTransform*)NL3D::CNELU::Scene->createModel(NL3D::TransformId); NL3D::CTransformShape *sphere = NL3D::CNELU::Scene->createInstance("sphere01.shape"); fontManager.setMaxMemory(2000000); tc.init(NL3D::CNELU::Driver, &fontManager); tc.setFontGenerator (NLMISC::CPath::lookup("beteckna.ttf")); nlinfo("end initialize gl"); } void QNelWidget::paintGL() { nlinfo("start painting gl"); NL3D::CNELU::clearBuffers(NL3D::CRGBA(0,0,0)); tc.setColor(NL3D::CRGBA (0, 0, 255)); tc.setFontSize(40); tc.setHotSpot(NL3D::CComputedString::BottomLeft); tc.printAt(0.3f, 0.5f, std::string("NeL")); nlinfo("end painting gl"); } void QNelWidget::resizeGL(int width, int height) { nlinfo("start resize gl"); // handle moves or resizes. nlinfo("end resize gl"); } void QNelWidget::swapBuffers() { nlinfo("starting rendering."); // render a frame NL3D::CNELU::swapBuffers(); nlinfo("finished rendering."); }