开发者

Android -- OpenGL doesn't display w/ emulator?

When I 开发者_如何学JAVArun 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);
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