Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid opengl rendering garbage
    text
    copied!<p>I've been doing some simple shaders and Im encountering an error that happens randomly, when I start rendering my scene, sometimes the mesh is rendered with extra vectors, and if I kill the activity and then I open the same activity it renders sometimes without the extra vectors.</p> <p>My guesses are that the memory on the GPU is not completely wiped out when I kill the activity. Whats more weird is that these extra polygons are rendered sometimes using my shader logic and other times they render as if they were filled with random squares.</p> <p>Im going all crazy I've reviewed all the code, from where I read the obj, to where I set the vertex attributes, if you have been seen this before please let me know. BTW I'm using a motorola milestone with android 2.1.</p> <p>This is the code related where I create a simple triangle and set the attributes of the vertices:</p> <pre><code>//This is where I create the mesh mMesh = new Mesh(); mMesh.setVertices(new float[]{-0.5f, 0f, 0.5f, 0.5f, 0f, -0.5f, -0.5f, 0f, -0.5f}); ArrayList&lt;VertexAttribute&gt; attributes = new ArrayList&lt;VertexAttribute&gt;(); attributes.add(new VertexAttribute(Usage.Position, 3, ProgramShader.POSITION_ATTRIBUTE)); VertexAttributes vertexAttributes = new VertexAttributes(attributes.toArray(new VertexAttribute[attributes.size()])); mMesh.setVertexAttributes(vertexAttributes); ... ... ....... //This is where I send the mesh to opengl for(VertexAttribute attr :mVertexAttributes.getAttributes().values()){ mVertexBuffer.position(attr.offset); int handler = shader.getHandler(attr.alias); if(handler != -1){ try{ GLES20.glVertexAttribPointer(handler, attr.numComponents, GLES20.GL_FLOAT, false, mVertexAttributes.vertexSize, mVertexBuffer); GLES20.glEnableVertexAttribArray(handler); }catch (RuntimeException e) { Log.d("CG", attr.alias); throw e; } } } //(length = 3 for a triangle) GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, length); </code></pre> <p>Here are some screenshots for you to see the issue:</p> <ul> <li><a href="http://www.dropbox.com/gallery/20966948/1/opengl?h=058c9f" rel="nofollow">Screenshots</a></li> </ul> <p>Also here is a link to a video I took when I run the app on the phone.</p> <ul> <li><a href="http://www.youtube.com/watch?v=Q5eE1_MGFw8" rel="nofollow">Video</a></li> </ul>
 

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