Java Code Examples for javax.microedition.khronos.opengles.GL10#glLoadIdentity()
The following examples show how to use
javax.microedition.khronos.opengles.GL10#glLoadIdentity() .
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: 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 2
Source File: Room.java From BobEngine with GNU Lesser General Public License v2.1 | 6 votes |
/** * Gathers the vertex, texture, and index data for each GameObject in this * room and passes that information to openGL. Can be called from another * room's draw method to draw both rooms at once. If overridden, call * super.draw(gl). * * @param gl OpenGL ES 1.0 object to do pass drawing information to. */ public void draw(GL10 gl) { // Update camera gl.glMatrixMode(GLES10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(camLeft, camRight, camBottom, camTop, -1, 1); // Draw graphics gl.glMatrixMode(GLES10.GL_MODELVIEW); gl.glLoadIdentity(); for (int l = 0; l < layers; l++) { for (int i = 0; i < renderables.size(); i++) { Renderable r = renderables.get(i); if (r.getGraphic() != null && r.getGraphic().shouldLoad()) { // Load the graphic if needed getView().getGraphicsHelper().addGraphic(r.getGraphic()); } r.render(gl, l); } } }
Example 3
Source File: CurlRenderer.java From Android-Example with Apache License 2.0 | 6 votes |
@Override public synchronized void onDrawFrame(GL10 gl) { mObserver.onDrawFrame(); gl.glClearColor(Color.red(mBackgroundColor) / 255f, Color.green(mBackgroundColor) / 255f, Color.blue(mBackgroundColor) / 255f, Color.alpha(mBackgroundColor) / 255f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); if (USE_PERSPECTIVE_PROJECTION) { gl.glTranslatef(0, 0, -6f); } for (int i = 0; i < mCurlMeshes.size(); ++i) { mCurlMeshes.get(i).onDrawFrame(gl); } }
Example 4
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 5
Source File: LabelMaker.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** * Begin drawing labels. Sets the OpenGL state for rapid drawing. * * @param gl * @param viewWidth * @param viewHeight */ public void beginDrawing(GL10 gl, float viewWidth, float viewHeight) { checkState(STATE_INITIALIZED, STATE_DRAWING); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glShadeModel(GL10.GL_FLAT); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrthof(0.0f, viewWidth, 0.0f, viewHeight, 0.0f, 1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); // Magic offsets to promote consistent rasterization. gl.glTranslatef(0.375f, 0.375f, 0.0f); }
Example 6
Source File: TouchSurfaceView.java From retrobreaker with MIT License | 6 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { mScreenWidth = width; mScreenHeight = height; float ratio = (float) width / height; State.setScreenMeasures((2.0f * Config.SCREEN_RATIO) - Config.WALL, 2.0f - Config.WALL); // Define a fixed game screen ratio independently of the screen resolution if(ratio >= Config.SCREEN_RATIO) { int newWidth = Math.round(height * Config.SCREEN_RATIO); gl.glViewport((width - newWidth)/2, 0, newWidth, height); } else { int newHeight = Math.round(width/Config.SCREEN_RATIO); gl.glViewport(0, (height - newHeight)/2, width, newHeight); } gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(-Config.SCREEN_RATIO, Config.SCREEN_RATIO, -1.0f, 1.0f, -1.0f, 1.0f); Matrix.orthoM(mUnprojectProjMatrix, 0, -Config.SCREEN_RATIO, Config.SCREEN_RATIO, -1.0f, 1.0f, -1.0f, 1.0f); Matrix.setIdentityM(mUnprojectViewMatrix, 0); }
Example 7
Source File: RotationVectorDemo.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public void onDrawFrame(GL10 gl) { // clear screen gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // set-up modelview matrix gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -3.0f); gl.glMultMatrixf(mRotationMatrix, 0); // draw our object gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); mCube.draw(gl); }
Example 8
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 9
Source File: RotationVectorDemo.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { // set view-port gl.glViewport(0, 0, width, height); // set projection matrix float ratio = (float) width / height; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); }
Example 10
Source File: OpenGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { // Sets the current view port to the new size. gl.glViewport(0, 0, width, height);// OpenGL docs. // Select the projection matrix gl.glMatrixMode(GL10.GL_PROJECTION);// OpenGL docs. // Reset the projection matrix gl.glLoadIdentity();// OpenGL docs. // Calculate the aspect ratio of the window GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f); // Select the modelview matrix gl.glMatrixMode(GL10.GL_MODELVIEW);// OpenGL docs. // Reset the modelview matrix gl.glLoadIdentity();// OpenGL docs. }
Example 11
Source File: OpenGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
public void onDrawFrame(GL10 gl) { // Clears the screen and depth buffer. gl.glClear(GL10.GL_COLOR_BUFFER_BIT | // OpenGL docs. GL10.GL_DEPTH_BUFFER_BIT); // Replace the current matrix with the identity matrix gl.glLoadIdentity(); // OpenGL docs // Translates 4 units into the screen. gl.glTranslatef(0, 0, -4); // OpenGL docs // Draw our square. square.draw(gl); // ( NEW ) }
Example 12
Source File: Renderer.java From augmentedreality with Apache License 2.0 | 5 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0,0,width,height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluPerspective(gl, 45.0f, ((float)width)/height, 0.11f, 100f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 13
Source File: PLRenderer.java From panoramagl with Apache License 2.0 | 5 votes |
/** * render methods */ protected void renderScene(GL10 gl, PLIScene scene, PLICamera camera) { if (scene != null && camera != null) { gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluPerspective(gl, camera.getFov(), PLConstants.kPerspectiveAspect, PLConstants.kPerspectiveZNear, PLConstants.kPerspectiveZFar); gl.glMatrixMode(GL10.GL_MODELVIEW); scene.render(gl, this); } }
Example 14
Source File: CubeRenderer.java From tilt-game-android with MIT License | 5 votes |
/** * Update view-port with the new surface * * @param gl the surface * @param width new width * @param height new height */ public void onSurfaceChanged(GL10 gl, int width, int height) { // set view-port gl.glViewport(0, 0, width, height); // set projection matrix float ratio = (float) width / height; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); }
Example 15
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 16
Source File: OpenGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
public void onSurfaceChanged(GL10 gl, int width, int height) { // Sets the current view port to the new size. gl.glViewport(0, 0, width, height);// OpenGL docs. // Select the projection matrix gl.glMatrixMode(GL10.GL_PROJECTION);// OpenGL docs. // Reset the projection matrix gl.glLoadIdentity();// OpenGL docs. // Calculate the aspect ratio of the window GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f); // Select the modelview matrix gl.glMatrixMode(GL10.GL_MODELVIEW);// OpenGL docs. // Reset the modelview matrix gl.glLoadIdentity();// OpenGL docs. }
Example 17
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 18
Source File: OpenGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
public void onDrawFrame(GL10 gl) { // Clears the screen and depth buffer. gl.glClear(GL10.GL_COLOR_BUFFER_BIT | // OpenGL docs. GL10.GL_DEPTH_BUFFER_BIT); // Replace the current matrix with the identity matrix gl.glLoadIdentity(); // OpenGL docs // Translates 4 units into the screen. gl.glTranslatef(0, 0, -4); // OpenGL docs // Draw our square. square.draw(gl); // ( NEW ) }
Example 19
Source File: GLFieldView.java From homescreenarcade with GNU General Public License v3.0 | 5 votes |
void endGLElements(GL10 gl) { vertexListManager.end(); gl.glEnable(GL10.GL_DITHER); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glLineWidth(2); vertexListManager.render(gl); }
Example 20
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); }