com.badlogic.gdx.backends.android.surfaceview
Class GLBaseSurfaceView

java.lang.Object
  extended by android.view.View
      extended by android.view.SurfaceView
          extended by android.opengl.GLSurfaceView
              extended by com.badlogic.gdx.backends.android.surfaceview.GLBaseSurfaceView
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.view.accessibility.AccessibilityEventSource, android.view.KeyEvent.Callback, android.view.SurfaceHolder.Callback

public class GLBaseSurfaceView
extends android.opengl.GLSurfaceView
implements android.view.SurfaceHolder.Callback

An implementation of SurfaceView that uses the dedicated surface for displaying OpenGL rendering.

A GLSurfaceView provides the following features:

Using GLSurfaceView

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 GLSurfaceView.setRenderer(Renderer) call.

Initializing GLSurfaceView

All you have to do to initialize a GLSurfaceView is call GLSurfaceView.setRenderer(Renderer). However, if desired, you can modify the default behavior of GLSurfaceView by calling one or more of these methods before calling setRenderer:

Choosing an EGL Configuration

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.

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.

Debug Behavior

You can optionally modify the behavior of GLSurfaceView by calling one or more of the debugging methods setDebugFlags(int), and setGLWrapper(com.badlogic.gdx.backends.android.surfaceview.GLBaseSurfaceView.GLWrapper). These methods may be called before and/or after setRenderer, but typically they are called before setRenderer so that they take effect immediately.

Setting a Renderer

Finally, you must call setRenderer(android.opengl.GLSurfaceView.Renderer) to register a Renderer. The renderer is responsible for doing the actual OpenGL rendering.

Rendering Mode

Once the renderer is set, you can control whether the renderer draws continuously or on-demand by calling setRenderMode(int). The default is continuous rendering.

Activity Life-cycle

A GLSurfaceView must be notified when the activity is paused and resumed. GLSurfaceView clients are required to call onPause() when the activity pauses and 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.

Handling events

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 queueEvent(Runnable). For example:

 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);
        }
 }
 
 
 
 
 
 


Nested Class Summary
static interface GLBaseSurfaceView.EGLContextFactory
          An interface for customizing the eglCreateContext and eglDestroyContext calls.
static interface GLBaseSurfaceView.EGLWindowSurfaceFactory
          An interface for customizing the eglCreateWindowSurface and eglDestroySurface calls.
static interface GLBaseSurfaceView.GLWrapper
          An interface used to wrap a GL interface.
 
Nested classes/interfaces inherited from class android.opengl.GLSurfaceView
android.opengl.GLSurfaceView.EGLConfigChooser, android.opengl.GLSurfaceView.Renderer
 
Nested classes/interfaces inherited from class android.view.View
android.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnAttachStateChangeListener, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener
 
Field Summary
static int DEBUG_CHECK_GL_ERROR
          Check glError() after every GL call and throw an exception if glError indicates that an error has occurred.
static int DEBUG_LOG_GL_CALLS
          Log GL calls to the system log at "verbose" level with tag "GLSurfaceView".
static int RENDERMODE_CONTINUOUSLY
          The renderer is called continuously to re-render the scene.
static int RENDERMODE_WHEN_DIRTY
          The renderer only renders when the surface is created, or when requestRender() is called.
 
Fields inherited from class android.view.View
ALPHA, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, VISIBLE, X, Y
 
Constructor Summary
GLBaseSurfaceView(android.content.Context context)
          Standard View constructor.
GLBaseSurfaceView(android.content.Context context, android.util.AttributeSet attrs)
          Standard View constructor.
 
