4 * \author Matt Raykowski
8 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
9 // Copyright (C) 2010 Winch Gate Property Limited
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU Affero General Public License as
13 // published by the Free Software Foundation, either version 3 of the
14 // License, or (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Affero General Public License for more details.
21 // You should have received a copy of the GNU Affero General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "NeLDriver.h"
28 #include <CEGUIExceptions.h>
38 void NeLDriver::init() {
40 HWND hWnd
= (HWND
)m_Driver
->getDisplay();
41 SetWindowText(hWnd
,"CEGUI NeL Demo");
44 // Create the window with config file values
45 if (!m_Driver
->setDisplay(NL3D::UDriver::CMode(800, 600, 32, true, 0))) {
46 nlwarning ("Can't set display mode %d %d %d %d %d", 800, 600, 32, false, 0);
49 m_Driver
->setFontManagerMaxMemory(2000000);
50 m_TextContext
= m_Driver
->createTextContext(NLMISC::CPath::lookup("n019003l.pfb"));
51 if(m_TextContext
== 0) {
52 nlwarning("Can't create text context");
55 m_TextContext
->setKeep800x600Ratio(false);
56 m_Driver
->setAmbientColor(NLMISC::CRGBA(82, 100, 133, 255));
57 m_Driver
->enableFog(false);
58 m_Scene
= m_Driver
->createScene(false);
60 nlwarning("Can't create a NeL UScene");
63 m_Scene
->getCam().setPerspective(NLMISC::degToRad(90.0f
), 1.33f
, 1.0f
*GScale
, 30000.0f
*GScale
);
64 m_Scene
->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix
);
65 m_Scene
->enableLightingSystem(true);
66 m_Scene
->setSunAmbient(NLMISC::CRGBA(82, 100, 133, 255));
67 m_Scene
->setSunDiffuse(NLMISC::CRGBA(255,255,255));
68 m_Scene
->setSunSpecular(NLMISC::CRGBA(255,255,255));
69 m_Scene
->setSunDirection(NLMISC::CVector(-1,0,-1));
71 m_Scene
->setPolygonBalancingMode(NL3D::UScene::PolygonBalancingOn
);
72 m_Scene
->setGroupLoadMaxPolygon("Fx", 5000);
75 m_FirstTime
= NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime());
76 m_OldTime
= NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime());
77 m_Time
= NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime());
81 void NeLDriver::update() {
82 using namespace NLMISC
;
83 H_AUTO(NeLDriver_update
);
86 double newTime
= NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime());
87 m_Time
= newTime
- m_FirstTime
;
88 m_DeltaTime
= m_Time
- m_OldTime
;
89 m_DeltaTimeSmooth
.addValue(m_DeltaTime
);
92 m_Scene
->animate(m_Time
);
95 m_Driver
->EventServer
.pump();
98 double NeLDriver::getFps() {
99 return m_DeltaTimeSmooth
.getSmoothValue() ? 1.0 / m_DeltaTimeSmooth
.getSmoothValue() : 0.0;
102 void NeLDriver::render() {
103 using namespace NLMISC
;
104 H_AUTO(NeLDriver_render
);
108 NL3D::UDriver
&NeLDriver::getDriver() const {
112 NL3D::UScene
&NeLDriver::getScene() const {
116 NL3D::UTextContext
&NeLDriver::getTextContext() const {
117 return *m_TextContext
;