Questions tagged [glsurfaceview]

GLSurfaceView is a subclass of SurfaceView for Android. It provides a dedicated surface for displaying OpenGL ES rendering.

GLSurfaceView extends SurfaceView, providing:

  • EGL context creation and management.
  • Renderer thread management.

The class is just a wrapper around SurfaceView. It's not necessary to use GLSurfaceView to render with OpenGL ES; a plain SurfaceView or TextureView will work. If you want more control over the EGL context lifetime, or better control over when rendering occurs, use one of the other classes.

For a simple example of a game written with GLSurfaceView, see Android Breakout.

Additional details about GLSurfaceView can be found in the graphics architecture document. The appendix on game loops may also be relevant, as games are one of the more common uses for GLSurfaceView. Examples of using GLES with SurfaceView and TextureView can be found in Grafika.

539 questions
5
votes
1 answer

Android and OpenGL gives black frame at startup

I'm currently writing an Android app for one my customers that has a GLSurfaceView with a GLSurfaceView.Renderer. My entire OpenGL stuff works just fine (it's basically a port of what another developer has written on iOS first). Except for one…
dirkvranckaert
  • 1,364
  • 1
  • 17
  • 30
5
votes
1 answer

GLSurfaceView in a PopupWindow

I need to add a GLSurfaceView to a FrameLayout in a PopupWindow. The problem is that, internally, the SurfaceView requests the token from the current window. PopupWindows don't have their own tokens, so I give it the token from the popup parent…
Błażej Czapp
  • 2,478
  • 2
  • 24
  • 18
4
votes
1 answer

Android GLSurfaceView

Is it possible add LinearLayout on GLSurfaceView? How to overlay LinearLayout over a GLSurfaceView? maybe GLSurfaceView is Game playground and LinearLayout is menubar~
Somyong Ri
  • 95
  • 3
  • 8
4
votes
2 answers

[Cocos2d]How to Create bitmap from GlSurfaceView

How can I take screen shot of Glsurfaceview in Cocos2d. I tried with following code using GLsurfaceView GlsurfaceView glv=CCDirector.sharedDirector().getOpenGLView(); glv.setDrawingCacheEnabled(true); Bitmap…
Dev.Sinto
  • 6,802
  • 8
  • 36
  • 54
4
votes
1 answer

How to get an EGL display/context to a specific GLSurfaceView

This is a follow up to my original Question, which was probably too broad (whereas this one is probably too specific but maybe I can apply Newton's Method). My specific situation is: OpenGL ES 2.0, on Android, using only Java (no JNI/Native…
Vanderdeckken
  • 211
  • 1
  • 3
  • 4
4
votes
0 answers

Renderer over Camera View both on same GLSurfaceView?

I am trying to use the same glsurfaceview object to show camera view & render custom openGl drawings over this camera view. But I found that if I use surface holder without renderer it's ok and when I use the renderer without holder it's ok But…
4
votes
1 answer

Seek through a video with MediaCodec and GLSurfaceView

I'm trying to implement seeking through video file with MediaCodec decoder which outputs to GLSurfaceView. The solution's based on Bigflake examples and fadden comments. It works with SurfaceView, but I'm facing some troubles using…
4
votes
2 answers

Sharing the GLES20 context and textures between different GLSurfaceViews?

Is it possible to share the GLES20 context between different GLSurfaceViews (within one Activity)? Alternatively, how would one share a set of texture between different GLSurfaceViews? On iOS, if you want to conserve memory and reuse (large)…
4
votes
1 answer

bitmap from glSurfaceView is empty

public Bitmap getBitmapFromGlSurface(int x, int y, int w, int h){ ByteBuffer buff = ByteBuffer.allocate(h * w * 4); Bitmap bitmap; try { GLES20.glReadPixels(x, y, w, h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buff); …
4
votes
1 answer

GlSurfaceView setZMediaOrder causing video to play outside its parents

Case-1: GLSurfaceView | FrameLayout | TextureView | VideoRecording So here I have a GLSurfaceView, based on user input I am adding a square FrameLayout on top of it (dimensions are set using layoutparams) and then adding TextureView on top of this…
Mohammed Atif
  • 4,383
  • 7
  • 28
  • 57
4
votes
1 answer

eglPresentationTimeANDROID(): Can I use microedition.khronos instead of android.opengl?

I want to use eglPresentationTimeANDROID in my ExtendedGLSurfaceView (extended from GLSurfaceView). The method appears in: EGLExt.eglPresentationTimeANDROID(android.opengl.EGLDisplay display, android.opengl.EGLSurface surface, long time); My main…
4
votes
1 answer

Android camera preview color issue (red and blue are swapped)

I am observing a strange visual glitch when using a GLSurfaceView to render a camera preview on Android. The reds and blues appear to be swapped in the Camera preview feed - greens seem ok. See the screen capture below. I am only seeing this…
4
votes
1 answer

Android: Crop video while recording using MediaCodec and MediaMuxer

I am trying to record the video using GLSurfaceView and audio from the AudioRecord. In MediaMuxer I am sending both audio and video data when onFrameAvailable called. I set the camera preview size of 1280 * 720 and preview on the full screen. I am…
Amit Thaper
  • 2,117
  • 4
  • 26
  • 49
4
votes
0 answers

GLSurfaceView disappear when Scroll up and scroll down again in RecyclerView

I attached my customize GLSurfaceView inside RecyclerView's Item layout. When I scroll up and scroll down again my GLSurfaceView is gone. I use Rajawali 3D engine for android OS. This is my ViewHolder in recyclerView Adapter class FieldViewHolder…
4
votes
1 answer

How can I sense if the user is holding down their finger on the screen without moving it?

I am currently using pure OpenGL to paint buttons in my own little way. I can detect if a button is pushed with onTouchEvent, but I want to know if the user is holding the button down, or if the user is no longer touching the screen.
Marcus Johansson
  • 2,626
  • 2
  • 24
  • 44