Method Summary
 int getDebugFlags()
          Get the current value of the debug flags.
 int getRenderMode()
          Get the current rendering mode.
 void onPause()
          Inform the view that the activity is paused.
 void onResume()
          Inform the view that the activity is resumed.
 void queueEvent(Runnable r)
          Queue a runnable to be run on the GL rendering thread.
 void requestRender()
          Request that the renderer render a frame.
 void setDebugFlags(int debugFlags)
          Set the debug flags to a new value.
 void setEGLConfigChooser(boolean needDepth)
          Install a config chooser which will choose a config as close to 16-bit RGB as possible, with or without an optional depth buffer as close to 16-bits as possible.
 void setEGLConfigChooser(android.opengl.GLSurfaceView.EGLConfigChooser configChooser)
          Install a custom EGLConfigChooser.
 void setEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
          Install a config chooser which will choose a config with at least the specified component sizes, and as close to the specified component sizes as possible.
 void setEGLContextFactory(GLBaseSurfaceView.EGLContextFactory factory)
          Install a custom EGLContextFactory.
 void setEGLWindowSurfaceFactory(GLBaseSurfaceView.EGLWindowSurfaceFactory factory)
          Install a custom EGLWindowSurfaceFactory.
 void setGLWrapper(GLBaseSurfaceView.GLWrapper glWrapper)
          Set the glWrapper.
 void setRenderer(android.opengl.GLSurfaceView.Renderer renderer)
          Set the renderer associated with this view.
 void setRenderMode(int renderMode)
          Set the rendering mode.
 void surfaceChanged(android.view.SurfaceHolder holder, int format, int w, int h)
          This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.
 void surfaceCreated(android.view.SurfaceHolder holder)
          This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.
 void surfaceDestroyed(android.view.SurfaceHolder holder)
          This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.
 
Methods inherited from class android.opengl.GLSurfaceView
getPreserveEGLContextOnPause, setEGLContextClientVersion, setEGLContextFactory, setEGLWindowSurfaceFactory, setGLWrapper, setPreserveEGLContextOnPause
 
Methods inherited from class android.view.SurfaceView
draw, gatherTransparentRegion, getHolder, setSecure, setVisibility, setZOrderMediaOverlay, setZOrderOnTop
 
Methods inherited from class android.view.View
addChildrenForAccessibility, addFocusables, addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, clearFocus, combineMeasuredStates, computeScroll, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, findFocus, findViewById, findViewsWithText, findViewWithTag, focusSearch, forceLayout, generateViewId, getAccessibilityNodeProvider, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getCameraDistance, getContentDescription, getContext, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResources, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hasFocus, hasFocusable, hasOnClickListeners, hasOverlappingRendering, hasTransientState, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPaddingRelative, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, jumpDrawablesToCurrentState, layout, measure, offsetLeftAndRight, offsetTopAndBottom, onCheckIsTextEditor, onCreateInputConnection, onDragEvent, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPopulateAccessibilityEvent, onRtlPropertiesChanged, onScreenStateChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, startActionMode, startAnimation, startDrag, toString, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RENDERMODE_WHEN_DIRTY

public static final int RENDERMODE_WHEN_DIRTY
The renderer only renders when the surface is created, or when requestRender() is called.

See Also:
getRenderMode(), setRenderMode(int), Constant Field Values

RENDERMODE_CONTINUOUSLY

public static final int RENDERMODE_CONTINUOUSLY
The renderer is called continuously to re-render the scene.

See Also:
getRenderMode(), setRenderMode(int), requestRender(), Constant Field Values

DEBUG_CHECK_GL_ERROR

public static final int DEBUG_CHECK_GL_ERROR
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 Also:
getDebugFlags(), setDebugFlags(int), Constant Field Values

DEBUG_LOG_GL_CALLS

public static final int DEBUG_LOG_GL_CALLS
Log GL calls to the system log at "verbose" level with tag "GLSurfaceView".

See Also:
getDebugFlags(), setDebugFlags(int), Constant Field Values
Constructor Detail

GLBaseSurfaceView

public GLBaseSurfaceView(android.content.Context context)
Standard View constructor. In order to render something, you must call setRenderer(android.opengl.GLSurfaceView.Renderer) to register a renderer.


