CViewRenderer no longer depends on the Driver global variable. Also got rid of the same dependencies in files which included that global from the CViewRenderer header.

This commit is contained in:
dfighter1985 2012-02-11 01:41:46 +01:00
parent cec36b97e0
commit f0cc382971
16 changed files with 111 additions and 99 deletions

View file

@ -62,6 +62,7 @@
#include "ingame_database_manager.h"
#include "client_chat_manager.h"
#include "interface_v3/input_handler_manager.h"
#include "interface_v3/interface_manager.h"
//#include "crtdbg.h"
#include "sound_manager.h"
#include "net_manager.h"
@ -1074,6 +1075,8 @@ void prelogInit()
// resetTextContext ("bremenb.ttf", false);
resetTextContext ("ryzom.ttf", false);
CInterfaceManager::getInstance();
ProgressBar.setFontFactor(0.85f);
nmsg = "Loading background...";

View file

@ -3920,6 +3920,7 @@ public:
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
{
#ifdef NL_OS_WINDOWS
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if (Driver)
{
HWND wnd = Driver->getDisplay();

View file

@ -520,7 +520,8 @@ CCameraBackup setupCameraForScreenshot(UScene &scene, uint left, uint right, uin
// Build a viewport
CViewport viewport;
viewport.init (0, 0, (float)(right-left)/Driver->getWindowWidth(), (float)(bottom-top)/Driver->getWindowHeight());
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
viewport.init (0, 0, (float)(right-left)/Driver->getWindowWidth(),(float)(bottom-top)/Driver->getWindowHeight());
// Activate all this
scene.getCam().setFrustum (frustumPart);
@ -552,6 +553,7 @@ void renderSceneScreenShot (uint left, uint right, uint top, uint bottom, uint s
void getBuffer (CBitmap &btm)
{
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
//
if (ClientCfg.ScreenShotWidth && ClientCfg.ScreenShotHeight)
{
@ -611,6 +613,8 @@ bool screenshotZBuffer(const std::string &filename)
std::string ext = filename.substr(pos+1);
std::vector<float> z;
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
Driver->getZBuffer(z);
float min = std::numeric_limits<float>::max();

View file

@ -250,6 +250,7 @@ CCtrlSheetInfo::CCtrlSheetInfo()
void CDBCtrlSheet::release ()
{
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if (Driver)
Driver->deleteMaterial(_GuildMat);
@ -489,6 +490,8 @@ CDBCtrlSheet::CDBCtrlSheet(const TCtorParam &param)
// ----------------------------------------------------------------------------
CDBCtrlSheet::~CDBCtrlSheet()
{
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if (_GuildBack)
{
if (Driver)
@ -1304,6 +1307,8 @@ void CDBCtrlSheet::setupGuildFlag ()
sint8 nLastGuildBack = (sint8)(_MacroID&15); // 4 bits en pos 0
sint8 nLastGuildSymbol = (sint8)((_MacroID>>4)&63); // 6 bits en pos 4
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if (_GuildMat.empty())
{
_GuildMat = Driver->createMaterial();

View file

@ -335,7 +335,7 @@ void CGroupEditBox::copy()
stopParentBlink();
// get the selection and copy it
if (Driver->copyTextToClipboard(getSelection()))
if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->copyTextToClipboard(getSelection()))
nlinfo ("Chat input was copied in the clipboard");
}
@ -353,7 +353,7 @@ void CGroupEditBox::paste()
ucstring sString;
if (Driver->pasteTextFromClipboard(sString))
if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->pasteTextFromClipboard(sString))
{
// append string now
appendStringFromClipboard(sString);

View file

@ -86,8 +86,8 @@ void CGroupInScene::computeWindowPos(sint32 &newX, sint32 &newY, CVector &newPro
tmp = pVR.getFrustum().projectZ (tmp);
// Get the width and height
tmp.x *= (float)Driver->getWindowWidth();
tmp.y *= (float)Driver->getWindowHeight();
tmp.x *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowWidth();
tmp.y *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowHeight();
// position without offset, in float
newProjCenter.x= tmp.x;

View file

@ -667,6 +667,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont
if (target)
{
// Find a position
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
const uint width = Driver->getWindowWidth();
const uint height = Driver->getWindowHeight();
h = (target->getXReal() < ((sint)width-target->getXReal()-target->getWReal()))?"l":"r";

View file

@ -174,13 +174,13 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event)
UserControls.stopFreeLook();
}
// be nice with other app : let the mouse reappear (useful in direct 3D mode with no hardware cursor)
Driver->showCursor(true);
CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(true);
// Driver->setSystemArrow();
}
else
{
_RecoverFocusLost = true; // force to update mouse pos on next click or move
Driver->showCursor(IsMouseCursorHardware());
CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(IsMouseCursorHardware());
_Focus = true;
}

View file

@ -78,6 +78,7 @@ CInterface3DScene::~CInterface3DScene()
for (i = 0; i < _FXs.size(); ++i)
delete _FXs[i];
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if (_Scene != NULL)
Driver->deleteScene (_Scene);
@ -171,7 +172,8 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
return true;
}
nlassert (Driver != NULL);
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
nlassert ( Driver != NULL);
_Scene = Driver->createScene(true);
@ -297,7 +299,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
if (!animName.empty())
{
if (_AutoAnimSet == NULL)
_AutoAnimSet = Driver->createAnimationSet();
_AutoAnimSet = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet();
uint id = _AutoAnimSet->addAnimation (ptr, animName.c_str ());
if (id == UAnimationSet::NotFound)
{
@ -376,7 +378,9 @@ void CInterface3DScene::draw ()
{
H_AUTO( RZ_Interface_CInterface3DScene_draw )
if (Driver == NULL)
NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
if ( Driver == NULL)
return;
// No Op if screen minimized
@ -434,7 +438,7 @@ void CInterface3DScene::draw ()
float vpW = (float) clipw / iavoid0(wsw);
float vpH = (float) cliph / iavoid0(wsh);
newVP.init(vpX, vpY, vpW, vpH);
NL3D::CFrustum oldFrustum = Driver->getFrustum();
NL3D::CFrustum oldFrustum = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getFrustum();
NL3D::CFrustum newFrustum;
newFrustum.initPerspective (pI3DCam->getFOV() * (float) (NLMISC::Pi / 180), (float) _WReal / iavoid0(_HReal), 0.1f, 100.f);
@ -1093,7 +1097,7 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
setRotX (_Rot.x);
setRotY (_Rot.y);
setRotZ (_Rot.z);
_IG->addToScene (*parentGroup->getScene(), Driver);
_IG->addToScene (*parentGroup->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() );
parentGroup->getScene()->setToGlobalInstanceGroup (_IG);
return true;
@ -1214,7 +1218,7 @@ void CInterface3DIG::setName (const std::string &ht)
_IG = UInstanceGroup::createInstanceGroup(_Name);
if (_IG == NULL) return;
_IG->setPos (_Pos);
_IG->addToScene (*pI3DS->getScene(), Driver);
_IG->addToScene (*pI3DS->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() );
pI3DS->getScene()->setToGlobalInstanceGroup (_IG);
}
}

View file

@ -253,7 +253,8 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG )
#endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS
// ------------------------------------------------------------------------------------------------
CInterfaceManager::CInterfaceManager()
CInterfaceManager::CInterfaceManager() :
_ViewRenderer( Driver )
{
_Instance = this;
_DbRootNode = new CCDBNodeBranch("ROOT");

View file

@ -414,7 +414,7 @@ COptionsAnimationSet::~COptionsAnimationSet()
BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList
(see deleteAnimationSet() doc)
*/
Driver->deleteAnimationSet(AnimationSet);
CInterfaceManager::getInstance()->getViewRenderer().getDriver()->deleteAnimationSet(AnimationSet);
AnimationSet= NULL;
}
}
@ -424,10 +424,10 @@ bool COptionsAnimationSet::parse (xmlNodePtr cur)
{
bool result = CInterfaceOptions::parse(cur);
if (!result) return false;
nlassert(Driver);
nlassert( CInterfaceManager::getInstance()->getViewRenderer().getDriver() );
// create the animation set
AnimationSet= Driver->createAnimationSet();
AnimationSet= CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet();
nlassert(AnimationSet);
AnimMale.clear();

View file

@ -118,13 +118,14 @@ using namespace NLMISC;
void badLuaParseMessageBox()
{
NL3D::UDriver::TMessageBoxId ret = Driver->systemMessageBox( "LUA files reading failed!\n"
"Some LUA files are corrupted, moved or may have been removed.\n"
"Ryzom may need to be restarted to run properly.\n"
"Would you like to quit now?",
"LUA reading failed!",
NL3D::UDriver::yesNoType,
NL3D::UDriver::exclamationIcon);
NL3D::UDriver::TMessageBoxId ret =
CInterfaceManager::getInstance()->getViewRenderer().getDriver()->systemMessageBox( "LUA files reading failed!\n"
"Some LUA files are corrupted, moved or may have been removed.\n"
"Ryzom may need to be restarted to run properly.\n"
"Would you like to quit now?",
"LUA reading failed!",
NL3D::UDriver::yesNoType,
NL3D::UDriver::exclamationIcon);
if (ret == NL3D::UDriver::yesId)
{
extern void quitCrashReport ();

View file

@ -701,7 +701,7 @@ void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot)
{
// set new cursor for the hardware mouse
std::string name = rVR.getTextureNameFromId(texId);
Driver->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0));
rVR.getDriver()->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0));
}
}

View file

@ -30,45 +30,15 @@ using namespace NLMISC;
using namespace std;
using namespace NL3D;
/*
* constructor
*/
CViewRenderer::CViewRenderer()
CViewRenderer::CViewRenderer( NL3D::UDriver *driver )
{
_ClipX = _ClipY = 0;
_ClipW = 800;
_ClipH = 600;
_ScreenW = 800;
_ScreenH = 600;
_OneOverScreenW= 1.0f / (float)_ScreenW;
_OneOverScreenH= 1.0f / (float)_ScreenH;
_IsMinimized= false;
_WFigurTexture= 0;
_HFigurTexture= 0;
_WFigurSeparatorTexture = 0;
_FigurSeparatorTextureId = -1;
_FigurBlankId = -1;
_BlankId = -1;
_WorldSpaceTransformation = true;
_CurrentZ = 10;
for(uint i=0;i<VR_NUM_LAYER;i++)
{
_StringRBLayers[i]= NULL;
_EmptyLayer[i]= true;
}
_BlankGlobalTexture = NULL;
setup();
this->driver = driver;
}
/*
* destructor
*/
CViewRenderer::~CViewRenderer()
{
if (!_Material.empty() && Driver)
Driver->deleteMaterial(_Material);
for(uint i=0;i<VR_NUM_LAYER;i++)
{
delete _StringRBLayers[i];
@ -101,9 +71,9 @@ void CViewRenderer::setClipWindow (sint32 x, sint32 y, sint32 w, sint32 h)
*/
void CViewRenderer::checkNewScreenSize ()
{
if (!Driver) return;
if (!driver) return;
uint32 w, h;
Driver->getWindowSize (w, h);
driver->getWindowSize (w, h);
// not minimized? change coords
if(w!=0 && h!=0)
{
@ -145,14 +115,40 @@ void CViewRenderer::getScreenOOSize (float &oow, float &ooh)
ooh= _OneOverScreenH;
}
void CViewRenderer::setup()
{
_ClipX = _ClipY = 0;
_ClipW = 800;
_ClipH = 600;
_ScreenW = 800;
_ScreenH = 600;
_OneOverScreenW= 1.0f / (float)_ScreenW;
_OneOverScreenH= 1.0f / (float)_ScreenH;
_IsMinimized= false;
_WFigurTexture= 0;
_HFigurTexture= 0;
_WFigurSeparatorTexture = 0;
_FigurSeparatorTextureId = -1;
_FigurBlankId = -1;
_BlankId = -1;
_WorldSpaceTransformation = true;
_CurrentZ = 10;
for(uint i=0;i<VR_NUM_LAYER;i++)
{
_StringRBLayers[i]= NULL;
_EmptyLayer[i]= true;
}
_BlankGlobalTexture = NULL;
}
/*
* init: init material and string buffer
*/
void CViewRenderer::init()
{
if (!Driver) return;
_Material = Driver->createMaterial();
if (!driver) return;
_Material = driver->createMaterial();
setRenderStates();
@ -188,7 +184,7 @@ void CViewRenderer::reset()
UTextureFile *tf = dynamic_cast<NL3D::UTextureFile *>(ite->Texture);
if (tf)
{
Driver->deleteTextureFile (tf);
driver->deleteTextureFile (tf);
}
ite++;
}
@ -200,6 +196,10 @@ void CViewRenderer::reset()
_IndexesToTextureIds.clear();
}
NL3D::UDriver* CViewRenderer::getDriver(){
return driver;
}
// ***************************************************************************
void CViewRenderer::SImage::setupQuadUV(bool flipv, uint8 rot, CQuadColorUV &dest)
{
@ -711,7 +711,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std:
CIFile ifTmp;
if (ifTmp.open(filename))
CBitmap::loadSize (ifTmp, gt.Width, gt.Height);
gt.Texture = Driver->createTextureFile (filename);
gt.Texture = driver->createTextureFile (filename);
// Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again.
// Its why we don't release it at the end, because it is likely to be uploaded soon)
CBitmap *texDatas = gt.Texture->generateDatas();
@ -729,7 +729,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std:
_GlobalTextures.push_back (gt);
Driver->setCursorScale(ClientCfg.HardwareCursorScale);
driver->setCursorScale(ClientCfg.HardwareCursorScale);
char bufTmp[256], tgaName[256];
string sTGAname;
@ -781,7 +781,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std:
CBitmap curs;
curs.resize(x1 - x0, y1 - y0);
curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0);
Driver->addCursor(image.Name, curs);
driver->addCursor(image.Name, curs);
}
}
}
@ -877,7 +877,7 @@ sint32 CViewRenderer::createTexture (const std::string &sGlobalTextureName,
nlwarning("Failed to load the texture '%s', please check image format", filename.c_str());
}
}
gtTmp.Texture = Driver->createTextureFile (sLwrGTName);
gtTmp.Texture = driver->createTextureFile (sLwrGTName);
gtTmp.Name = sLwrGTName;
gtTmp.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff);
if(uploadDXTC)
@ -1007,7 +1007,7 @@ void CViewRenderer::deleteTexture (sint32 textureId)
UTextureFile *tf = dynamic_cast<NL3D::UTextureFile *>(iteGT->Texture);
if (tf)
{
Driver->deleteTextureFile (tf);
driver->deleteTextureFile (tf);
}
_GlobalTextures.erase (iteGT);
return;
@ -1151,13 +1151,13 @@ void CViewRenderer::flush ()
// draw quads and empty list
if (layer.NbQuads != 0)
{
Driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material);
driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material);
layer.NbQuads = 0;
}
if (!layer.Tris.empty())
{
Driver->drawTriangles(layer.Tris, _Material);
driver->drawTriangles(layer.Tris, _Material);
layer.Tris.clear();
}
@ -1178,12 +1178,12 @@ void CViewRenderer::flush ()
// alpha blended
if (!layer.FilteredAlphaBlendedQuads.empty())
{
Driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material);
driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material);
layer.FilteredAlphaBlendedQuads.clear();
}
if (!layer.FilteredAlphaBlendedTris.empty())
{
Driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material);
driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material);
layer.FilteredAlphaBlendedTris.clear();
}
// additif
@ -1193,12 +1193,12 @@ void CViewRenderer::flush ()
_Material.setBlendFunc (NL3D::UMaterial::one, NL3D::UMaterial::one);
if (!layer.FilteredAdditifQuads.empty())
{
Driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material);
driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material);
layer.FilteredAdditifQuads.clear();
}
if (!layer.FilteredAdditifTris.empty())
{
Driver->drawTriangles(layer.FilteredAdditifTris, _Material);
driver->drawTriangles(layer.FilteredAdditifTris, _Material);
layer.FilteredAdditifTris.clear();
}
// restore alpha blend
@ -1546,13 +1546,13 @@ URenderStringBuffer *CViewRenderer::getStringRenderBuffer(sint layerId)
// ***************************************************************************
void CViewRenderer::drawWiredQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/)
{
Driver->drawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col);
driver->drawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col);
}
// ***************************************************************************
void CViewRenderer::drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/)
{
Driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col);
driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col);
}
@ -1610,7 +1610,7 @@ void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height,
worldSpaceTransformation (qcoluv2_clipped);
// Draw clipped quad
Driver->drawQuads (&qcoluv2_clipped, 1, Mat);
driver->drawQuads (&qcoluv2_clipped, 1, Mat);
}
// ***************************************************************************
@ -1658,7 +1658,7 @@ void CViewRenderer::drawCustom(sint32 x, sint32 y, sint32 width, sint32 height,
}
// Draw clipped quad
Driver->drawQuads (&qcoluv_clipped, 1, Mat);
driver->drawQuads (&qcoluv_clipped, 1, Mat);
}
// ***************************************************************************
@ -1716,7 +1716,7 @@ void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height,
worldSpaceTransformation (qcoluv2_clipped);
// Draw clipped quad
Driver->drawQuads (&qcoluv2_clipped, 1, Mat);
driver->drawQuads (&qcoluv2_clipped, 1, Mat);
}
// ***************************************************************************

