2

When I run my program on an emulator, it displays an ImageView splash screen, then a black screen for the remainder of the application, which uses GLSurfaceViews. The OGL runs well on my phone. I have tested the program on two computers (low and high performance) and neither displays the GLSurfaceViews. I have also tested the emulator using some of the OGL demos from the Google apidemos interweb site and the demos don't display on either computer. My program uses OGL es 1.1, however I have also tested using OGL es 1.0 to no avail. How might I display ogl on an emulator? Thanks.

Here's an example of some simple square rendering code that doesn't work on the emulator


public void onDrawFrame(GL10 gl) {
  //This works
  gl.glClearColor(_red, _green, _blue, 1.0f);
  gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  //This doesn't
  float vertices[] = { .5f, .5f, 0, .5f, -.5f, 0, -.5f, .5f, 0, -.5f, -.5f, 0 };
  FloatBuffer vertexSquareBuffer = ByteBuffer.allocateDirect(4 * 3 * 4)
    .order(ByteOrder.nativeOrder()).asFloatBuffer();
  vertexSquareBuffer.put(vertices);
  vertexSquareBuffer.position(0);
  gl.glColor4f(1, 1, 0, 0.5f);
  gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexSquareBuffer);
  gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,4);
}
farm ostrich
  • 5,881
  • 14
  • 55
  • 81

1 Answers1

2

Well there are some possibilities. Firstly lets see if something that should work, does work on your emulator. Can you please go here and try this tutorial and run it through your emulator: http://www.droidnova.com/android-3d-game-tutorial-part-i,312.html (Do this bit first)

That way we know if the problem is with your code or the emulator.

After that you might need to look to see if there are all the required shared object libraries present.

Let me know in the comments how you go.

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
  • I ran the linked program and it displays the red background, which is good. So I added in some trivial code that draws a square (posted above) and that isn't being rendered on the emulator (works on the phone). What to do now? – farm ostrich Jun 11 '11 at 17:04
  • I think that your example code is missing a few minor OpenGL calls. Perhaps take a look at part two of that tutorial and see if that works too: http://www.droidnova.com/android-3d-game-tutorial-part-ii,328.html – Robert Massaioli Jun 12 '11 at 02:17
  • I was missing gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); which my phone didn't care about. This is a major problem solved. Much appreciated. – farm ostrich Jun 12 '11 at 03:07
  • @farm ostrich: No problems. Though in the future you also may want to check that the phone/tablet supports the OpenGL extensions that you are using too: http://stackoverflow.com/q/2093594/83446 Just in case you want to use more features of OpenGL and you are not sure if they are supported or not (because otherwise you will run into other errors too). – Robert Massaioli Jun 12 '11 at 05:02