android.opengl.GLU Java Examples
The following examples show how to use
android.opengl.GLU.
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: 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 #2
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 #3
Source File: GLCanvasImpl.java From document-viewer with GNU General Public License v3.0 | 6 votes |
@Override public void setSize(final int width, final int height) { mScreenWidth = width; mScreenHeight = height; mAlpha = 1.0f; final GL11 gl = mGL; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluOrtho2D(gl, 0, width, 0, height); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); final float matrix[] = mMatrixValues; Matrix.setIdentityM(matrix, 0); // to match the graphic coordinate system in android, we flip it vertically. Matrix.translateM(matrix, 0, 0, height, 0); Matrix.scaleM(matrix, 0, 1, -1, 1); }
Example #4
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 #5
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 #6
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 6 votes |
public void initGL( ) { int width = sv.getWidth(); int height = sv.getHeight(); mGL.glViewport(0, 0, width, height); mGL.glMatrixMode(GL10.GL_PROJECTION); mGL.glLoadIdentity(); float aspect = (float) width/height; GLU.gluPerspective(mGL, 45.0f, aspect, 1.0f, 30.0f); mGL.glClearColor(0.5f,0.5f,0.5f,1); // the only way to draw primitives with OpenGL ES mGL.glEnableClientState(GL10.GL_VERTEX_ARRAY); // some rendering options mGL.glShadeModel(GL10.GL_SMOOTH); mGL.glEnable(GL10.GL_DEPTH_TEST); //mGL.glEnable(GL10.GL_CULL_FACE); Log.i("GL", "GL initialized"); }
Example #7
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 #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: BasicGLCube.java From opengl with Apache License 2.0 | 6 votes |
public void initGL( ) { int width = sv.getWidth(); int height = sv.getHeight(); mGL.glViewport(0, 0, width, height); mGL.glMatrixMode(GL10.GL_PROJECTION); mGL.glLoadIdentity(); float aspect = (float) width/height; GLU.gluPerspective(mGL, 45.0f, aspect, 1.0f, 30.0f); mGL.glClearColor(0.5f,0.5f,0.5f,1); // the only way to draw primitives with OpenGL ES mGL.glEnableClientState(GL10.GL_VERTEX_ARRAY); // some rendering options mGL.glShadeModel(GL10.GL_SMOOTH); mGL.glEnable(GL10.GL_DEPTH_TEST); //mGL.glEnable(GL10.GL_CULL_FACE); Log.i("GL", "GL initialized"); }
Example #10
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 #11
Source File: BobRenderer.java From BobEngine with GNU Lesser General Public License v2.1 | 6 votes |
/** * Handle changes such as orientation changes. This also happens when the * surface is created. <br /> * <br /> * This method will set the background color, set the viewport, remove * perspective. */ @Override public void onSurfaceChanged(GL10 gl, int width, int height) { if (height == 0) { // Prevent A Divide By Zero By height = 1; // Making Height Equal One } camWidth = width; camHeight = height; //myOwner.getGraphicsHelper().loadAllGraphics(gl); gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix gl.glLoadIdentity(); // Reset The Projection Matrix GLU.gluOrtho2D(gl, 0, width, 0, height); // Use orthogonic view. No perspective. gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix gl.glLoadIdentity(); }
Example #12
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 #13
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 #14
Source File: MyGLRenderer.java From TikTok with Apache License 2.0 | 6 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { if (height == 0) { // Prevent A Divide By Zero By height = 1; // Making Height Equal One } this.width = width; this.height = height; gl.glViewport(0, 0, width, height); // Reset The // Current // Viewport gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix gl.glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix gl.glLoadIdentity(); }
Example #15
Source File: CurlRenderer.java From Android-Example with Apache License 2.0 | 6 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); mViewportWidth = width; mViewportHeight = height; float ratio = (float) width / height; mViewRect.top = 1.0f; mViewRect.bottom = -1.0f; mViewRect.left = -ratio; mViewRect.right = ratio; updatePageRects(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); if (USE_PERSPECTIVE_PROJECTION) { GLU.gluPerspective(gl, 20f, (float) width / height, .1f, 100f); } else { GLU.gluOrtho2D(gl, mViewRect.left, mViewRect.right, mViewRect.bottom, mViewRect.top); } gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); }
Example #16
Source File: PageRenderer.java From PlayLikeCurl with MIT License | 6 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { if(height == 0) { height = 1; } gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); if(height>width) GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f); else GLU.gluPerspective(gl, 45.0f, (float) height / (float) width, 0.1f, 100.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); }
Example #17
Source File: TouchSurfaceView.java From retrobreaker with MIT License | 5 votes |
@Override public boolean onTouchEvent(MotionEvent e) { switch (e.getAction()) { case MotionEvent.ACTION_MOVE: final float screenX = e.getX(); final float screenY = mScreenHeight - e.getY(); final int[] viewport = { 0, 0, mScreenWidth, mScreenHeight }; float[] resultWorldPos = { 0.0f, 0.0f, 0.0f, 0.0f }; GLU.gluUnProject(screenX, screenY, 0, mUnprojectViewMatrix, 0, mUnprojectProjMatrix, 0, viewport, 0, resultWorldPos, 0); resultWorldPos[0] /= resultWorldPos[3]; resultWorldPos[1] /= resultWorldPos[3]; resultWorldPos[2] /= resultWorldPos[3]; resultWorldPos[3] = 1.0f; mRenderer.updatePaddlePosition(resultWorldPos[0]); break; case MotionEvent.ACTION_DOWN: // Only start the game when the user clicks on the screen State.setGamePaused(false); break; } return true; }
Example #18
Source File: FlipRenderer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
public static void checkError(GL10 gl) { if (AphidLog.ENABLE_DEBUG) { int error = gl.glGetError(); if (error != 0) { throw new RuntimeException(GLU.gluErrorString(error)); } } }
Example #19
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 #20
Source File: AndroidOpenGL.java From opengl with Apache License 2.0 | 5 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); // configure projection to screen gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glClearColor(0.5f, 0.5f, 0.5f, 1); float aspect = (float) width / height; GLU.gluPerspective(gl, 45.0f, aspect, 1.0f, 30.0f); }
Example #21
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 #22
Source File: FlipRenderer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
public static void checkError(GL10 gl) { if (AphidLog.ENABLE_DEBUG) { int error = gl.glGetError(); if (error != 0) { throw new RuntimeException(GLU.gluErrorString(error)); } } }
Example #23
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 #24
Source File: TGAGLSurfaceView.java From TGAReader with MIT License | 5 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); GLU.gluPerspective(gl, 45, (float)width/height, 1, 10); }
Example #25
Source File: ARObject.java From geoar-app with Apache License 2.0 | 5 votes |
private final void updateScreenCoordinates() { float[] screenPos = new float[3]; // TODO FIXME XXX i think newPosition[2] has to be negative int result = GLU.gluProject(-newPosition[0], newPosition[1], newPosition[2], modelMatrix, 0, GLESCamera.projectionMatrix, 0, GLESCamera.viewportMatrix, 0, screenPos, 0); if (result == GL10.GL_TRUE) { screenCoordinates[0] = screenPos[0]; screenCoordinates[1] = GLESCamera.viewportMatrix[3] - screenPos[1]; } }
Example #26
Source File: GLException.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private static String getErrorString(final int pError) { String errorString = GLU.gluErrorString(pError); if(errorString == null) { errorString = "Unknown error '0x" + Integer.toHexString(pError) + "'."; } return errorString; }
Example #27
Source File: RenderFeature2.java From geoar-app with Apache License 2.0 | 5 votes |
public float[] onScreenCoordsUpdate() { if (modelMatrix == null || GLESCamera.projectionMatrix == null || GLESCamera.viewportMatrix == null) { return null; } float[] output = new float[3]; int res = GLU.gluProject(position[0], position[1], position[2], modelMatrix, 0, GLESCamera.projectionMatrix, 0, GLESCamera.viewportMatrix, 0, output, 0); if (res == GL10.GL_FALSE) return null; return output; }
Example #28
Source File: RendererUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Checks for an OpenGL error and throws a {@link RendererException} if * there is one. Ignores the value of * {@link RendererUtil#ENABLE_ERROR_CHECKING}. */ public static void checkGLErrorForced() { int error = GLES20.glGetError(); if (error != 0) { String message = GLU.gluErrorString(error); if (message == null) { throw new RendererException("An unknown OpenGL error has occurred."); } else { throw new RendererException("An OpenGL error has occurred: " + message); } } }
Example #29
Source File: RendererUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Checks for an OpenGL error and throws a {@link RendererException} if * there is one. Does nothing if {@link RendererUtil#ENABLE_ERROR_CHECKING} * is set to * <code>false</code>. */ public static void checkGLError() { if (!ENABLE_ERROR_CHECKING) { return; } int error = GLES20.glGetError(); if (error != 0) { String message = GLU.gluErrorString(error); if (message == null) { throw new RendererException("An unknown OpenGL error has occurred."); } else { throw new RendererException("An OpenGL error has occurred: " + message); } } }
Example #30
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); }