I wanna rotate my Cube in OpenGL ES with the DPAD, but I don't know how.
Using java Syntax Highlighting
- class GLThread extends Thread {
- private float xRot, yRot;
- //............................
- private void drawFrame(GL10 gl) {
- // Clear the screen to black
- gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
- // Other drawing commands go here...
- gl.glMatrixMode(GL10.GL_MODELVIEW);
- gl.glLoadIdentity();
- gl.glPushMatrix();
- gl.glTranslatef(0, 0, -2.0f);
- //************ ROTATE BY THE DPAD ************
- gl.glRotatef(yRot, 0, 1, 0);
- gl.glRotatef(xRot, 1, 0, 0);
- // ... Draw the model
- cube.draw(gl);
- gl.glPopMatrix();
- gl.glPushMatrix();
- gl.glTranslatef(-1.0f, 1.0f, -2.0f);
- gl.glScalef(0.5f, 0.5f, 0.5f);
- cube.draw(gl);
- gl.glPopMatrix();
- gl.glPushMatrix();
- gl.glTranslatef(1.0f, -1.0f, -2.0f);
- gl.glScalef(0.3f, 0.3f, 0.3f);
- cube.draw(gl);
- gl.glPopMatrix();
- }
- public boolean onKeyDown(int keyCode, KeyEvent ev) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_DPAD_UP:
- xRot += 30.0f;
- yRot += 30.0f;
- return true;
- default:
- return false;
- }
- }
- //.............................
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
az the ********** line:
for example, I push the DPAD_UP, the Cube(s) rotate around the X axis by 30.
Please help me!

