Aufgrund einer Wartung wird GitLab am 17.08. zwischen 8:30 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 17.08. between 8:30 and 9:00 am.

Commit 4342260e authored by Anakin's avatar Anakin

improved performance using my own tga load function always instead of QImage

improved Profiler
parent d1c68e8b
......@@ -2,9 +2,10 @@
#ifdef _DEBUG
#include <QElapsedTimer.h>
#include <QString>
#include <iostream>
#define TIC Profiler::getInstance().startTimer();
#define TOC Profiler::getInstance().takeTime();
#define TIC(val) Profiler::getInstance().startTimer(val);
#define TOC(val) Profiler::getInstance().takeTime(val);
class Profiler
{
......@@ -21,16 +22,17 @@
return instance;
}
void startTimer() {
void startTimer(QString position = "") {
std::cout << "from: " << position.toStdString() << std::endl;
timer.restart();
};
void takeTime() {
std::cout << "time elapsed: " << timer.elapsed() << std::endl;
void takeTime(QString position = "") {
std::cout << "to: "<< position.toStdString() << " time elapsed: " << timer.elapsed() << std::endl;
};
};
#else
#define TIC
#define TOC
#define TIC(val)
#define TOC(val)
#endif
......@@ -3,12 +3,11 @@
#include <QImage>
#include <QColor>
#include "..\Header\Profiler.h"
QImage loadTga(QString filePath, bool &success)
{
QImage img;
if (!img.load(filePath))
{
// open the file
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();
}
success = true;
return img;
}
......@@ -3,6 +3,8 @@
#include "..\Header\OutputDevice.h"
#include <QColor>
#include "..\Header\Profiler.h"
// helper function to save data from file to any variable type
#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->transparent = curMat->flags[2] || curMat->flags[3] || curMat->flags[4] || curMat->flags[6] || curMat->rendertype == 4;
}
// texture 0
......@@ -310,7 +311,6 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
if (!m_materials->back().tx1d.isEmpty())
loadTexture(m_materials->back().texture1, m_filepath, m_materials->back().tx1d);
}
// texture 2
......@@ -719,6 +719,7 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position)
void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QString& filename)
{
bool loadSuccess(false);
QImage img = loadTga(filepath + "/" + filename, loadSuccess);
if (!loadSuccess)
......
......@@ -428,8 +428,12 @@ void OglViewerWidget::setAmbCoef(double value)
void OglViewerWidget::setHeadlight(bool value)
{
m_light.headlight = value;
if (m_lightOn)
if (m_lightOn && value)
{
updateLightPosition();
update();
}
}
void OglViewerWidget::setBackfaceCulling(bool value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment