I'm building a 3D game, and i'm trying to load some assets with the nice Assimp library. The model should look like the one in the first picture, but instead, it takes the form of some kind of avant-garde sculpture, as the second picture shows.
At least i'm proud that i get to see something, but hey, i can do better.
It's not a problem with shaders (it simply isn't, i pass no normals and no textures, just the vertex coordinate, since i set a static colour). Here is my code:
MODEL LOADING (only vertex coordinates)
void Mesh::open(const std::string file)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(file, aiProcess_Triangulate);
if(!scene)
throw STREAM("Could open mesh '" << file << "'!");
std::vector<float> g_vp;
count = 0;
for(uint m_i = 0; m_i < scene->mNumMeshes; m_i++)
{
const aiMesh* mesh = scene->mMeshes[0];
g_vp.reserve(3 * mesh->mNumVertices);
count += mesh->mNumVertices;
for(uint v_i = 0; v_i < mesh->mNumVertices; v_i++)
{
if(mesh->HasPositions())
{
const aiVector3D* vp = &(mesh->mVertices[v_i]);
g_vp.push_back(vp->x);
g_vp.push_back(vp->y);
g_vp.push_back(vp->z);
}
}
}
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, count * 3 * sizeof(float), &g_vp[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte*)NULL);
}
SCENE RENDERING
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
program.use();
program.setUniform("transformMat", modelMat);
glBindBuffer(GL_ARRAY_BUFFER, m.vbo);
glDrawArrays(GL_TRIANGLES, 0, m.count);
SDL_GL_SwapWindow(window->mWin);
}
Depth testing is enabled, and i'm using OpenGL 4.0 with v400 shaders too.
The error will possibly be stupid, but i can't find it, and my head is all boiling at this very moment.
Thanks for your help!