Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2015-12-26 14:38:37 +01:00
commit 4806693f49
13 changed files with 317 additions and 91 deletions

View file

@ -169,7 +169,7 @@ namespace NLGUI
/* /*
* getScreenSize : get the screen window size changed (at last checkNewScreenSize called) * getScreenSize : get the screen window size changed (at last checkNewScreenSize called)
*/ */
void getScreenSize (uint32 &w, uint32 &h); void getScreenSize(uint32 &w, uint32 &h);
/* /*
* get OOW / OOH * get OOW / OOH

View file

@ -335,7 +335,7 @@ namespace NLGUI
sint32 newW, sint32 newH) const; sint32 newW, sint32 newH) const;
// move windows according to new screen size // move windows according to new screen size
void moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI ); void moveAllWindowsToNewScreenSize(uint32 newScreenW, uint32 newScreenH, bool fixCurrentUI );
void updateAllLocalisedElements(); void updateAllLocalisedElements();
@ -481,7 +481,7 @@ namespace NLGUI
void setIngame( bool i ){ inGame = i; } void setIngame( bool i ){ inGame = i; }
bool isIngame() const{ return inGame; } bool isIngame() const{ return inGame; }
void setScreenWH( uint32 w, uint32 h ){ screenW = w; screenH = h; } void setScreenWH(uint32 w, uint32 h){ _ScreenW = w; _ScreenH = h; }
void registerNewScreenSizeHandler( INewScreenSizeHandler *handler ); void registerNewScreenSizeHandler( INewScreenSizeHandler *handler );
void removeNewScreenSizeHandler( INewScreenSizeHandler *handler ); void removeNewScreenSizeHandler( INewScreenSizeHandler *handler );
@ -612,8 +612,8 @@ namespace NLGUI
CEventDescriptorKey lastKeyEvent; CEventDescriptorKey lastKeyEvent;
uint32 screenH; uint32 _ScreenH;
uint32 screenW; uint32 _ScreenW;
std::vector< CInterfaceAnim* > activeAnims; std::vector< CInterfaceAnim* > activeAnims;

View file

@ -2087,6 +2087,7 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
GfxMode mode; GfxMode mode;
mode.Width = sizes[i].width; mode.Width = sizes[i].width;
mode.Height = sizes[i].height; mode.Height = sizes[i].height;
mode.Depth = 32;
mode.Frequency = 0; mode.Frequency = 0;
modes.push_back(mode); modes.push_back(mode);
// nldebug("3D: Mode %d: %dx%d", i, mode.Width, mode.Height); // nldebug("3D: Mode %d: %dx%d", i, mode.Width, mode.Height);

View file

@ -56,19 +56,17 @@ void CQuadEffect::makeRasters(const TPoint2DVect &poly
{ {
dest.clear(); dest.clear();
const float epsilon = 10E-5f; startY = 0.f;
sint size = (sint)poly.size(); sint size = (sint)poly.size();
if (!size) return;
const float epsilon = 10E-5f;
uint aelSize = 0; // size of active edge list uint aelSize = 0; // size of active edge list
sint k; // loop counter sint k; // loop counter
dest.clear();
if (!size) return;
static TEdgeList lel, ael; // the left edge list, and the active edge list static TEdgeList lel, ael; // the left edge list, and the active edge list
float highest = poly[0].y; float highest = poly[0].y;
lel.clear(); lel.clear();
@ -217,7 +215,8 @@ void CQuadEffect::makeRasters(const TPoint2DVect &poly
currY += quadHeight; currY += quadHeight;
} while (size || aelSize); }
while (size || aelSize);
} }
//** //**

View file

@ -1640,6 +1640,9 @@ void CWaterModel::traverseRender()
for(sint k = 0; k < (sint) poly.Vertices.size() - 2; ++k) for(sint k = 0; k < (sint) poly.Vertices.size() - 2; ++k)
{ {
NLMISC::CTriangleUV truv; NLMISC::CTriangleUV truv;
truv.Uv0.set(0.f, 0.f);
truv.Uv1.set(0.f, 0.f);
truv.Uv2.set(0.f, 0.f);
truv.V0.set(poly.Vertices[0].x, poly.Vertices[0].y, 0.f); truv.V0.set(poly.Vertices[0].x, poly.Vertices[0].y, 0.f);
truv.V1.set(poly.Vertices[k + 1].x, poly.Vertices[k + 1].y, 0.f); truv.V1.set(poly.Vertices[k + 1].x, poly.Vertices[k + 1].y, 0.f);
truv.V2.set(poly.Vertices[k + 2].x, poly.Vertices[k + 2].y, 0.f); truv.V2.set(poly.Vertices[k + 2].x, poly.Vertices[k + 2].y, 0.f);

View file

@ -64,7 +64,7 @@ namespace NLGUI
rVR.getClipWindow(x, y, w, h); rVR.getClipWindow(x, y, w, h);
uint32 sw, sh; uint32 sw, sh;
rVR.getScreenSize(sw, sh); rVR.getScreenSize(sw, sh);
rVR.setClipWindow(0, 0, (sint32) sw, (sint32) sh); rVR.setClipWindow(0, 0, (sint32)sw, (sint32)sh);
rVR.drawRotFlipBitmap (renderLayer, xreal, yreal, wreal, hreal, 0, false, rVR.getBlankTextureId(), color ); rVR.drawRotFlipBitmap (renderLayer, xreal, yreal, wreal, hreal, 0, false, rVR.getBlankTextureId(), color );
rVR.setClipWindow(x, y, w ,h); rVR.setClipWindow(x, y, w ,h);
} }
@ -350,7 +350,7 @@ namespace NLGUI
{ {
if (_ResizerPos & Hotspot_xR) if (_ResizerPos & Hotspot_xR)
{ {
clippedNewW = std::min((sint32) sw + _Parent->getW() - _Parent->getXReal(), clippedNewW); clippedNewW = std::min((sint32)sw + _Parent->getW() - _Parent->getXReal(), clippedNewW);
} }
else else
{ {
@ -365,7 +365,7 @@ namespace NLGUI
} }
else else
{ {
clippedNewW = std::min((sint32) sw - _Parent->getXReal(), clippedNewW); clippedNewW = std::min((sint32)sw - _Parent->getXReal(), clippedNewW);
} }
} }
// //

View file

@ -715,7 +715,7 @@ namespace NLGUI
// *** Get the column sizes, we need to know min for the table // *** Get the column sizes, we need to know min for the table
uint i; uint i;
sint column = 0; uint column = 0;
_Columns.clear (); _Columns.clear ();
for (i=0; i<_Cells.size(); i++) for (i=0; i<_Cells.size(); i++)
{ {
@ -764,7 +764,7 @@ namespace NLGUI
} }
// Resize the array // Resize the array
if (column>=_Columns.size()) if (column >= _Columns.size())
_Columns.resize(column+1); _Columns.resize(column+1);
// Handle rowspan from previous row // Handle rowspan from previous row
@ -773,7 +773,7 @@ namespace NLGUI
_Columns[column].RowSpan--; _Columns[column].RowSpan--;
column++; column++;
// if previous row had less <TD> elements, then we missing columns // if previous row had less <TD> elements, then we missing columns
if (column>=_Columns.size()) if (column >= _Columns.size())
_Columns.resize(column+1); _Columns.resize(column+1);
} }
@ -783,13 +783,12 @@ namespace NLGUI
// new column, set rowspan from current <TD> // new column, set rowspan from current <TD>
_Columns[column].RowSpan = cell->RowSpan; _Columns[column].RowSpan = cell->RowSpan;
float colspan = 1.f / cell->ColSpan; float colspan = 1.f / cell->ColSpan;
float rowspan = 1.f / cell->RowSpan;
// Update sizes // Update sizes
if (cellWidth*colspan > _Columns[column].Width) if (cellWidth*colspan > _Columns[column].Width)
_Columns[column].Width = cellWidth*colspan; _Columns[column].Width = (sint32)(cellWidth*colspan);
if (cell->WidthMax*colspan > _Columns[column].WidthMax) if (cell->WidthMax*colspan > _Columns[column].WidthMax)
_Columns[column].WidthMax = cell->WidthMax*colspan; _Columns[column].WidthMax = (sint32)(cell->WidthMax*colspan);
if (cell->TableRatio*colspan > _Columns[column].TableRatio) if (cell->TableRatio*colspan > _Columns[column].TableRatio)
_Columns[column].TableRatio = cell->TableRatio*colspan; _Columns[column].TableRatio = cell->TableRatio*colspan;
if (cell->WidthWanted*colspan + additionnalWidth > _Columns[column].WidthWanted) if (cell->WidthWanted*colspan + additionnalWidth > _Columns[column].WidthWanted)
@ -1035,7 +1034,7 @@ namespace NLGUI
if (cell->TableColumnIndex > 0) if (cell->TableColumnIndex > 0)
{ {
// we have active rowspan, must add up 'skipped' columns // we have active rowspan, must add up 'skipped' columns
for( ; column<cell->TableColumnIndex; ++column) for( ; column < (uint)cell->TableColumnIndex; ++column)
currentX += _Columns[column].Width + padding*2 + CellSpacing; currentX += _Columns[column].Width + padding*2 + CellSpacing;
} }
@ -1081,7 +1080,7 @@ namespace NLGUI
cell->Group->updateCoords(); cell->Group->updateCoords();
// Resize the row array // Resize the row array
float rowspan = 1 / cell->RowSpan; float rowspan = 1.f / (float)cell->RowSpan;
_Rows.back().Height = std::max((sint32)(cell->Height*rowspan), std::max(_Rows.back().Height, (sint32)(cell->Group->getH()*rowspan))); _Rows.back().Height = std::max((sint32)(cell->Height*rowspan), std::max(_Rows.back().Height, (sint32)(cell->Group->getH()*rowspan)));
// Next column // Next column

View file

@ -398,7 +398,7 @@ namespace NLGUI
{ {
time_t now; time_t now;
time(&now); time(&now);
if (expires < now) if (expires < (uint32)now)
{ {
nlwarning("cookie expired, remove from list '%s'", nsformat); nlwarning("cookie expired, remove from list '%s'", nsformat);
HTTPCookies[domain].erase(chunks[5]); HTTPCookies[domain].erase(chunks[5]);

View file

@ -1722,8 +1722,8 @@ namespace NLGUI
// *** First detect from which screen position the window is the more sticked (borders or center) // *** First detect from which screen position the window is the more sticked (borders or center)
// In X: best hotspot is left, middle or right? // In X: best hotspot is left, middle or right?
sint32 posXToLeft= x; sint32 posXToLeft= x;
sint32 posXToMiddle= x+w/2-screenW/2; sint32 posXToMiddle= x+w/2-_ScreenW/2;
sint32 posXToRight= screenW-(x+w); sint32 posXToRight= _ScreenW-(x+w);
sint32 bestXHotSpot= Hotspot_xL; sint32 bestXHotSpot= Hotspot_xL;
sint32 bestXPosVal= posXToLeft; sint32 bestXPosVal= posXToLeft;
if(abs(posXToMiddle) < bestXPosVal) if(abs(posXToMiddle) < bestXPosVal)
@ -1740,8 +1740,8 @@ namespace NLGUI
// Same In Y: best hotspot is bottom, middle or top? // Same In Y: best hotspot is bottom, middle or top?
// remember here that y is the top of window (relative to bottom of screen) // remember here that y is the top of window (relative to bottom of screen)
sint32 posYToBottom= y-h; sint32 posYToBottom= y-h;
sint32 posYToMiddle= y-h/2-screenH/2; sint32 posYToMiddle= y-h/2-_ScreenH/2;
sint32 posYToTop= screenH-y; sint32 posYToTop= _ScreenH-y;
sint32 bestYHotSpot= Hotspot_Bx; sint32 bestYHotSpot= Hotspot_Bx;
sint32 bestYPosVal= posYToBottom; sint32 bestYPosVal= posYToBottom;
const sint32 middleYWeight= 6; // Avoid default Mission/Team/Map/ContactList positions to be considered as "middle" const sint32 middleYWeight= 6; // Avoid default Mission/Team/Map/ContactList positions to be considered as "middle"
@ -1774,13 +1774,13 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CWidgetManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI) void CWidgetManager::moveAllWindowsToNewScreenSize(uint32 newScreenW, uint32 newScreenH, bool fixCurrentUI)
{ {
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = getAllMasterGroup(); std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = getAllMasterGroup();
// If resolutions correctly setuped, and really different from new setup // If resolutions correctly setuped, and really different from new setup
if( screenW >0 && screenH>0 && if( _ScreenW >0 && _ScreenH>0 &&
newScreenW >0 && newScreenH>0 && newScreenW >0 && newScreenH>0 &&
( screenW != newScreenW || screenH != newScreenH) ( _ScreenW != newScreenW || _ScreenH != newScreenH)
) )
{ {
// *** Do it for the Active Desktop (if wanted) // *** Do it for the Active Desktop (if wanted)
@ -1790,13 +1790,13 @@ namespace NLGUI
for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{ {
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if(!rMG.Group || rMG.Group->getId()!="ui:interface") if (!rMG.Group || rMG.Group->getId() != "ui:interface")
continue; continue;
// For all priorities, but the worldspace one // For all priorities, but the worldspace one
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)
{ {
if(nPriority==WIN_PRIORITY_WORLD_SPACE) if (nPriority==WIN_PRIORITY_WORLD_SPACE)
continue; continue;
// For All windows (only layer 0 group container) // For All windows (only layer 0 group container)
@ -1842,8 +1842,8 @@ namespace NLGUI
// Now those are the last screen coordinates used for window position correction // Now those are the last screen coordinates used for window position correction
if(newScreenW >0 && newScreenH>0) if(newScreenW >0 && newScreenH>0)
{ {
screenW = newScreenW; _ScreenW = newScreenW;
screenH = newScreenH; _ScreenH = newScreenH;
} }
} }
@ -1966,13 +1966,13 @@ namespace NLGUI
uint32 w, h; uint32 w, h;
CViewRenderer::getInstance()->checkNewScreenSize (); CViewRenderer::getInstance()->checkNewScreenSize ();
CViewRenderer::getInstance()->getScreenSize (w, h); CViewRenderer::getInstance()->getScreenSize (w, h);
if ((w != screenW) || (h != screenH)) if ((w != _ScreenW) || (h != _ScreenH))
{ {
// No Op if screen minimized // No Op if screen minimized
if(w!=0 && h!=0 && !CViewRenderer::getInstance()->isMinimized()) if(w!=0 && h!=0 && !CViewRenderer::getInstance()->isMinimized())
{ {
updateAllLocalisedElements (); updateAllLocalisedElements ();
setScreenWH( w, h ); setScreenWH(w, h);
} }
} }
@ -2075,18 +2075,18 @@ namespace NLGUI
} }
// Draw the pointer and DND Item // Draw the pointer and DND Item
if( getPointer() != NULL) if (getPointer() != NULL)
{ {
if ( getPointer()->getActive()) if (getPointer()->getActive())
getPointer()->draw (); getPointer()->draw ();
} }
if( CInterfaceElement::getEditorMode() ) if (CInterfaceElement::getEditorMode())
{ {
for( int i = 0; i < editorSelection.size(); i++ ) for(uint i = 0; i < editorSelection.size(); ++i)
{ {
CInterfaceElement *e = getElementFromId( editorSelection[ i ] ); CInterfaceElement *e = getElementFromId(editorSelection[i]);
if( e != NULL ) if (e != NULL)
e->drawHighlight(); e->drawHighlight();
} }
} }
@ -3376,8 +3376,8 @@ namespace NLGUI
void CWidgetManager::getEditorSelection( std::vector< std::string > &selection ) void CWidgetManager::getEditorSelection( std::vector< std::string > &selection )
{ {
selection.clear(); selection.clear();
for( int i = 0; i < editorSelection.size(); i++ ) for(uint i = 0; i < editorSelection.size(); ++i)
selection.push_back( editorSelection[ i ] ); selection.push_back(editorSelection[i]);
} }
void CWidgetManager::selectWidget( const std::string &name ) void CWidgetManager::selectWidget( const std::string &name )
@ -3539,11 +3539,11 @@ namespace NLGUI
std::vector< CInterfaceElement* > elms; std::vector< CInterfaceElement* > elms;
// Resolve the widget names // Resolve the widget names
for( int i = 0; i < editorSelection.size(); i++ ) for(uint i = 0; i < editorSelection.size(); ++i)
{ {
CInterfaceElement *e = getElementFromId( editorSelection[ i ] ); CInterfaceElement *e = getElementFromId(editorSelection[i]);
if( e != NULL ) if (e != NULL)
elms.push_back( e ); elms.push_back(e);
} }
editorSelection.clear(); editorSelection.clear();
@ -3562,21 +3562,21 @@ namespace NLGUI
std::string oldId; std::string oldId;
// Reparent the widgets to the new group // Reparent the widgets to the new group
for( int i = 0; i < elms.size(); i++ ) for(uint i = 0; i < elms.size(); ++i)
{ {
CInterfaceElement *e = elms[ i ]; CInterfaceElement *e = elms[i];
oldId = e->getId(); oldId = e->getId();
CInterfaceGroup *p = e->getParent(); CInterfaceGroup *p = e->getParent();
if( p != NULL ) if (p != NULL)
p->takeElement( e ); p->takeElement(e);
g->addElement( e ); g->addElement(e);
e->setParent( g ); e->setParent(g);
e->setParentPos( g ); e->setParentPos(g);
e->setParentSize( g ); e->setParentSize(g);
e->setIdRecurse( e->getShortId() ); e->setIdRecurse(e->getShortId());
onWidgetMoved( oldId, e->getId() ); onWidgetMoved(oldId, e->getId());
} }
elms.clear(); elms.clear();
@ -3631,7 +3631,7 @@ namespace NLGUI
{ {
reset(); reset();
for( int i = 0; i < _MasterGroups.size(); i++ ) for(uint i = 0; i < _MasterGroups.size(); ++i)
delete _MasterGroups[i].Group; delete _MasterGroups[i].Group;
_MasterGroups.clear(); _MasterGroups.clear();
@ -3724,7 +3724,7 @@ namespace NLGUI
_MouseOverWindow = false; _MouseOverWindow = false;
inGame = false; inGame = false;
setScreenWH( 0, 0 ); setScreenWH(0, 0);
_GroupSelection = false; _GroupSelection = false;
multiSelection = false; multiSelection = false;

View file

@ -214,12 +214,13 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f )
dstOffset+= dstChannels; dstOffset+= dstChannels;
uint32 index = curFrame->RasterBits[srcOffset]; uint32 index = curFrame->RasterBits[srcOffset];
if (index != transparency)
if ((sint32)index != transparency)
{ {
// make sure color index is not outside colormap // make sure color index is not outside colormap
if (ColorMap) if (ColorMap)
{ {
if (index > ColorMap->ColorCount) if ((sint)index > ColorMap->ColorCount)
{ {
index = 0; index = 0;
} }
@ -260,12 +261,13 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f )
dstOffset+= dstChannels; dstOffset+= dstChannels;
uint32 index = curFrame->RasterBits[srcOffset]; uint32 index = curFrame->RasterBits[srcOffset];
if (index != transparency)
if ((sint32)index != transparency)
{ {
// make sure color index is not outside colormap // make sure color index is not outside colormap
if (ColorMap) if (ColorMap)
{ {
if (index > ColorMap->ColorCount) if ((sint)index > ColorMap->ColorCount)
{ {
index = 0; index = 0;
} }

View file

@ -32,6 +32,8 @@
# include <ShObjIdl.h> # include <ShObjIdl.h>
# define TASKBAR_PROGRESS 1 # define TASKBAR_PROGRESS 1
# endif # endif
#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
#include "nel/misc/file.h"
#endif #endif
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
@ -472,7 +474,7 @@ sint CSystemUtils::getTotalVideoMemory()
{ {
sint res = -1; sint res = -1;
#ifdef NL_OS_WINDOWS #if defined(NL_OS_WINDOWS)
// using DXGI // using DXGI
HINSTANCE hDXGI = LoadLibraryA("dxgi.dll"); HINSTANCE hDXGI = LoadLibraryA("dxgi.dll");
@ -596,8 +598,192 @@ sint CSystemUtils::getTotalVideoMemory()
nlwarning("Unable to load ddraw.dll"); nlwarning("Unable to load ddraw.dll");
} }
} }
#elif defined(NL_OS_MAC)
// the right method is using OpenGL
#else #else
// TODO: implement for other systems // under Linux, no method is really reliable...
NLMISC::CIFile file;
std::string logFile = "/var/log/Xorg.0.log";
// parse last Xorg.0.log
if (file.open(logFile, true))
{
char buffer[256];
while(!file.eof())
{
file.getline(buffer, 256);
if (buffer[0] == '\0') break;
std::string line(buffer);
// nvidia driver
std::string::size_type pos = line.find(") NVIDIA(");
if (pos != std::string::npos)
{
// [ 20.883] (--) NVIDIA(0): Memory: 2097152 kBytes
pos = line.find("Memory: ", pos);
// found memory line
if (pos == std::string::npos) continue;
pos += 8;
std::string::size_type posUnits = line.find(" kBytes", pos);
// found units in KiB
if (posUnits == std::string::npos) continue;
std::string videoMemory = line.substr(pos, posUnits-pos);
if (!NLMISC::fromString(videoMemory, res)) continue;
nlinfo("Xorg NVIDIA driver reported %d KiB of video memory", res);
break;
}
// intel driver
pos = line.find(") intel(");
if (pos != std::string::npos)
{
// (**) intel(0): VideoRam: 131072 KB
pos = line.find("VideoRam: ", pos);
// found memory line
if (pos == std::string::npos) continue;
pos += 10;
std::string::size_type posUnits = line.find(" KB", pos);
// found units in KiB
if (posUnits == std::string::npos) continue;
std::string videoMemory = line.substr(pos, posUnits-pos);
if (!NLMISC::fromString(videoMemory, res)) continue;
nlinfo("Xorg Intel driver reported %d KiB of video memory", res);
break;
}
// TODO: other drivers: nv, fglrx (ATI), radeon (ATI)
}
file.close();
}
if (res == -1)
{
// use lspci
std::string command = "lspci";
std::string out = getCommandOutput(command);
if (out.empty())
{
nlwarning("Unable to launch %s", command.c_str());
}
else
{
std::vector<std::string> lines;
std::string deviceId;
explode(out, std::string("\n"), lines, true);
// process each line
for(uint i = 0; i < lines.size(); ++i)
{
std::string line = lines[i];
if (line.find("VGA") == std::string::npos &&
line.find("3D") == std::string::npos &&
line.find("2D") == std::string::npos)
continue;
std::string::size_type pos = line.find(' ');
if (pos == std::string::npos) continue;
// found device ID
deviceId = line.substr(0, pos);
break;
}
if (deviceId.empty())
{
nlwarning("Unable to find a 3D device with lspci");
}
else
{
command = "lspci -v -s " + deviceId;
out = getCommandOutput(command);
if (out.empty())
{
nlwarning("Unable to launch %s", command.c_str());
}
else
{
explode(out, std::string("\n"), lines, true);
// process each line
for(uint i = 0; i < lines.size(); ++i)
{
std::string line = lines[i];
// look for a size
std::string::size_type pos0 = line.find("[size=");
if (pos0 == std::string::npos) continue;
// move to first digit
pos0 += 6;
// end of the size
std::string::size_type pos1 = line.find("]", pos0);
if (pos1 == std::string::npos) continue;
sint units;
if (line.substr(pos1-1, 1) == "M")
{
// size in MiB
units = 1024;
--pos1;
}
else if (line.substr(pos1-1, 1) == "K")
{
// size in KiB
units = 1;
--pos1;
}
else
{
// size in B
units = 0;
}
// extract the size
std::string sizeStr = line.substr(pos0, pos1-pos0);
// convert size to integer with right units
sint tmpSize;
if (!NLMISC::fromString(sizeStr, tmpSize)) continue;
tmpSize *= units;
// take the higher size (up to 256 MiB apparently)
if (tmpSize > res) res = tmpSize;
}
nlinfo("lspci reported %d KiB of video memory", res);
}
}
}
}
#endif #endif
return res; return res;

View file

@ -152,8 +152,10 @@ bool UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING;
#define ENTITY_TEXTURE_NORMAL_LEVEL 1 #define ENTITY_TEXTURE_NORMAL_LEVEL 1
#define ENTITY_TEXTURE_HIGH_LEVEL 0 #define ENTITY_TEXTURE_HIGH_LEVEL 0
// Size in MB of the cache for entity texturing. // Size in MB of the cache for entity texturing.
#define ENTITY_TEXTURE_NORMAL_MEMORY 40 #define ENTITY_TEXTURE_LOW_MEMORY 10 // 64, 32 or less
#define ENTITY_TEXTURE_HIGH_MEMORY 160 #define ENTITY_TEXTURE_NORMAL_MEMORY 40 // 128
#define ENTITY_TEXTURE_HIGH_MEMORY 80 // 256
#define ENTITY_TEXTURE_VERY_HIGH_MEMORY 160 // 512 and more
// Size in KB of max upload per frame // Size in KB of max upload per frame
#define ENTITY_TEXTURE_LOW_MAXUP 64 #define ENTITY_TEXTURE_LOW_MAXUP 64
#define ENTITY_TEXTURE_NORMAL_MAXUP 128 #define ENTITY_TEXTURE_NORMAL_MAXUP 128
@ -884,33 +886,67 @@ void initMainLoop()
// setup according to client // setup according to client
if (ClientCfg.HDTextureInstalled) if (ClientCfg.HDTextureInstalled)
{ {
if(ClientCfg.HDEntityTexture) sint videoMemory;
{
// temporary code for debug
sint videoMemory = Driver->getTotalVideoMemory();
// only detect amount of video memory if using HD textures
if (ClientCfg.HDEntityTexture)
{
// determine video memory using 3D driver
videoMemory = Driver->getTotalVideoMemory();
// if unable to determine, use plaform methods
if (videoMemory < 0) videoMemory = CSystemUtils::getTotalVideoMemory(); if (videoMemory < 0) videoMemory = CSystemUtils::getTotalVideoMemory();
// in the worst case, use default value of 128 MiB
if (videoMemory < 0) videoMemory = 128 * 1024;
videoMemory /= 1024; // size in MiB videoMemory /= 1024; // size in MiB
nlinfo("Video Memory detected: %d MiB", videoMemory); nlinfo("Video memory detected: %d MiB", videoMemory);
// setup "v2 texture" (or 512*512)
Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, ENTITY_TEXTURE_HIGH_LEVEL);
// Allow a big cache for them (should be on 512 Mo card only)
Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_HIGH_MEMORY*1024*1024);
// Allow high upload
Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_HIGH_MAXUP*1024);
} }
else else
{ {
// setup "v1 texture" (or 256*256) // 32 MiB of VRAM if DivideTextureSizeBy2 else 64 MiB
Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, ENTITY_TEXTURE_NORMAL_LEVEL); videoMemory = ClientCfg.DivideTextureSizeBy2 ? 32:64;
// Allow a big cache for them
Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_NORMAL_MEMORY*1024*1024);
// Allow normal upload
Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_NORMAL_MAXUP*1024);
} }
uint maxText, maxLevel, maxup;
if (videoMemory > 256)
{
// 512 MB or higher
maxLevel = ENTITY_TEXTURE_HIGH_LEVEL;
maxText = ENTITY_TEXTURE_VERY_HIGH_MEMORY;
maxup = ENTITY_TEXTURE_HIGH_MAXUP;
}
else if (videoMemory > 128)
{
// 256 MB
maxLevel = ENTITY_TEXTURE_HIGH_LEVEL;
maxText = ENTITY_TEXTURE_HIGH_MEMORY;
maxup = ENTITY_TEXTURE_HIGH_MAXUP;
}
else if (videoMemory > 64)
{
// 128 MB
maxLevel = ENTITY_TEXTURE_NORMAL_LEVEL;
maxText = ENTITY_TEXTURE_NORMAL_MEMORY;
maxup = ENTITY_TEXTURE_HIGH_MAXUP;
}
else
{
// 64 MB or lower
maxLevel = ENTITY_TEXTURE_NORMAL_LEVEL;
maxText = ENTITY_TEXTURE_LOW_MEMORY;
maxup = ENTITY_TEXTURE_NORMAL_MAXUP;
}
// setup "v2 texture" (or 512*512) or "v1 texture" (or 256*256)
Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, maxLevel);
// Allow a big cache for them
Driver->setupMaxTotalAsyncTextureSize(maxText*1024*1024);
// Allow normal or high upload
Driver->setupAsyncTextureMaxUploadPerFrame(maxup*1024);
} }
else else
{ {
@ -919,7 +955,7 @@ void initMainLoop()
*/ */
Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL-1, ENTITY_TEXTURE_NORMAL_LEVEL-1); Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL-1, ENTITY_TEXTURE_NORMAL_LEVEL-1);
// Allow a big cache for them // Allow a big cache for them
Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_NORMAL_MEMORY*1024*1024); Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_LOW_MEMORY*1024*1024);
// Allow low upload // Allow low upload
Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_LOW_MAXUP*1024); Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_LOW_MAXUP*1024);
} }

View file

@ -495,8 +495,8 @@ CInterfaceManager::CInterfaceManager()
CViewRenderer::getInstance()->checkNewScreenSize(); CViewRenderer::getInstance()->checkNewScreenSize();
{ {
uint32 w,h; uint32 w,h;
CViewRenderer::getInstance()->getScreenSize( w, h ); CViewRenderer::getInstance()->getScreenSize(w, h);
CWidgetManager::getInstance()->setScreenWH( w, h ); CWidgetManager::getInstance()->setScreenWH(w, h);
} }
CViewRenderer::getInstance()->init(); CViewRenderer::getInstance()->init();