// ############################################################
// ############################################################
//
// This class is a replacement for the original GLSurfaceView, due to issue:
// http://code.google.com/p/android/issues/detail?id=2828
//
// Reason: Two sequential Activities using a GLSurfaceView leads to a deadlock in the GLThread!
//
// ############################################################
// ############################################################
package org.anddev.andengine.opengl.view;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
/**
* An implementation of SurfaceView that uses the dedicated surface for
* displaying OpenGL rendering.
* <p>
* A GLSurfaceView provides the following features:
* <p>
* <ul>
* <li>Manages a surface, which is a special piece of memory that can be
* composited into the Android view system.
* <li>Manages an EGL display, which enables OpenGL to render into a surface.
* <li>Accepts a user-provided Renderer object that does the actual rendering.
* <li>Renders on a dedicated thread to decouple rendering performance from the
* UI thread.
* <li>Supports both on-demand and continuous rendering.
* <li>Optionally wraps, traces, and/or error-checks the renderer's OpenGL
* calls.
* </ul>
*
* <h3>Using GLSurfaceView</h3>
* <p>
* Typically you use GLSurfaceView by subclassing it and overriding one or more
* of the View system input event methods. If your application does not need to
* override event methods then GLSurfaceView can be used as-is. For the most
* part GLSurfaceView behavior is customized by calling "set" methods rather
* than by subclassing. For example, unlike a regular View, drawing is delegated
* to a separate Renderer object which is registered with the GLSurfaceView
* using the {@link #setRenderer(Renderer)} call.
* <p>
* <h3>Initializing GLSurfaceView</h3>
* All you have to do to initialize a GLSurfaceView is call
* {@link #setRenderer(Renderer)}. However, if desired, you can modify the
* default behavior of GLSurfaceView by calling one or more of these methods
* before calling setRenderer:
* <ul>
* <li>{@link #setDebugFlags(int)}
* <li>{@link #setEGLConfigChooser(boolean)}
* <li>{@link #setEGLConfigChooser(EGLConfigChooser)}
* <li>{@link #setEGLConfigChooser(int, int, int, int, int, int)}
* <li>{@link #setGLWrapper(GLWrapper)}
* </ul>
* <p>
* <h4>Choosing an EGL Configuration</h4>
* A given Android device may support multiple possible types of drawing
* surfaces. The available surfaces may differ in how may channels of data are
* present, as well as how many bits are allocated to each channel. Therefore,
* the first thing GLSurfaceView has to do when starting to render is choose
* what type of surface to use.
* <p>
* By default GLSurfaceView chooses an available surface that's closest to a
* 16-bit R5G6B5 surface with a 16-bit depth buffer and no stencil. If you would
* prefer a different surface (for example, if you do not need a depth buffer)
* you can override the default behavior by calling one of the
* setEGLConfigChooser methods.
* <p>
* <h4>Debug Behavior</h4>
* You can optionally modify the behavior of GLSurfaceView by calling one or
* more of the debugging methods {@link #setDebugFlags(int)}, and
* {@link #setGLWrapper}. These methods may be called before and/or after
* setRenderer, but typically they are called before setRenderer so that they
* take effect immediately.
* <p>
* <h4>Setting a Renderer</h4>
* Finally, you must call {@link #setRenderer} to register a {@link Renderer}.
* The renderer is responsible for doing the actual OpenGL rendering.
* <p>
* <h3>Rendering Mode</h3>
* Once the renderer is set, you can control whether the renderer draws
* continuously or on-demand by calling {@link #setRenderMode}. The default is
* continuous rendering.
* <p>
* <h3>Activity Life-cycle</h3>
* A GLSurfaceView must be notified when the activity is paused and resumed.
* GLSurfaceView clients are required to call {@link #onPause()} when the
* activity pauses and {@link #onResume()} when the activity resumes. These
* calls allow GLSurfaceView to pause and resume the rendering thread, and also
* allow GLSurfaceView to release and recreate the OpenGL display.
* <p>
* <h3>Handling events</h3>
* <p>
* To handle an event you will typically subclass GLSurfaceView and override the
* appropriate method, just as you would with any other View. However, when
* handling the event, you may need to communicate with the Renderer object
* that's running in the rendering thread. You can do this using any standard
* Java cross-thread communication mechanism. In addition, one relatively easy
* way to communicate with your renderer is to call
* {@link #queueEvent(Runnable)}. For example:
*
* <pre class="prettyprint">
* class MyGLSurfaceView extends GLSurfaceView {
*
* private MyRenderer mMyRenderer;
*
* public void start() {
* mMyRenderer = ...;
* setRenderer(mMyRenderer);
* }
*
* public boolean onKeyDown(int keyCode, KeyEvent event) {
* if(keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
* queueEvent(new Runnable() {
* // This method will be called on the rendering
* // thread:
* public void run() {
* mMyRenderer.handleDpadCenter();
* }
* });
* return true;
* }
* return super.onKeyDown(keyCode, event);
* }
* }
* </pre>
*
*/
public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
// ===========================================================
// Constants
// ===========================================================
/**
* The renderer only renders when the surface is created, or when
* {@link #requestRender} is called.
*
* @see #getRenderMode()
* @see #setRenderMode(int)
*/
public final static int RENDERMODE_WHEN_DIRTY = 0;
/**
* The renderer is called continuously to re-render the scene.
*
* @see #getRenderMode()
* @see #setRenderMode(int)
* @see #requestRender()
*/
public final static int RENDERMODE_CONTINUOUSLY = 1;
/**
* Check glError() after every GL call and throw an exception if glError
* indicates that an error has occurred. This can be used to help track down
* which OpenGL ES call is causing an error.
*
* @see #getDebugFlags
* @see #setDebugFlags
*/
public final static int DEBUG_CHECK_GL_ERROR = 1;
/**
* Log GL calls to the system log at "verbose" level with tag
* "GLSurfaceView".
*
* @see #getDebugFlags
* @see #setDebugFlags
*/
public final static int DEBUG_LOG_GL_CALLS = 2;
private static final Semaphore sEglSemaphore = new Semaphore(1);
// ===========================================================
// Fields
// ===========================================================
private GLThread mGLThread;
private EGLConfigChooser mEGLConfigChooser;
private GLWrapper mGLWrapper;
private int mDebugFlags;
private int mRenderMode;
private Renderer mRenderer;
private int mSurfaceWidth;
private int mSurfaceHeight;
private boolean mHasSurface;
// ===========================================================
// Constructors
// ===========================================================
/**
* Standard View constructor. In order to render something, you must call
* {@link #setRenderer} to register a renderer.
*/
public GLSurfaceView(final Context context) {
super(contex
没有合适的资源?快使用搜索试试~ 我知道了~
Android 游戏源代码 MasterMind(含截图)
共465个文件
java:405个
png:27个
xcf:23个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 139 浏览量
2022-06-23
08:32:25
上传
评论
收藏 2.75MB RAR 举报
温馨提示
Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android 游戏源代码 MasterMind(含截图)Android
资源推荐
资源详情
资源评论
收起资源包目录
Android 游戏源代码 MasterMind(含截图) (465个子文件)
cert 1KB
proguard.cfg 1KB
.classpath 364B
GLSurfaceView.java 31KB
Entity.java 26KB
Engine.java 24KB
Base64.java 24KB
Texture.java 19KB
Scene.java 19KB
GLHelper.java 16KB
BaseMenuItemDecorator.java 14KB
Game.java 14KB
TMXLayer.java 12KB
BlackPawnTextureBuilder.java 12KB
Camera.java 11KB
PathModifier.java 11KB
BuildableTexture.java 11KB
SpriteBatch.java 10KB
AnimatedSprite.java 10KB
TextureRegionFactory.java 9KB
ParticleSystem.java 9KB
BaseGameActivity.java 9KB
TMXParser.java 9KB
ActivityUtils.java 9KB
IEntity.java 9KB
Font.java 9KB
AStarPathFinder.java 8KB
BaseOnScreenControl.java 8KB
SystemUtils.java 7KB
FileUtils.java 7KB
TMXTileSet.java 7KB
MathUtils.java 7KB
TMXTiledMap.java 7KB
HoldDetector.java 7KB
SpriteBatchVertexBuffer.java 7KB
SequenceModifier.java 7KB
BaseTextureSourceDecorator.java 7KB
SAXUtils.java 7KB
MenuScene.java 6KB
LinearGradientFillTextureSourceDecorator.java 6KB
Transformation.java 6KB
SurfaceGestureDetector.java 6KB
Text.java 6KB
Line.java 6KB
FastFloatBuffer.java 6KB
TextureManager.java 6KB
RadialGradientFillTextureSourceDecorator.java 6KB
BufferObjectManager.java 6KB
Shape.java 5KB
SmoothCamera.java 5KB
LoopModifier.java 5KB
RenderSurfaceView.java 5KB
Path.java 5KB
BoundCamera.java 5KB
BaseTextureRegion.java 5KB
ShapeCollisionChecker.java 5KB
DoubleSceneSplitScreenEngine.java 5KB
LevelStatsDBConnector.java 5KB
LevelLoader.java 5KB
StreamUtils.java 5KB
BaseSplashActivity.java 5KB
AnalogOnScreenControl.java 5KB
RectangularShape.java 5KB
ScaleAtModifier.java 5KB
DigitalOnScreenControl.java 5KB
ColorBackground.java 5KB
BaseCollisionChecker.java 5KB
ParallaxBackground.java 5KB
ParallelModifier.java 5KB
MainMenu.java 5KB
ScreenGrabber.java 5KB
BaseActivity.java 4KB
PhysicsHandler.java 4KB
TMXLoader.java 4KB
TiledTextureRegion.java 4KB
GenericInputDialogBuilder.java 4KB
ZoomCamera.java 4KB
SlideMenuAnimator.java 4KB
BaseTouchController.java 4KB
Base64InputStream.java 4KB
TextureRegionBuffer.java 4KB
BufferObject.java 4KB
TSXParser.java 4KB
OrientationData.java 4KB
AlphaMenuAnimator.java 4KB
ScreenCapture.java 4KB
TouchEvent.java 4KB
TMXConstants.java 4KB
ScrollDetector.java 4KB
AccelerometerData.java 4KB
ScaleModifier.java 4KB
FontFactory.java 4KB
LocationSensorOptions.java 4KB
Debug.java 4KB
SmartList.java 4KB
SingleSceneSplitScreenEngine.java 4KB
RectangularShapeCollisionChecker.java 4KB
EngineOptions.java 4KB
CameraScene.java 4KB
TextVertexBuffer.java 4KB
共 465 条
- 1
- 2
- 3
- 4
- 5
资源评论
金枝玉叶9
- 粉丝: 124
- 资源: 7640
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功