Download presentation
Presentation is loading. Please wait.
Published byJayson Goodwin Modified over 9 years ago
1
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. Lecture 8 - OpenGL on Android
2
Laura Gheorghe, Petre Eftime OpenGL ES Cut down version of OpenGL Fixed point support Found in many mobile platforms (Android, iOS, Blackberry, Symbian, 3DS, etc.) Designed for slower GPUs and CPUs 2
3
Laura Gheorghe, Petre Eftime Version 1.x 3 OpenGL ES 1.0 based on OpenGL 1.3 and OpenGL ES 1.1 based on OpenGL 1.5 Common and Common-Lite (only fixed point) profile Fixed-function rendering pipeline Reduced features: no quad and polygon primitives, no stippling, only multisample AA, reduced drawing modes, no display lists, etc. OpenGL ES 1.1 adds better multitexture support, VBOs, clip planes, mipmap generation Android 1.0 and higher
4
Laura Gheorghe, Petre Eftime Version 2.0 4 Based on OpenGL 2.0, but reduced fixed-function pipeline support Not compatible with OpenGL ES 1.x OpenGL ES Shading Language ESSL only has forward branches and fixed iteration loops Transforming and Lighting functions replaced by shaders Better performance than OpenGL ES 1.x in many cases Android 2.2 and higher
5
Laura Gheorghe, Petre Eftime Version 3.0 5 Compatible with OpenGL ES 2.0 and OpenGL 4.3 Standardized texture compression Better texturing support New Shading Language version with full support for integer and floating point Improved flow control Easier portability Android 4.3 and higher
6
Laura Gheorghe, Petre Eftime GL Surface 6 Manages a surface (a region of memory which can be displayed on screen) Manages an EGL display (an OpenGL rendering context) Dedicated rendering thread Can provide debug information
7
Laura Gheorghe, Petre Eftime EGL 7 Virtual display which contains a rendering context 2D and 3D rendering Allows having multiple smaller surfaces on the actual screen or drawing to offscreen buffer Used by SurfaceFlinger and other compositors (Wayland, Mir) or libraries (SDL)
8
Laura Gheorghe, Petre Eftime Demo 8 Create GL2JNIView and set it as a view for the activity Constructor initializes the view private void init(boolean translucent, int depth, int stencil) { setEGLContextFactory(new ContextFactory()); setEGLConfigChooser( translucent ? new ConfigChooser(8, 8, 8, 8, depth, stencil) : new ConfigChooser(5, 6, 5, 0, depth, stencil) ); setRenderer(new Renderer()); }
9
Laura Gheorghe, Petre Eftime Demo 9 public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { /* Get the number of minimally matching EGL configurations */ int[] num_config = new int[1]; egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config); int numConfigs = num_config[0]; /* Allocate then read the array of minimally matching EGL configs */ EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config); /* Now return the "best" one (matches rgba specifications) */ return chooseConfig(egl, display, configs); }
10
Laura Gheorghe, Petre Eftime Demo 10 private static class Renderer implements GLSurfaceView.Renderer { public void onDrawFrame(GL10 gl) { GL2JNILib.step(); } public void onSurfaceChanged(GL10 gl, int width, int height) { GL2JNILib.init(width, height); } public void onSurfaceCreated(GL10 gl, EGLConfig config) { // Do nothing. }
11
Laura Gheorghe, Petre Eftime Demo 11 setupGraphics Compiles vertex and pixel shaders into a program Defines Uniforms, Attributes, etc. Sets initial camera position and viewport
12
Laura Gheorghe, Petre Eftime Demo 12 renderFrame Updates camera Sets shader program Sets Uniforms and Attributes for current frame Draws triangles
13
Laura Gheorghe, Petre Eftime Android Tools for Debugging and Profiling 13 Logging Debugging Developer Options: Overdraw, Clipping Profiling Developer Options: Performance metrics on screen or through ADB, Traces Tracer for OpenGL ES: Visualize traces
14
Laura Gheorghe, Petre Eftime Intel GPA 14 Intel Atom processors More information: GPU, CPU, Battery usage More detailed analysis Identifies possible bottlenecks Realtime Works over Wifi
15
Laura Gheorghe, Petre Eftime Vendor specific tools 15 Low level information Different interface and capabilities for each vendor Optimizations not always portable PowerVR, Tegra, Adreno, etc.
16
Laura Gheorghe, Petre Eftime Bibliography 16 https://www.khronos.org/opengles/ http://developer.android.com/guide/topics/graphics/ope ngl.html http://developer.android.com/training/graphics/opengl/i ndex.html
17
Laura Gheorghe, Petre Eftime Keywords 17 OpenGL EGL Fixed function pipeline Shaders GLSurfaceView Profiling Tracer
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.