Tony Bogdanov
Tony Bogdanov

Reputation: 7686

Android: OpenGL: glGenTextures not working in constructor?

Can anyone tell me why glGenTextures() isn't working in my constructor?

Here is how my project is setup:

It seems as if everything works ONLY if there is already a reference to the current stage I'm using (if the stage is created e.g. the constructor has already run).

I am not sure if it is related, but the stage is created in a Thread after onCreateSurface ends.

I could post some of the code if you say which parts would be relevant.

Upvotes: 1

Views: 788

Answers (1)

Jave
Jave

Reputation: 31846

I am quite sure you have to run all openGL operations on the Thread associated with openGL. This is why it works when called from your draw() method called from the renderer (which runs on the GL-Thread) but not from the constructor (which runs on another Thread as you say).

Upvotes: 5

Related Questions