PDA

View Full Version : Assimp vertexArray problem



rgbaboy
03-21-2016, 10:45 AM
hi guys its my first post here and i am trying to import a model using assimp for a small space simulation project and was wondering if anyone could help me fix why it is throwing a memory access violation.

i have drawn a small 3d cube in my main.cpp to test my 3d camera but im not sure if that would interfere with the model rendering. ive posted a small code sample where the problem is occuring


Mesh::MeshEntry::MeshEntry(aiMesh *mesh) {
vbo[VERTEX_BUFFER] = NULL;
vbo[TEXCOORD_BUFFER] = NULL;
vbo[NORMAL_BUFFER] = NULL;
vbo[INDEX_BUFFER] = NULL;
//access violation
//glGenVertexArrays(1, &vao);
//glBindVertexArray(vao);

elementCount = mesh->mNumFaces * 3;

if (mesh->HasPositions()){
float *vertices = new float[mesh->mNumVertices * 3];
for (int i = 0; i < mesh->mNumVertices; i++){
vertices[i * 3] = mesh->mVertices[i].x;
vertices[i * 3 + 1] = mesh->mVertices[i].y;
vertices[i * 3 + 2] = mesh->mVertices[i].z;
}

/* glGenBuffers(1, &vbo[VERTEX_BUFFER]);
glBindBuffer(GL_ARRAY_BUFFER, vbo[VERTEX_BUFFER]);
glBufferData(GL_ARRAY_BUFFER, 3 * mesh->mNumVertices* sizeof(GLfloat), vertices, GL_STATIC_DRAW);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(0);*/

delete[] vertices;

}