BlueBug
BlueBug

Reputation: 369

Android OpenGl: When to start calling API functions?

I have noticed that if I try to call API calls before surface is created such as

GLES20.glGenTextures(textures.size(), textureHandle,0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[i]);

They don't behave properly, for example texture handler being returned as 0 all the time.

So I put my initiation methods under onSurfaceCreated call.

public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
    if(initiated)return;
    BitmapLoader.onOpenglGLInitiated();
    program.init();
    initiated = true;

}

However such results in being recalled whenever surface is recreated; when a user pauses and resumes as well. In which reuslts in double initiation, thus an error. I want to know where exactly should be a better place to put my initiation codes.

Upvotes: 1

Views: 96

Answers (1)

escalator
escalator

Reputation: 889

So far what I´ve seen, it´s quite convenient to load textures in onSurfaceCreated

Example 6: Texture (Nehe Lesson 6: Texture)

Which errors do you exactly get?

Upvotes: 1

Related Questions