|
02:10 pm

|
Nexus One Spinny Cube |
Friday, June 4th, 2010 |
I bought a Nexus One 2 weeks ago, and I've started learning its programming environment. Since I've gotten into the habit of making a spinny cube for every platform (previously: V3 RAZR, NDS), here's my Android one:
This was my first experience with OpenGL ES, and gaaaaaaah it's not fun. I think some of that is also Android's Java implementation of it, since you have to jump through hoops to make the now-required geometry buffers in the required hardware format. For complex game engines, it doesn't matter. But for "my first OpenGL", what a difference! For example, drawing a quad:
| Regular OpenGL |
OpenGL ES |
gl.glBegin(GL.GL_QUADS);
gl.glVertex3f(0.0f, 0.0f, 0.0f);
gl.glVertex3f(1.0f, 0.0f, 0.0f);
gl.glVertex3f(1.0f, 1.0f, 0.0f);
gl.glVertex3f(0.0f, 1.0f, 0.0f);
gl.glEnd()
|
final float quad[] = {
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
};
int storageSize = quad.length * Float.SIZE / 8;
ByteBuffer quadStorage = ByteBuffer.allocateDirect(storageSize);
quadStorage.order(ByteOrder.nativeOrder());
FloatBuffer quadBuffer = quadStorage.asFloatBuffer();
quadBuffer.put(quad);
quadBuffer.position(0);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, quadBuffer);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, quadBuffer.capacity()/3);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
|
Anyway, continuing on with more Android this weekend. My goal is to write a little app for interacting with Nectarine. That should cover a range of GUI, network, XML parsing, and IPC tasks. |
|
| |
| Comments |
Congratulations on your cube and welcome to the nexus world! I love my phone -- mainly because of people like you who keep doing amazing things with it. I look forward to your first app.
Thanks! The library of apps impressed me as well. The android market has given me everything I've asked for except a good version of Mille Bornes!
I had to wikipedia mille bornes -- sounds like fun. | |