View file

@ -29,16 +29,6 @@
#include "../ingame_database_manager.h"
//the NEL 3d driver
extern NL3D::UDriver* Driver;
//the NEL 3d textcontext
extern NL3D::UTextContext *TextContext;
//the network database node
extern CCDBSynchronised IngameDbMngr;
// ***************************************************************************
#define VR_NUM_LAYER 32
#define VR_BIAS_LAYER (VR_NUM_LAYER/2)
@ -113,15 +103,13 @@ public:
sint32 _TextureId;
};
/**
* destructor
*/
CViewRenderer ();
/**
* destructor
*/
CViewRenderer( NL3D::UDriver *driver );
~CViewRenderer ();
/// setup the default values for everything
void setup();
/// init when TextContext and Driver are created
void init();
@ -131,6 +119,9 @@ public:
/// Delete all textures and the like and reset the view renderer
void reset();
/// Retrieves the 3d driver we are using
NL3D::UDriver* getDriver();
/*
* setClipWindow : set the current clipping window
* (this window do not inherit properties from parent or whatever)
@ -567,7 +558,9 @@ private:
NL3D::CFrustum _CameraFrustum; // Transform from screen space to world space
NLMISC::CMatrix _WorldSpaceMatrix; // Matrix to be applied for world space transformation
bool _WorldSpaceScale;
NL3D::UDriver *driver;
};

View file

@ -300,7 +300,6 @@ void CObjectRefIdClient::getNameInParent(std::string &name, sint32 &indexInArray
nlwarning("ObservedObject parent instance ptr = %p", parent);
parent->getLuaProjection().dump();
}
Driver->systemMessageBox("Bug catched, please send log.log to vizerie@nevrax.com", "nevrax internal", NL3D::UDriver::okType, NL3D::UDriver::exclamationIcon);
nlassert(0); // not found in parent
}