Tuesday 28 May 2013

[Android]call to OpenGL ES API with no current context (logged once per thread)

Questions:
call to OpenGL ES API with no current context (logged once per thread)
for java you could not call the Opengl on main thread, you should build opengl running in subthread.
You can use  GLSurfaceView to do this by your own thread.

The wrong way:

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.clear:
            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
            break;
        // ...
    }
}

The correct way:

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.clear:
            // GLSurfaceView.queueEvent
            surface.queueEvent(new Runnable() {
                @Override
                public void run() {
                    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
                }
            });
            break;
        // ...
    }
}

9 comments:

  1. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving... very specific nice content.
    Android Training in chennai | Android Training

    ReplyDelete

  2. Thanks for sharing the knowledgeable stuff to enlighten us no words for this amazing blog.. learnt so many things I recommend everyone to learn something from this blogger and blog.. I am sharing it with others also
    IT Software Training in Chennai | Python Training in Chennai | Dot Net Training in Chennai |Android Training in Chennai | J2ee Training in Chennai

    ReplyDelete
  3. Good work. Your blog really grabs the attention of readers. It is very good to share decent articles.
    Thanks
    Dedicated hosting provider

    ReplyDelete
  4. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful .Oracle training in Bangalore

    ReplyDelete
  5. I have read your blog its very attractive and impressive. I like it your blog.Microsoft Training in Bangalore

    ReplyDelete