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
6
votes
1 answer

GLSurfaceView displaying black on Nexus 7 with Android 4.2

I have an OpenGL ES2.0 app that is working on devices running various Android versions from 2.2 up to 4.1. However I have been told that when running it on a Nexus 7 with Android 4.2 the 3D graphics in the App are all black. The Action Bar and…
6
votes
1 answer

GLSurfaceView onDrawFrame clearing behavior

I ran into different behaviors with the GLSurfaceView. AFAIK it is the responsibility of the program to clear the buffer (color and depth ) each frame. Which means that if I don't clear the buffer I get the content of the last frame ( or the one…
P.Melch
  • 8,066
  • 43
  • 40
6
votes
1 answer

How to add GLSurfaceView between Android Views?

I'm working on a special UI in Android -Sandwich type, a small GalleryView on GLSurfaceView(with transparent areas) on top of background View (LinearLayout+some widgets). This is how I'm thinking of setting it up: TOP…
prot0n
  • 193
  • 9
6
votes
1 answer

GLSurfaceView lifecycle methods onPause() and onResume()

I'm trying to correctly play with OpenGL in my application and having a few problems when it comes to using the Lifecycle Methods: onPause() and onResume(). The documentation states: Activity Life-cycle A GLSurfaceView must be notified when the…
Graeme
  • 25,714
  • 24
  • 124
  • 186
6
votes
1 answer

Determining Max/Min Texture Size Limit in Android OpenGLES

I've been assigned to create an open source Java port of this Objective C GPUImage Framework so that it can be used in an Android application. I am to recreate it as closely as I can, with all the variable names, function names, etc all the same. …
Synergy807
  • 523
  • 2
  • 6
  • 18
5
votes
2 answers

Sharing the EGL2.0 context between 2 GLSurfaceViews caused EGL_BAD_ACCESS on Android tablets

I try to share EGL context bwteen 2 GLSurfaceViews by following code: createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { EGLContext shared = ...; // a cached egl context int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2,…
5
votes
1 answer

glReadPixels too slow to use

I am using glReadPixels to take a snapshot at regular intervals in drawFrame method of GLSurfaceView.Renderer. I need to take this snapshot at regular intervals to keep saving my data as per my app requirements. However glReadPixels performance is…
random
  • 10,238
  • 8
  • 57
  • 101
5
votes
2 answers

Android: GLSurfaceView is black after resuming app

As per the title, the GLSurfaceView is blank after resuming from a paused state. The Renderer's onSurfaceCreated, onSurfaceChanged, and onDrawFrame get called after it resumes, but the screen is still blank! Here's the relevant…
confusedKid
  • 3,231
  • 6
  • 30
  • 49
5
votes
0 answers

Limiting refresh rate at 60 FPS of SurfaceView on new Android devices with high refresh rates (90-120Hz)

I'm facing increased and even doubled FPS on new Android devices with 90Hz and 120Hz screens (e.g. Samsung S20 FE), it affects my game, which I've developed based on GLSurfaceView (OpenGL implementation of SurfaceView). Originally it was always…
Sergey Emeliyanov
  • 5,158
  • 6
  • 29
  • 52
5
votes
4 answers

GLSurfaceView.Renderer possible to swap buffers multiple times in onDrawFrame()?

In my openGL game, I draw my scene normally using a GLSurfaceView.Renderer class in the onDrawFrame(). However, when I am displaying a loading screen I would like to force the screen to draw after each item of data is loaded so the loading bar can…
DJPJ
  • 319
  • 1
  • 4
  • 13
5
votes
1 answer

How to identify click inside the 3D object or outside 3D object using near and far positions

I am working in 3D object rendering using OpenGLES 2.0 with Android,Java code.How to identify click inside the 3D object or outside 3D object using following code near and far positions? public static PointF screenToWorld(float[] viewMatrix, …
Ramprasad
  • 7,981
  • 20
  • 74
  • 135
5
votes
1 answer

How to paint on walls in Camera View android?

I am trying to paint a wall in my Camera View. Can Anyone tell me where should I start, Any library or something helpful that can point me in right direction. I know its a difficult thing to do but I need some direction to continue my work.…
5
votes
4 answers

Android GLSurfaceView with drawable background

I have a GLSurfaceView with a drawable as background, however only the background is visible when rendered without surfaceView.setZOrderOnTop(true) I need to avoid using setZOrderOnTop(true) because there are static TextView's being used on top of…
Jlam
  • 1,932
  • 1
  • 21
  • 26
5
votes
0 answers

How to get YUV from the decode output of MediaCodec and draw it on GLSurfaceView?

I'm need to play a video stream using GLSurfaceView. And I tried to get the outputs and render them. But the color is not correct. I dump the outputbuffer to file and open it with yuv viewer, the color is not correct too. So I doubt that I use the…
mqstack
  • 51
  • 3
5
votes
0 answers

Keep receiving eglMakeCurrent failed EGL_BAD_ALLOC report when we are not using GLSurface at all

My app's keep getting crash report on Android 4.4.x devices, samsung, xiaomi: java.lang.IllegalStateException: eglMakeCurrent failed EGL_BAD_ALLOC at android.view.HardwareRenderer$GlRenderer.createSurface(HardwareRenderer.java:1354) at…
Felix.D
  • 724
  • 6
  • 17