Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL Assimp C++ Access Violation Reading Location 0x00000000
    primarykey
    data
    text
    <p>I have encountered a problem trying to run a simple model loader/displayer based off some tutorials. Whenever I compile the following code, I get this error:</p> <pre><code>Unhandled exception at 0x77ad15de in Test.exe: 0xC0000005: Access violation reading location 0x00000000. </code></pre> <p>I know this means that a null pointer is being accessed which is illegal, but I cant seem to find one. Here is my code:</p> <pre><code>gleMesh gleLoadMesh(const char* filename){ const aiScene* scene = aiImportFile(filename, aiProcessPreset_TargetRealtime_Fast); if(!scene){ fprintf(stderr,"[WARNING] Could not load file %s", filename); gleMesh load = {0,0,0,0}; return load; } const struct aiMesh* mesh = scene-&gt;mMeshes[0]; int tris = mesh-&gt;mNumFaces*3; float *verts = new float[mesh-&gt;mNumFaces*3*3]; float *normals = new float[mesh-&gt;mNumFaces*3*3]; float *uvs = new float[mesh-&gt;mNumFaces*3*3]; for(unsigned int i = 0; i &lt; mesh-&gt;mNumFaces; i++){ const aiFace face = mesh-&gt;mFaces[i]; for(unsigned int j = 0; j &lt; 3; j++){ aiVector3D vert = mesh-&gt;mVertices[face.mIndices[j]]; memcpy(verts, &amp;vert, sizeof(float)*3); verts += 3; aiVector3D normal = mesh-&gt;mNormals[face.mIndices[j]]; memcpy(normals, &amp;normal, sizeof(float)*3); normals += 3; aiVector3D uv = mesh-&gt;mTextureCoords[0][face.mIndices[j]]; memcpy(uvs, &amp;uv, sizeof(float)*2); uvs += 2; } } gleMesh load = {0,0,0,0}; if(glv3){ glGenBuffers(1, &amp;load.vertex); glBindBuffer(GL_ARRAY_BUFFER, load.vertex); glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW); glGenBuffers(1, &amp;load.normal); glBindBuffer(GL_ARRAY_BUFFER, load.normal); glBufferData(GL_ARRAY_BUFFER, sizeof(uvs), uvs, GL_STATIC_DRAW); glGenBuffers(1, &amp;load.uv); glBindBuffer(GL_ARRAY_BUFFER, load.uv); glBufferData(GL_ARRAY_BUFFER, sizeof(uvs), uvs, GL_STATIC_DRAW); load.numTris = tris; } else{ load.vertex = glGenLists(1); glNewList(load.vertex, GL_COMPILE); int j = 0; for(unsigned int i = 0; i &lt; mesh-&gt;mNumFaces; i++){ glNormal3f(normals[j], normals[j+1], normals[j+2]); glVertex3f(verts[j], verts[j+1], verts[j+2]); j+=3; } glEndList(); } verts -= mesh-&gt;mNumFaces*3*3; normals -= mesh-&gt;mNumFaces*3*3; uvs -= mesh-&gt;mNumFaces*3*2; aiReleaseImport(scene); return load; </code></pre> <p>}</p> <p>I use this function here:</p> <pre><code>int main(){ gleInit("Test", GLFW_WINDOW, SCREEN_WIDTH, SCREEN_HEIGHT); mesh1 = gleLoadMesh("resource/model/test.blend"); while(!glfwGetKey(GLFW_KEY_ESC) &amp;&amp; glfwGetWindowParam(GLFW_OPENED)){ draw(); capFPS(); } gleQuit(); return 0; } </code></pre> <p>The strangest part is, depending on what model format I choose to load, I will get an error break in a different place, but the error is always the same. I am using assimp version 3.0 and visual studio 2010.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload