/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hippo.tuxiang; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; // android-9.0.0_r30 /** * A generic renderer interface. *
* The renderer is responsible for making OpenGL calls to render a frame. *
* GLSurfaceView clients typically create their own classes that implement * this interface, and then call {@link GLStuff#setRenderer} to * register the renderer with the GLSurfaceView. *
* *
For more information about how to use OpenGL, read the * OpenGL developer guide.
**
* Called when the rendering thread * starts and whenever the EGL context is lost. The EGL context will typically * be lost when the Android device awakes after going to sleep. *
* Since this method is called at the beginning of rendering, as well as * every time the EGL context is lost, this method is a convenient place to put * code to create resources that need to be created when the rendering * starts, and that need to be recreated when the EGL context is lost. * Textures are an example of a resource that you might want to create * here. *
* Note that when the EGL context is lost, all OpenGL resources associated * with that context will be automatically deleted. You do not need to call * the corresponding "glDelete" methods such as glDeleteTextures to * manually delete these lost resources. *
* @param gl the GL interface. Use instanceof to
* test if the interface supports GL11 or higher interfaces.
* @param config the EGLConfig of the created surface. Can be used
* to create matching pbuffers.
*/
void onSurfaceCreated(GL10 gl, EGLConfig config);
/**
* Called when the surface changed size.
*
* Called after the surface is created and whenever * the OpenGL ES surface size changes. *
* Typically you will set your viewport here. If your camera * is fixed then you could also set your projection matrix here: *
* void onSurfaceChanged(GL10 gl, int width, int height) {
* gl.glViewport(0, 0, width, height);
* // for a fixed camera, set the projection too
* float ratio = (float) width / height;
* gl.glMatrixMode(GL10.GL_PROJECTION);
* gl.glLoadIdentity();
* gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
* }
*
* @param gl the GL interface. Use instanceof to
* test if the interface supports GL11 or higher interfaces.
*/
void onSurfaceChanged(GL10 gl, int width, int height);
/**
* Called to draw the current frame.
* * This method is responsible for drawing the current frame. *
* The implementation of this method typically looks like this: *
* void onDrawFrame(GL10 gl) {
* gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
* //... other gl calls to render the scene ...
* }
*
* @param gl the GL interface. Use instanceof to
* test if the interface supports GL11 or higher interfaces.
* @return {@code false} for not drew, will not swap buffers.
*/
boolean onDrawFrame(GL10 gl);
/**
* Called when the GL thread exits.
* * GL thread starts after {@link GLStuff#setRenderer(Renderer)} called, and * after {@link android.view.View#onDetachedFromWindow} called except * the first time. *
* It is a good time to prepare resources. */ void onGLThreadStart(); /** * Called when the GL thread exits. *
* GL thread ends after {@link android.view.View#onDetachedFromWindow} called. *
* It is a good time to release resources. */ void onGLThreadExit(); /** * Called after {@link GLStuff#onPause()} called. *
* It is a good time to stop animations. */ void onGLThreadPause(); /** * Called after {@link GLStuff#onResume()} called. *
* It is a good time to restart animations. */ void onGLThreadResume(); }