GLBaseSurfaceView

public GLBaseSurfaceView(android.content.Context context,
                         android.util.AttributeSet attrs)
Standard View constructor. In order to render something, you must call setRenderer(android.opengl.GLSurfaceView.Renderer) to register a renderer.

Method Detail

setGLWrapper

public void setGLWrapper(GLBaseSurfaceView.GLWrapper glWrapper)
Set the glWrapper. If the glWrapper is not null, its GLBaseSurfaceView.GLWrapper.wrap(GL) method is called whenever a surface is created. A GLWrapper can be used to wrap the GL object that's passed to the renderer. Wrapping a GL object enables examining and modifying the behavior of the GL calls made by the renderer.

Wrapping is typically used for debugging purposes.

The default value is null.

Parameters:
glWrapper - the new GLWrapper

setDebugFlags

public void setDebugFlags(int debugFlags)
Set the debug flags to a new value. The value is constructed by OR-together zero or more of the DEBUG_CHECK_* constants. The debug flags take effect whenever a surface is created. The default value is zero.

Overrides:
setDebugFlags in class android.opengl.GLSurfaceView
Parameters:
debugFlags - the new debug flags
See Also:
DEBUG_CHECK_GL_ERROR, DEBUG_LOG_GL_CALLS

getDebugFlags

public int getDebugFlags()
Get the current value of the debug flags.

Overrides:
getDebugFlags in class android.opengl.GLSurfaceView
Returns:
the current value of the debug flags.

setRenderer

public void setRenderer(android.opengl.GLSurfaceView.Renderer renderer)
Set the renderer associated with this view. Also starts the thread that will call the renderer, which in turn causes the rendering to start.

This method should be called once and only once in the life-cycle of a GLSurfaceView.

The following GLSurfaceView methods can only be called before setRenderer is called:

The following GLSurfaceView methods can only be called after setRenderer is called:

Overrides:
setRenderer in class android.opengl.GLSurfaceView
Parameters:
renderer - the renderer to use to perform OpenGL drawing.

setEGLContextFactory

public void setEGLContextFactory(GLBaseSurfaceView.EGLContextFactory factory)
Install a custom EGLContextFactory.

If this method is called, it must be called before GLSurfaceView.setRenderer(Renderer) is called.

If this method is not called, then by default a context will be created with no shared context and with a null attribute list.


setEGLWindowSurfaceFactory

public void setEGLWindowSurfaceFactory(GLBaseSurfaceView.EGLWindowSurfaceFactory factory)
Install a custom EGLWindowSurfaceFactory.

If this method is called, it must be called before GLSurfaceView.setRenderer(Renderer) is called.

If this method is not called, then by default a window surface will be created with a null attribute list.


setEGLConfigChooser

public void setEGLConfigChooser(android.opengl.GLSurfaceView.EGLConfigChooser configChooser)
Install a custom EGLConfigChooser.

If this method is called, it must be called before GLSurfaceView.setRenderer(Renderer) is called.

If no setEGLConfigChooser method is called, then by default the view will choose a config as close to 16-bit RGB as possible, with a depth buffer as close to 16 bits as possible.

Overrides:
setEGLConfigChooser in class android.opengl.GLSurfaceView
Parameters:
configChooser -

setEGLConfigChooser

public void setEGLConfigChooser(boolean needDepth)
Install a config chooser which will choose a config as close to 16-bit RGB as possible, with or without an optional depth buffer as close to 16-bits as possible.

If this method is called, it must be called before GLSurfaceView.setRenderer(Renderer) is called.

If no setEGLConfigChooser method is called, then by default the view will choose a config as close to 16-bit RGB as possible, with a depth buffer as close to 16 bits as possible.

Overrides:
setEGLConfigChooser in class android.opengl.GLSurfaceView
Parameters:
needDepth -

setEGLConfigChooser

