Java Code Examples for javax.microedition.khronos.opengles.GL10#glRotatef()
The following examples show how to use
javax.microedition.khronos.opengles.GL10#glRotatef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TouchRotateActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public void onDrawFrame(GL10 gl) { /* * Usually, the first thing one might want to do is to clear * the screen. The most efficient way of doing this is to use * glClear(). */ gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); /* * Now we're ready to draw some 3D objects */ gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -3.0f); gl.glRotatef(mAngleX, 0, 1, 0); gl.glRotatef(mAngleY, 1, 0, 0); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); mCube.draw(gl); }
Example 2
Source File: BouncyCubeRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onDrawFrame(GL10 gl) { gl.glClearColor(0.0f,0.5f,0.5f,1.0f); gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL11.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,(float)Math.sin(mTransY), -7.0f); gl.glRotatef(mAngle, 0.0f, 1.0f, 0.0f); gl.glRotatef(mAngle, 1.0f, 0.0f, 0.0f); gl.glEnableClientState(GL11.GL_VERTEX_ARRAY); gl.glEnableClientState(GL11.GL_COLOR_ARRAY); mCube.draw(gl); mTransY += .075f; mAngle+=.4; }
Example 3
Source File: SolarSystemRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glClearColor(0.0f,0.0f,0.0f,1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,(float)Math.sin(mTransY), -4.0f); gl.glRotatef(mAngle, 1, 0, 0); gl.glRotatef(mAngle, 0, 1, 0); mPlanet.draw(gl); mTransY+=.075f; mAngle+=.4; }
Example 4
Source File: BouncyCubeRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onDrawFrame(GL10 gl) { gl.glClearColor(0.0f,0.5f,0.5f,1.0f); gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL11.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,(float)Math.sin(mTransY), -7.0f); gl.glRotatef(mAngle, 0.0f, 1.0f, 0.0f); gl.glRotatef(mAngle, 1.0f, 0.0f, 0.0f); gl.glEnableClientState(GL11.GL_VERTEX_ARRAY); gl.glEnableClientState(GL11.GL_COLOR_ARRAY); mCube.draw(gl); mTransY += .075f; mAngle+=.4; }
Example 5
Source File: SolarSystemRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glClearColor(0.0f,0.0f,0.0f,1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,(float)Math.sin(mTransY), -4.0f); gl.glRotatef(mAngle, 1, 0, 0); gl.glRotatef(mAngle, 0, 1, 0); mPlanet.draw(gl); mTransY+=.075f; mAngle+=.4; }
Example 6
Source File: VortexRenderer.java From opengl with Apache License 2.0 | 6 votes |
@Override public void onDrawFrame(GL10 gl) { // clear the color buffer and the depth buffer gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _vertexBuffer); gl.glColorPointer(4, GL10.GL_FLOAT, 0, _colorBuffer); for (int i = 1; i <= 10; i++) { gl.glLoadIdentity(); gl.glTranslatef(0.0f, -1f, -1.0f + -1.5f * i); // set rotation gl.glRotatef(-_xAngle, 1f, 0f, 0f); gl.glRotatef(-_yAngle, 0f, 1f, 0f); gl.glDrawElements(GL10.GL_TRIANGLES, _nrOfVertices, GL10.GL_UNSIGNED_SHORT, _indexBuffer); } }
Example 7
Source File: GLDrawerES1.java From Building-Android-UIs-with-Custom-Views with MIT License | 6 votes |
@Override public void onDrawFrame(GL10 gl) { gl.glClearColor(1.f, 0.f, 0.f, 1.f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0.f, 0.f, -50.f); long time = SystemClock.uptimeMillis() % 4000L; float angle = 0.090f * ((int) time); gl.glRotatef(angle, 0.f, 0.f, 1.f); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glColor4f(1.f, 1.f, 1.f, 1.f); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); }
Example 8
Source File: AndroidOpenGL.java From opengl with Apache License 2.0 | 5 votes |
public void onDrawFrame(GL10 gl) { if (!fAnimPaused) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glRotatef(1f, 0, 0, 1f); if (mTriangle != null) { mTriangle.drawColorful(gl); } } }
Example 9
Source File: CubeRenderer.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onDrawFrame(GL10 gl) { /* * Usually, the first thing one might want to do is to clear * the screen. The most efficient way of doing this is to use * glClear(). */ gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); /* * Now we're ready to draw some 3D objects */ gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -3.0f); gl.glRotatef(mAngle, 0, 1, 0); gl.glRotatef(mAngle*0.25f, 1, 0, 0); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); mCube.draw(gl); gl.glRotatef(mAngle*2.0f, 0, 1, 1); gl.glTranslatef(0.5f, 0.5f, 0.5f); mCube.draw(gl); mAngle += 1.2f; }
Example 10
Source File: AndroidOpenGL.java From opengl with Apache License 2.0 | 5 votes |
public void onDrawFrame(GL10 gl) { if (!fAnimPaused) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glRotatef(1f, 0, 0, 1f); if (mTriangle != null) { mTriangle.drawColorful(gl); } } }
Example 11
Source File: FrameBufferObjectActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
private void drawOffscreenImage(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); float ratio = (float) width / height; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); gl.glEnable(GL10.GL_CULL_FACE); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glClearColor(0,0.5f,1,0); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -3.0f); gl.glRotatef(mAngle, 0, 1, 0); gl.glRotatef(mAngle*0.25f, 1, 0, 0); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); mCube.draw(gl); gl.glRotatef(mAngle*2.0f, 0, 1, 1); gl.glTranslatef(0.5f, 0.5f, 0.5f); mCube.draw(gl); mAngle += 1.2f; // Restore default state so the other renderer is not affected. gl.glDisable(GL10.GL_CULL_FACE); gl.glDisable(GL10.GL_DEPTH_TEST); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }
Example 12
Source File: PLQuadricPanoramaBase.java From panoramagl with Apache License 2.0 | 5 votes |
/** * render methods */ @Override protected void beginRender(GL10 gl, PLIRenderer renderer) { super.beginRender(gl, renderer); gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); gl.glRotatef(180.0f, 0.0f, 1.0f, 0.0f); }
Example 13
Source File: PLRenderableElementBase.java From panoramagl with Apache License 2.0 | 5 votes |
protected void internalRotate(GL10 gl, PLRotation rotation) { boolean isYZAxisInverseRotation = this.isYZAxisInverseRotation(), isReverseRotation = this.isReverseRotation(); float yDirection = (isYZAxisInverseRotation ? 1.0f : 0.0f), zDirection = (isYZAxisInverseRotation ? 0.0f : 1.0f); if (this.isPitchEnabled()) gl.glRotatef(isReverseRotation ? rotation.pitch : -rotation.pitch, 1.0f, 0.0f, 0.0f); if (this.isYawEnabled()) gl.glRotatef(isReverseRotation ? rotation.yaw : -rotation.yaw, 0.0f, yDirection, zDirection); if (this.isRollEnabled()) gl.glRotatef(isReverseRotation ? rotation.roll : -rotation.roll, 0.0f, yDirection, zDirection); }
Example 14
Source File: PLQuadricPanoramaBase.java From PanoramaGL with Apache License 2.0 | 5 votes |
@Override protected void endRender(GL10 gl, PLIRenderer renderer) { gl.glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); super.endRender(gl, renderer); }
Example 15
Source File: PLQuadricPanoramaBase.java From PanoramaGL with Apache License 2.0 | 5 votes |
/**render methods*/ @Override protected void beginRender(GL10 gl, PLIRenderer renderer) { super.beginRender(gl, renderer); gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); gl.glRotatef(180.0f, 0.0f, 1.0f, 0.0f); }
Example 16
Source File: PLQuadricPanoramaBase.java From panoramagl with Apache License 2.0 | 4 votes |
@Override protected void endRender(GL10 gl, PLIRenderer renderer) { gl.glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); super.endRender(gl, renderer); }
Example 17
Source File: TriangleRenderer.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
public void onDrawFrame(GL10 gl) { /* * By default, OpenGL enables features that improve quality * but reduce performance. One might want to tweak that * especially on software renderer. */ gl.glDisable(GL10.GL_DITHER); gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE); /* * Usually, the first thing one might want to do is to clear * the screen. The most efficient way of doing this is to use * glClear(). */ gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); /* * Now we're ready to draw some 3D objects */ gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glActiveTexture(GL10.GL_TEXTURE0); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); long time = SystemClock.uptimeMillis() % 4000L; float angle = 0.090f * ((int) time); gl.glRotatef(angle, 0, 0, 1.0f); mTriangle.draw(gl); }
Example 18
Source File: CubeMapActivity.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
public void onDrawFrame(GL10 gl) { checkGLError(gl); if (mContextSupportsCubeMap) { gl.glClearColor(0,0,1,0); } else { // Current context doesn't support cube maps. // Indicate this by drawing a red background. gl.glClearColor(1,0,0,0); } gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); gl.glRotatef(mAngle, 0, 1, 0); gl.glRotatef(mAngle*0.25f, 1, 0, 0); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); checkGLError(gl); if (mContextSupportsCubeMap) { gl.glActiveTexture(GL10.GL_TEXTURE0); checkGLError(gl); gl.glEnable(GL11ExtensionPack.GL_TEXTURE_CUBE_MAP); checkGLError(gl); gl.glBindTexture(GL11ExtensionPack.GL_TEXTURE_CUBE_MAP, mCubeMapTextureID); checkGLError(gl); GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl; gl11ep.glTexGeni(GL11ExtensionPack.GL_TEXTURE_GEN_STR, GL11ExtensionPack.GL_TEXTURE_GEN_MODE, GL11ExtensionPack.GL_REFLECTION_MAP); checkGLError(gl); gl.glEnable(GL11ExtensionPack.GL_TEXTURE_GEN_STR); checkGLError(gl); gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_DECAL); } checkGLError(gl); mGrid.draw(gl); if (mContextSupportsCubeMap) { gl.glDisable(GL11ExtensionPack.GL_TEXTURE_GEN_STR); } checkGLError(gl); mAngle += 1.2f; }
Example 19
Source File: LaserScanRenderer.java From RobotCA with GNU General Public License v3.0 | 4 votes |
/** * Called to draw the current frame. * @param gl the GL interface. */ @Override public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); if (vertexFrontBuffer != null) { final float cameraX = xShift; final float cameraY = yShift; if (angleFollowsRobot) cameraAngle = 90.0f; else cameraAngle = angleShift + (float) Math.toDegrees(RobotController.getHeading()); synchronized (mutex) { gl.glPushMatrix(); // Adjust scale for screen aspect ratio gl.glScalef(cameraZoom * BASE_ZOOM / width, cameraZoom * BASE_ZOOM / height, 1f); // Apply camera translation gl.glTranslatef(cameraX, cameraY, 0.0f); // Rotate by the camera angle gl.glRotatef(cameraAngle, 0.0f, 0.0f, 1.0f); // Draw start position drawPoint(gl, 0.0, 0.0, 32.0f, 0xFFCCCCDD, null); // Draw the robot Utils.drawShape(gl, ROBOT_INDICATOR_COLOR); // Draw the scan area Utils.drawPoints(gl, vertexFrontBuffer, 0.0f, true); // // Draw the scanMap // ControlApp.getLaserScanMap().draw(gl, 8.0f, 0xFF22FF44); // Drop the first point which is required for the triangle fan but is // not a range reading. FloatBuffer pointVertices = vertexFrontBuffer.duplicate(); pointVertices.position(3 + 4); // Draw the scan points Utils.drawPoints(gl, pointVertices, LASER_SCAN_POINT_SIZE, false); // Draw waypoints drawWayPoints(gl); // Reset transforms gl.glPopMatrix(); } } gl.glDisable(GL10.GL_BLEND); }
Example 20
Source File: Graph3DRenderer.java From ncalc with GNU General Public License v3.0 | 4 votes |
@Override public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -3.0f); gl.glRotatef(gamma, 0, 1f, 0); gl.glRotatef(alpha, 1f, 1f, 0); gl.glRotatef(beta, 0, 0, 1f); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); if (dirty) { setUpArray(); dirty = false; } gl.glLineWidth(1.0f); for (int k = 0; k < functions.size(); k++) { int colors[] = Graph2DView.colors[k]; gl.glColor4f((float) colors[0] / 255, (float) colors[1] / 255, (float) colors[2], 1); for (int i = 0; i <= 30; i++) { vertexBuffer[k][i][1].position(0); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer[k][i][0]); gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, 31); vertexBuffer[k][i][1].position(0); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer[k][i][1]); gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, 31); } } gl.glLineWidth(3.0f); gl.glColor4f(1, 1, 1, 1); axisBuffer.position(0); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, axisBuffer); gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, axis.length); gl.glRotatef(gamma * 2.0f, 0, 0, 1); gl.glTranslatef(0.5f, 0.5f, 0.5f); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); long newSeconds = System.currentTimeMillis(); if (!userRotate) { gamma += .04f * (newSeconds - milliseconds); } milliseconds = newSeconds; }