1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "qnelwidget.h"
20 #include <windows.h> // needed for WindowFromDC()
22 #include <Qt/qx11info_x11.h>
26 #include <nel/misc/types_nl.h>
27 #include <nel/misc/debug.h>
28 #include <nel/3d/nelu.h>
29 #include <nel/3d/init_3d.h>
30 #include <nel/3d/register_3d.h>
31 #include <nel/misc/path.h>
33 void QNelWidget::init()
35 nlinfo("start init.");
36 // do something, like initialize the basic system.
38 NL3D::CScene::registerBasics();
39 NL3D::registerSerial3d();
43 void QNelWidget::initializeGL()
45 // initialize NeL context if needed
46 if (!NLMISC::INelContext::isContextInitialised())
47 new NLMISC::CApplicationContext
;
49 nlinfo("start initialize gl");
50 NLMISC::CPath::addSearchPath(".");
53 NL3D::CViewport viewport
;
55 // Create a dummy driver.
56 //NL3D::IDriver *driver=NL3D::CDRU::createGlDriver();
58 //void *windowId = (void*)(this->parentWidget()->winId());
60 if (!NL3D::CNELU::init(width(), height(), viewport
, 32, true, (void *)winId(), false, false))
65 //_SceneRoot= (NL3D::CTransform*)NL3D::CNELU::Scene->createModel(NL3D::TransformId);
66 NL3D::CTransformShape
*sphere
= NL3D::CNELU::Scene
->createInstance("sphere01.shape");
69 fontManager
.setMaxMemory(2000000);
71 tc
.init(NL3D::CNELU::Driver
, &fontManager
);
72 tc
.setFontGenerator (NLMISC::CPath::lookup("beteckna.ttf"));
73 nlinfo("end initialize gl");
76 void QNelWidget::paintGL()
78 nlinfo("start painting gl");
79 NL3D::CNELU::clearBuffers(NL3D::CRGBA(0,0,0));
80 tc
.setColor(NL3D::CRGBA (0, 0, 255));
82 tc
.setHotSpot(NL3D::CComputedString::BottomLeft
);
83 tc
.printAt(0.3f
, 0.5f
, std::string("NeL"));
84 nlinfo("end painting gl");
87 void QNelWidget::resizeGL(int width
, int height
)
89 nlinfo("start resize gl");
90 // handle moves or resizes.
91 nlinfo("end resize gl");
94 void QNelWidget::swapBuffers() {
95 nlinfo("starting rendering.");
97 NL3D::CNELU::swapBuffers();
98 nlinfo("finished rendering.");