Start a new topic

missing texture native android


I am doing a native api android project and I render a 3D model from assets file with OPENGL.

However, I find that if and only if I put the code outside of onImageRecognized(), the model can be shown.

I want to put the code in onImageRecognized() so I can get the uniqueID.

How should I solve it please?

public void onRenderExtensionCreated(final RenderExtension renderExtension) {
Log.v(TAG, "onRenderExtensionCreated");
glRenderer = new GLRenderer(renderExtension);
customSurfaceView = new CustomSurfaceView(getApplicationContext(), glRenderer);
driver = new Driver(customSurfaceView, 30);

// there is my code
try {
ObjRenderable obj = new ObjRenderable(getAssets().open("modelName.obj"), getAssets().open("modelName.bmp"));

glRenderer.setRenderablesForKey("name", obj, null);

} catch (IOException e) {

1 Comment


does creating a new ObjRenderable make calls to OpenGL internally? Within onImageRecognized you do not have an OpenGL context set, so these OpenGL calls will simply fail and your model will not render.

To get the ID you will need to store it and use it in the next draw cycle (onDrawFrame) to create your object therein. If you have a look inside of the pre-existing renderables (StrokedCube, StrokedRectangle, etc.) you will notice that the only function containing calls to OpenGL is onDrawFrame.

- Daniel

Login or Signup to post a comment