improved performance using my own tga load function always instead of QImage
improved Profiler
This commit is contained in:
parent
d1c68e8ba6
commit
4342260e6d
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#include <QElapsedTimer.h>
|
#include <QElapsedTimer.h>
|
||||||
|
#include <QString>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define TIC Profiler::getInstance().startTimer();
|
#define TIC(val) Profiler::getInstance().startTimer(val);
|
||||||
#define TOC Profiler::getInstance().takeTime();
|
#define TOC(val) Profiler::getInstance().takeTime(val);
|
||||||
|
|
||||||
class Profiler
|
class Profiler
|
||||||
{
|
{
|
||||||
|
@ -21,16 +22,17 @@
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startTimer() {
|
void startTimer(QString position = "") {
|
||||||
|
std::cout << "from: " << position.toStdString() << std::endl;
|
||||||
timer.restart();
|
timer.restart();
|
||||||
};
|
};
|
||||||
|
|
||||||
void takeTime() {
|
void takeTime(QString position = "") {
|
||||||
std::cout << "time elapsed: " << timer.elapsed() << std::endl;
|
std::cout << "to: "<< position.toStdString() << " time elapsed: " << timer.elapsed() << std::endl;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define TIC
|
#define TIC(val)
|
||||||
#define TOC
|
#define TOC(val)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
#include "..\Header\Profiler.h"
|
||||||
|
|
||||||
QImage loadTga(QString filePath, bool &success)
|
QImage loadTga(QString filePath, bool &success)
|
||||||
{
|
{
|
||||||
QImage img;
|
QImage img;
|
||||||
if (!img.load(filePath))
|
|
||||||
{
|
|
||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
std::fstream fsPicture(filePath.toStdString().c_str(), std::ios::in | std::ios::binary);
|
std::fstream fsPicture(filePath.toStdString().c_str(), std::ios::in | std::ios::binary);
|
||||||
|
@ -133,7 +132,7 @@ QImage loadTga(QString filePath, bool &success)
|
||||||
}
|
}
|
||||||
|
|
||||||
fsPicture.close();
|
fsPicture.close();
|
||||||
}
|
|
||||||
success = true;
|
success = true;
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "..\Header\OutputDevice.h"
|
#include "..\Header\OutputDevice.h"
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
#include "..\Header\Profiler.h"
|
||||||
|
|
||||||
// helper function to save data from file to any variable type
|
// helper function to save data from file to any variable type
|
||||||
#define F2V(variableName) reinterpret_cast<char*>(&variableName)
|
#define F2V(variableName) reinterpret_cast<char*>(&variableName)
|
||||||
|
|
||||||
|
@ -278,7 +280,6 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||||
curMat->flags[i] = (std::uint8_t)(flag << (7 - i)) >> 7;
|
curMat->flags[i] = (std::uint8_t)(flag << (7 - i)) >> 7;
|
||||||
|
|
||||||
curMat->transparent = curMat->flags[2] || curMat->flags[3] || curMat->flags[4] || curMat->flags[6] || curMat->rendertype == 4;
|
curMat->transparent = curMat->flags[2] || curMat->flags[3] || curMat->flags[4] || curMat->flags[6] || curMat->rendertype == 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// texture 0
|
// texture 0
|
||||||
|
@ -310,7 +311,6 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||||
|
|
||||||
if (!m_materials->back().tx1d.isEmpty())
|
if (!m_materials->back().tx1d.isEmpty())
|
||||||
loadTexture(m_materials->back().texture1, m_filepath, m_materials->back().tx1d);
|
loadTexture(m_materials->back().texture1, m_filepath, m_materials->back().tx1d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// texture 2
|
// texture 2
|
||||||
|
@ -719,6 +719,7 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position)
|
||||||
void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QString& filename)
|
void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QString& filename)
|
||||||
{
|
{
|
||||||
bool loadSuccess(false);
|
bool loadSuccess(false);
|
||||||
|
|
||||||
QImage img = loadTga(filepath + "/" + filename, loadSuccess);
|
QImage img = loadTga(filepath + "/" + filename, loadSuccess);
|
||||||
|
|
||||||
if (!loadSuccess)
|
if (!loadSuccess)
|
||||||
|
|
|
@ -428,8 +428,12 @@ void OglViewerWidget::setAmbCoef(double value)
|
||||||
void OglViewerWidget::setHeadlight(bool value)
|
void OglViewerWidget::setHeadlight(bool value)
|
||||||
{
|
{
|
||||||
m_light.headlight = value;
|
m_light.headlight = value;
|
||||||
if (m_lightOn)
|
|
||||||
|
if (m_lightOn && value)
|
||||||
|
{
|
||||||
|
updateLightPosition();
|
||||||
update();
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OglViewerWidget::setBackfaceCulling(bool value)
|
void OglViewerWidget::setBackfaceCulling(bool value)
|
||||||
|
|
Loading…
Reference in New Issue