public void setEGLConfigChooser(int redSize,
                                int greenSize,
                                int blueSize,
                                int alphaSize,
                                int depthSize,
                                int stencilSize)
Install a config chooser which will choose a config with at least the specified component sizes, and as close to the specified component sizes as possible.

If this method is called, it must be called before GLSurfaceView.setRenderer(Renderer) is called.

If no setEGLConfigChooser method is called, then by default the view will choose a config as close to 16-bit RGB as possible, with a depth buffer as close to 16 bits as possible.

Overrides:
setEGLConfigChooser in class android.opengl.GLSurfaceView

setRenderMode

public void setRenderMode(int renderMode)
Set the rendering mode. When renderMode is RENDERMODE_CONTINUOUSLY, the renderer is called repeatedly to re-render the scene. When renderMode is RENDERMODE_WHEN_DIRTY, the renderer only rendered when the surface is created, or when requestRender() is called. Defaults to RENDERMODE_CONTINUOUSLY.

Using RENDERMODE_WHEN_DIRTY can improve battery life and overall system performance by allowing the GPU and CPU to idle when the view does not need to be updated.

This method can only be called after GLSurfaceView.setRenderer(Renderer)

Overrides:
setRenderMode in class android.opengl.GLSurfaceView
Parameters:
renderMode - one of the RENDERMODE_X constants
See Also:
RENDERMODE_CONTINUOUSLY, RENDERMODE_WHEN_DIRTY

getRenderMode

public int getRenderMode()
Get the current rendering mode. May be called from any thread. Must not be called before a renderer has been set.

Overrides:
getRenderMode in class android.opengl.GLSurfaceView
Returns:
the current rendering mode.
See Also:
RENDERMODE_CONTINUOUSLY, RENDERMODE_WHEN_DIRTY

requestRender

public void requestRender()
Request that the renderer render a frame. This method is typically used when the render mode has been set to RENDERMODE_WHEN_DIRTY, so that frames are only rendered on demand. May be called from any thread. Must not be called before a renderer has been set.

Overrides:
requestRender in class android.opengl.GLSurfaceView

surfaceCreated

public void surfaceCreated(android.view.SurfaceHolder holder)
This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.

Specified by:
surfaceCreated in interface android.view.SurfaceHolder.Callback
Overrides:
surfaceCreated in class android.opengl.GLSurfaceView

surfaceDestroyed

public void surfaceDestroyed(android.view.SurfaceHolder holder)
This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.

Specified by:
surfaceDestroyed in interface android.view.SurfaceHolder.Callback
Overrides:
surfaceDestroyed in class android.opengl.GLSurfaceView

surfaceChanged

public void surfaceChanged(android.view.SurfaceHolder holder,
                           int format,
                           int w,
                           int h)
This method is part of the SurfaceHolder.Callback interface, and is not normally called or subclassed by clients of GLSurfaceView.

Specified by:
surfaceChanged in interface android.view.SurfaceHolder.Callback
Overrides:
surfaceChanged in class android.opengl.GLSurfaceView

onPause

public void onPause()
Inform the view that the activity is paused. The owner of this view must call this method when the activity is paused. Calling this method will pause the rendering thread. Must not be called before a renderer has been set.

Overrides:
onPause in class android.opengl.GLSurfaceView

onResume

public void onResume()
Inform the view that the activity is resumed. The owner of this view must call this method when the activity is resumed. Calling this method will recreate the OpenGL display and resume the rendering thread. Must not be called before a renderer has been set.

Overrides:
onResume in class android.opengl.GLSurfaceView

queueEvent

public void queueEvent(Runnable r)
Queue a runnable to be run on the GL rendering thread. This can be used to communicate with the Renderer on the rendering thread. Must not be called before a renderer has been set.

Overrides:
queueEvent in class android.opengl.GLSurfaceView
Parameters:
r - the runnable to be run on the GL rendering thread.


Copyright © 2013. All Rights Reserved.