Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL "Invalid operation error" After glDrawElements function on android phone
    primarykey
    data
    text
    <p>I can't run my app on my phone, and I'v located the error, yet lack the knowledge in programming and in english to repair it. The app run's on emulator perfectly, without any errors in code neither in opengl. Yet on the phone everything runs fine without any errors, but show no opengl elements which i want to draw. I'v added <code>glGetError</code> almost everythere in my code, and found the error 1282 generated after <code>glDrawElements</code> which is <code>GL_INVALID_OPERATION</code>.</p> <p><code>GL_INVALID_OPERATION</code> is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.</p> <p><code>GL_INVALID_OPERATION</code> is generated if glDrawElements is executed between the execution of glBegin and the corresponding glEnd.</p> <p>I have no glBegin or glEnd in my code, so i guess the problem is in my indexbuffer. Below i present you everthing i have with the indexbuffer. </p> <pre><code>private ShortBuffer _indexBuffer; public void onDrawFrame(GL10 gl) { FramesPerSecond.StartCounter(); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _vertexBuffer); gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); for (int i = 1; i &lt;= 10; i++) { gl.glLoadIdentity(); gl.glTranslatef(0.0f, -1f, -1.0f + -1.5f * i); gl.glRotatef(-_xAngle, 1f, 0f, 0f); gl.glRotatef(-_yAngle, 0f, 1f, 0f); gl.glDrawElements(GL10.GL_TRIANGLES, _nrOfVertices, GL10.GL_UNSIGNED_SHORT, _indexBuffer); Log.e("Warning", " error code " +gl.glGetError()); } </code></pre> <p>Code of buffer in my object initialization function:</p> <pre><code> short[] indeksai = new short[] { 0, 1, 3, 0, 2, 1, 0, 3, 2, 1, 2, 3, }; ByteBuffer ibb = ByteBuffer.allocateDirect(indeksai.length * 2); ibb.order(ByteOrder.nativeOrder()); _indexBuffer = ibb.asShortBuffer(); _indexBuffer.put(indeksai); </code></pre> <p>And that's basicaly everything i have done with this buffer.</p> <p>On surfaceCreated function >></p> <pre><code>public void onSurfaceCreated(GL10 gl, EGLConfig config) { Log.i(LOG_TAG, "onSurfaceCreated()"); gl.glMatrixMode(GL10.GL_PROJECTION); float ratio = _width / _height; gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int) _width, (int) _height); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glClearColor(0f, 0f, 0f, 1.0f); gl.glEnable(GL10.GL_CULL_FACE); gl.glFrontFace(GL10.GL_CCW); gl.glCullFace(GL10.GL_BACK); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); initTriangle(gl, context); try { loadGLTexture(gl); } catch (IOException e) { Log.w(LOG_TAG, "Texture fail"); } gl.glEnable(GL10.GL_TEXTURE_2D); gl.glShadeModel(GL10.GL_SMOOTH); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); gl.glClearDepthf(1.0f); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glDepthFunc(GL10.GL_LEQUAL); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); } </code></pre>
    singulars
    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.
 

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