53 #include <OpenFlipper/Utils/Memory/RAMInfo.hh>
56 #define GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
57 #define GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
65 void MemInfoPlugin::pluginsInitialized() {
68 QString glExtensions = QString((
const char*)glGetString(GL_EXTENSIONS));
74 if ( glExtensions.contains(
"GL_NVX_gpu_memory_info") ) {
80 gpuMemBar_->setFormat(
"GPU Mem %p% %v/%m MB" );
114 MemInfoPlugin::MemInfoPlugin():
122 MemInfoPlugin::~MemInfoPlugin() {
130 GLint total_mem_kb = 0;
131 glGetIntegerv(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &total_mem_kb);
134 GLint cur_avail_mem_kb = 0;
135 glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
137 gpuMemBar_->setRange( 0 , total_mem_kb/1024 );
138 gpuMemBar_->setValue( (total_mem_kb-cur_avail_mem_kb)/1024);
146 unsigned long totalRamMB = Utils::Memory::queryTotalRAM();
147 unsigned long freeRamMB = Utils::Memory::queryFreeRAM();
158 const int val = _bar->value();
159 const int maxVal = _bar->maximum();
162 float redPerc = (val > 0.5f*maxVal) ? 2.f*(val-0.5f*maxVal) : 0.f;
163 const quint32 red = 255.f*redPerc/maxVal;
164 const quint32 green = 255u-red;
165 const quint32 blue = 0u;
168 const quint32 color = (red<<16)+(green<<8)+blue;
169 _bar->setStyleSheet(QString(
" QProgressBar { border: 2px solid grey; border-radius: 2px; text-align: center; } QProgressBar::chunk {background-color: #%1; width: 1px;}").arg(color,6,16,QChar(
'0')));
173 #if QT_VERSION < 0x050000
void nvidiaMemoryInfoUpdate()
Update statusbar with NVIDIA memory infos.
void initializePlugin()
BaseInterface.
QProgressBar * gpuMemBar_
Status bar for GPU memory.
QTimer * updateTimer_
Timer that triggers an update of the bars.
void setProgressBarStyleSheet(QProgressBar *_bar)
Sets the Qt Stylesheet for the progress bars.
void cpuMemoryInfoUpdate()
Update statusbar with main memory infos.
QProgressBar * mainMemBar_
Status bar for Main memory.