Java Code Examples for android.opengl.GLU#gluLookAt()
The following examples show how to use
android.opengl.GLU#gluLookAt() .
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: BasicGL.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); TriangleSmallGLUT triangle = new TriangleSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 10f, 0, 0, 0, 0, 1, 0f); mGL.glColor4f(1f, 0f, 0f, 1f); while (!mDone) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT| GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 0, 0, 1f); triangle.drawColorful(mGL); //triangle.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); } }
Example 2
Source File: SimpleFPSDisplay.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); CubeSmallGLUT cube = new CubeSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 8f, 0, 0, 0, 0, 1, 0f); while (!mDone) { if (animState) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); cube.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); calculateAndDisplayFPS(); } } }
Example 3
Source File: Renderer.java From augmentedreality with Apache License 2.0 | 6 votes |
public void onDrawFrame(GL10 gl) { if(ModelViewer.DEBUG) { frame++; time=System.currentTimeMillis(); if (time - timebase > 1000) { Log.d("fps: ", String.valueOf(frame*1000.0f/(time-timebase))); timebase = time; frame = 0; } } gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); GLU.gluLookAt(gl, cameraPosition.x, cameraPosition.y, cameraPosition.z, 0, 0, 0, 0, 1, 0); for (Iterator<Model3D> iterator = models.iterator(); iterator.hasNext();) { Model3D model = iterator.next(); model.draw(gl); } }
Example 4
Source File: SimpleLitGLCube.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); CubeSmallGLUT cube = new CubeSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 8f, 0, 0, 0, 0, 1, 0f); while (!mDone) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT| GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); mGL.glColor4f(1f, 0f, 0f, 1f); cube.draw(mGL); mGL.glFlush(); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); } }
Example 5
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); CubeSmallGLUT cube = new CubeSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 6f, 0, 0, 0, 0, 1, 0f); while (!mDone) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT| GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); mGL.glColor4f(1f, 0f, 0f, 1f); cube.drawSimpleCube(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); } }
Example 6
Source File: BasicGL.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); TriangleSmallGLUT triangle = new TriangleSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 10f, 0, 0, 0, 0, 1, 0f); mGL.glColor4f(1f, 0f, 0f, 1f); while (!mDone) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT| GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 0, 0, 1f); triangle.drawColorful(mGL); //triangle.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); } }
Example 7
Source File: SimpleFPSDisplay.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); CubeSmallGLUT cube = new CubeSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 8f, 0, 0, 0, 0, 1, 0f); while (!mDone) { if (animState) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); cube.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); calculateAndDisplayFPS(); } } }
Example 8
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 6 votes |
public void run() { initEGL(); initGL(); CubeSmallGLUT cube = new CubeSmallGLUT(3); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 6f, 0, 0, 0, 0, 1, 0f); while (!mDone) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT| GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); mGL.glColor4f(1f, 0f, 0f, 1f); cube.drawSimpleCube(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); } }
Example 9
Source File: FrameBufferObjectActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
private void drawOnscreen(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, 3, 7); gl.glClearColor(0,0,1,0); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTargetTexture); gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE); 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); long time = SystemClock.uptimeMillis() % 4000L; float angle = 0.090f * ((int) time); gl.glRotatef(angle, 0, 0, 1.0f); mTriangle.draw(gl); // Restore default state so the other renderer is not affected. gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); }
Example 10
Source File: DemoHeartRateSensorActivity.java From BLE-Heart-rate-variability-demo with MIT License | 5 votes |
public void onDrawFrame(GL10 gl) { gl.glDisable(GL10.GL_DITHER); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 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); draw(gl); }
Example 11
Source File: FlipRenderer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); float fovy = 20f; float eyeZ = height / 2f / (float) Math.tan(TextureUtils.d2r(fovy / 2)); GLU.gluPerspective(gl, fovy, (float) width / (float) height, 0.5f, eyeZ + height / 2); //set zFar be larger than eyeZ to fix issue #5 gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, width / 2f, height / 2f, eyeZ, width / 2f, height / 2f, 0.0f, 0.0f, 1.0f, 0.0f ); gl.glEnable(GL_LIGHTING); gl.glEnable(GL_LIGHT0); float lightAmbient[] = new float[]{3.5f, 3.5f, 3.5f, 1f}; gl.glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient, 0); light0Position = new float[]{0, 0, eyeZ, 0f}; gl.glLightfv(GL_LIGHT0, GL_POSITION, light0Position, 0); if (AphidLog.ENABLE_DEBUG) { AphidLog.d("onSurfaceChanged: %d, %d", width, height); } }
Example 12
Source File: TGAGLSurfaceView.java From TGAReader with MIT License | 5 votes |
@Override public void onDrawFrame(GL10 gl) { gl.glClearColor(0.5f, 0.5f, 0.5f, 1); gl.glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, positionBuffer); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texcoordBuffer); gl.glEnable(GL_CULL_FACE); gl.glCullFace(GL_BACK); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 3, 3, 3, 0, 0, 0, 0, 1, 0); // draw front and back draw(gl, tgaTextures[0]); // draw left and right gl.glPushMatrix(); gl.glRotatef(90, 0, 1, 0); draw(gl, tgaTextures[1]); gl.glPopMatrix(); // draw top and bottom gl.glPushMatrix(); gl.glRotatef(-90, 1, 0, 0); draw(gl, tgaTextures[2]); gl.glPopMatrix(); }
Example 13
Source File: AndroidOpenGL.java From opengl with Apache License 2.0 | 5 votes |
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); // configure model space gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, 10f, 0, 0, 0, 0, 1, 0f); gl.glColor4f(1f, 0f, 0f, 1f); }
Example 14
Source File: TextureGL.java From opengl with Apache License 2.0 | 5 votes |
public void run() { initEGL(); initGL(); TexCubeSmallGLUT cube = new TexCubeSmallGLUT(3); // create room for two textures mGL.glEnable(GL10.GL_TEXTURE_2D); // use this texture unit mGL.glActiveTexture(GL10.GL_TEXTURE0); int[] textures = new int[1]; mGL.glGenTextures(1, textures, 0); cube.setTex(mGL, sv.getContext(), textures[0], R.drawable.android); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 8f, 0, 0, 0, 0, 1, 0f); while (!mDone) { if (animState) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); mGL.glColor4f(1f, 0f, 0f, 1f); cube.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); calculateAndDisplayFPS(); } } }
Example 15
Source File: AndroidOpenGL.java From opengl with Apache License 2.0 | 5 votes |
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); // configure model space gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, 10f, 0, 0, 0, 0, 1, 0f); gl.glColor4f(1f, 0f, 0f, 1f); }
Example 16
Source File: TextureGL.java From opengl with Apache License 2.0 | 5 votes |
public void run() { initEGL(); initGL(); TexCubeSmallGLUT cube = new TexCubeSmallGLUT(3); // create room for two textures mGL.glEnable(GL10.GL_TEXTURE_2D); // use this texture unit mGL.glActiveTexture(GL10.GL_TEXTURE0); int[] textures = new int[1]; mGL.glGenTextures(1, textures, 0); cube.setTex(mGL, sv.getContext(), textures[0], R.drawable.android); mGL.glMatrixMode(GL10.GL_MODELVIEW); mGL.glLoadIdentity(); GLU.gluLookAt(mGL, 0, 0, 8f, 0, 0, 0, 0, 1, 0f); while (!mDone) { if (animState) { mGL.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); mGL.glRotatef(1f, 1f, 1f, 1f); mGL.glColor4f(1f, 0f, 0f, 1f); cube.draw(mGL); mEGL.eglSwapBuffers(mGLDisplay, mGLSurface); calculateAndDisplayFPS(); } } }
Example 17
Source File: StaticTriangleRenderer.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. */ glDisable(GL_DITHER); glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, 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(). */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* * Now we're ready to draw some 3D objects */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mTextureID); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); long time = SystemClock.uptimeMillis() % 4000L; float angle = 0.090f * ((int) time); glRotatef(angle, 0, 0, 1.0f); mTriangle.draw(gl); }
Example 18
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 19
Source File: MatrixPaletteRenderer.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); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_CULL_FACE); /* * 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; // Rock back and forth double animationUnit = ((double) time) / 4000; float unitAngle = (float) Math.cos(animationUnit * 2 * Math.PI); float angle = unitAngle * 135f; gl.glEnable(GL11Ext.GL_MATRIX_PALETTE_OES); gl.glMatrixMode(GL11Ext.GL_MATRIX_PALETTE_OES); GL11Ext gl11Ext = (GL11Ext) gl; // matrix 0: no transformation gl11Ext.glCurrentPaletteMatrixOES(0); gl11Ext.glLoadPaletteFromModelViewMatrixOES(); // matrix 1: rotate by "angle" gl.glRotatef(angle, 0, 0, 1.0f); gl11Ext.glCurrentPaletteMatrixOES(1); gl11Ext.glLoadPaletteFromModelViewMatrixOES(); mGrid.draw(gl); gl.glDisable(GL11Ext.GL_MATRIX_PALETTE_OES); }
Example 20
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; }