Commit dca6e61c authored by Anakin's avatar Anakin
Browse files

parent matrix works,

texture works,
next fix multimodel problem
parent 3758a260
...@@ -25,8 +25,8 @@ private: ...@@ -25,8 +25,8 @@ private:
QVector<QOpenGLTexture*> m_textures; QVector<QOpenGLTexture*> m_textures;
QVector<DrawInformation> m_drawList; QVector<DrawInformation> m_drawList;
void initCubeGeometry(); void loadFile(const char* filePath);
void initTexture(); void loadTexture(const char* filePath);
public: public:
void drawGeometry(QOpenGLShaderProgram *program); void drawGeometry(QOpenGLShaderProgram *program);
......
...@@ -15,7 +15,7 @@ GeometryEngine::GeometryEngine() ...@@ -15,7 +15,7 @@ GeometryEngine::GeometryEngine()
m_indexBuf.create(); m_indexBuf.create();
// Initializes cube geometry and transfers it to VBOs // Initializes cube geometry and transfers it to VBOs
initCubeGeometry(); loadFile("..\\Release\\Msh\\triClothMan.msh");
} }
GeometryEngine::~GeometryEngine() GeometryEngine::~GeometryEngine()
...@@ -33,18 +33,21 @@ GeometryEngine::~GeometryEngine() ...@@ -33,18 +33,21 @@ GeometryEngine::~GeometryEngine()
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// private functions // private functions
void GeometryEngine::initCubeGeometry() void GeometryEngine::loadFile(const char* filePath)
{ {
QVector<Model*>* models;
QVector<VertexData> vertexData;
QVector<GLuint> indexData;
try try
{ {
MshFile file("..\\Release\\Msh\\triClothMan.msh");
models = file.getModels();
//TODO normalize //TODO normalize
//TODO: handle the textures
QVector<Model*>* models;
QVector<std::string>* textureNames;
QVector<VertexData> vertexData;
QVector<GLuint> indexData;
// open file and get the information
MshFile file(filePath);
models = file.getModels();
textureNames = file.getTextureNames();
// collect data // collect data
unsigned int offsetCount(0); unsigned int offsetCount(0);
...@@ -73,6 +76,8 @@ void GeometryEngine::initCubeGeometry() ...@@ -73,6 +76,8 @@ void GeometryEngine::initCubeGeometry()
} }
} }
//TODO: cleanup old stuff
// Transfer vertex data to VBO 0 // Transfer vertex data to VBO 0
m_arrayBuf.bind(); m_arrayBuf.bind();
m_arrayBuf.allocate(vertexData.data(), vertexData.size() * sizeof(VertexData)); m_arrayBuf.allocate(vertexData.data(), vertexData.size() * sizeof(VertexData));
...@@ -81,8 +86,15 @@ void GeometryEngine::initCubeGeometry() ...@@ -81,8 +86,15 @@ void GeometryEngine::initCubeGeometry()
m_indexBuf.bind(); m_indexBuf.bind();
m_indexBuf.allocate(indexData.data(), indexData.size() * sizeof(GLuint)); m_indexBuf.allocate(indexData.data(), indexData.size() * sizeof(GLuint));
// load the texture // get textures path
initTexture(); std::string path = filePath;
while (path.back() != '/' && path.back() != '\\')
path.pop_back();
// load the textures
for(auto& it : *textureNames)
loadTexture(std::string(path + it).c_str());
} }
catch (std::invalid_argument e) catch (std::invalid_argument e)
...@@ -94,10 +106,18 @@ void GeometryEngine::initCubeGeometry() ...@@ -94,10 +106,18 @@ void GeometryEngine::initCubeGeometry()
} }
void GeometryEngine::initTexture() void GeometryEngine::loadTexture(const char* filePath)
{ {
// Load cube.png image
QOpenGLTexture* new_texture = new QOpenGLTexture(QImage(":images/cube.png").mirrored()); QImage img;
if (!img.load(filePath))
{
img = QImage(1, 1, QImage::Format_RGB32);
img.fill(Qt::red);
}
// Load image to OglTexture
QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored());
// Set nearest filtering mode for texture minification // Set nearest filtering mode for texture minification
new_texture->setMinificationFilter(QOpenGLTexture::Nearest); new_texture->setMinificationFilter(QOpenGLTexture::Nearest);
......
...@@ -17,7 +17,6 @@ MshFile::MshFile(const char * path) ...@@ -17,7 +17,6 @@ MshFile::MshFile(const char * path)
MshFile::~MshFile() MshFile::~MshFile()
{ {
//TODO: clean up
} }
......
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