GLGraphics crash: Invalid memory access of location 0x0...
in
Contributed Library Questions
•
1 year ago
I'm trying to add new vertices to an already existing GLModel, but it's giving me the following error:
Invalid memory access of location 0x0 eip=0x949c43f8.
I can add vertices in the same function as where I create the model, but not for example 5 seconds later in a different function. Whenever I call a function on the model that alters it, the sketch crashes (even when using the same function that works right after instantiating the model).
For instance:
_faceModel.beginUpdateVertices(); => crash
_faceModel.updateVertices(verts); => crash
...
But only when called after x seconds and from a different function.
Any tips on where to go from here? Some example code below.
I don't know if creating hundres of GLModels is the way too go? I originally thought of putting all of them in one model, but if this doesn't work... Just want to render a hundred spheres or so with OpenGL instead of the basic renderer.
—
So again: calling createSphere right after instantiating the model works fine, even when called 50 times. Calling createSphere after some time crashes the application. I've tried putting it between renderer.beginGL() or putting the same code somewhere else, but to no avail.
- // Enough particles to hold all future vertices
- _faceModel = new GLModel(_applet, 100000, GLModel.TRIANGLES, GLModel.STREAM);
- createSphere(_applet.random(0, 200), _applet.random(0, 200), _applet.random(-200, 200), DEFAULT_NODE_START_DIAMETER, DEFAULT_SPHERE_RESOLUTION);
- private void createSphere(float $x, float $y, float $z, int $radius, int $resolution) {
- Sphere sph = new Sphere(new Vec3D($x, $y, $z), $radius);
- TriangleMesh tm = (TriangleMesh) sph.toMesh($resolution);
- float[] verts = tm.getMeshAsVertexArray();
- int numV = verts.length / 4;
- _faceModel.beginUpdateVertices(); // <<<< Crash here, but not on first runs
- for(int i = 0; i < numV; i++)
- _faceModel.updateVertex(i + numVertices, verts[4 * i], verts[4 * i + 1], verts[4 * i + 2]);
- _faceModel.endUpdateVertices();
- numVertices += numV;
1