Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OpenGL ES

OpenGL ES

Orhan Obut

March 13, 2014
Tweet

More Decks by Orhan Obut

Other Decks in Programming

Transcript

  1. About • What is openGL? • Where it came from?

    Competitors? • Where and Why?
  2. What is OpenGL? OpenGL is a powerful, low-level rendering and

    modelling software library and it is used a lot today in computer languages. OpenGL is the closest point between the CPU and the GPU and API is language free.
  3. Where it came from? Competitors? OpenGL was developed by Silicon

    Graphics Inc. (SGI) from 1991 and released in January 1992 and is widely used in CAD, virtual reality, scientific visualization, information visualization, flight simulation, and video games. OpenGL is managed by the non-profit technology consortium Khronos Group. Microsoft DirectX
  4. Where and Why? • More control of what your application

    draws on screen. • Three dimensional graphics. • OpenGL lets all the mass computations to the GPU. Gpu is much faster on float calculations than CPU.
  5. Basics • Difference between OpenGL and OpenGL ES • Pipeline

    • Primitives • Buffers • Rasterize • Shaders • Matrices • Error API • EGL Api
  6. Difference between OpenGL and OpenGL ES • OpenGL ES (Embedded

    Systems) strips down and then extends OpenGL APIs to make it suitable for a mobile platform. • ES is a subset of OpenGL, thus all ES application can work on non ES systems but not the opposite.
  7. Difference between OpenGL ES 1.0 and OpenGL ES 2.0 OpenGL

    ES 1.0 uses a fixed pipeline, you use built-in functions to set lights, vertexes, colors, cameras, and more. OpenGL ES 2.0 uses a programmable pipeline, all those built-in functions go away, and you have to write everything yourself.
  8. Primitives Vertex : 3D Point in space (x,y,z) Line: 3D

    Line in space (composed by two vertices) Triangle: 3D Triangle in space (composed by three vertices)
  9. Buffers Buffer is a temporary optimized storage and it stores

    everything about what to draw. • Render Buffer • Frame Buffer
  10. Render Buffer Render buffer is a temporary storage of one

    single image. • Color Render Buffer • Depth Render Buffer • Stencil Render Buffer
  11. Color Render Buffer Stores the final colored image generated by

    OpenGL's render. Color Render Buffer is a colored (RGB) image.
  12. Depth Render Buffer Stores the final Z depth information of

    the objects. It's a grey scale image about the Z position of the objects in 3D space, in which the full white represent most near visible object and black represent the most far object (the full black is invisible)
  13. Stencil Render Buffer Stores the only visible part of the

    object. Like a mask of the visible parts. Stencil Render Buffer is a black and white image.
  14. Frame Buffer A Framebuffer is a collection of buffers that

    can be used as the destination for rendering. OpenGL has two kinds of framebuffers: 1. Default Framebuffer, which is provided by the OpenGL Context. The buffers for default framebuffers are part of the context and usually represent a window or display device 2. Framebuffer Objects (FBOs) called User-created framebuffers. The buffers for FBOs reference images from either Textures or Renderbuffers; they are never directly visible.
  15. Rasterize The rasterizer takes each triangle, clips it and discards

    parts that are outside of the screen, and breaks the remaining visible parts into pixel-sized fragments.
  16. Vertex Shader (VSH) The Vertex Shader is the programmable Shader

    stage in the rendering pipeline that handles the processing of individual vertices. Vertex shader is done on every vertex. Vertex shader can manipulate the attributes of vertices.
  17. Geometry Shader Geometry shader invocations take a single Primitive as

    input and may output zero or more primitives. A geometry shader is optional and does not have to be used.
  18. Program VSH and FSH works together and it’s mandatory to

    one VSH to one FSH, no more no less. A Program in OpenGL is just the compiled pair of VSH and FSH. P = VSH + FSH
  19. Shading Language (GLSL) It is a high-level shading language based

    on the syntax of the C programming language. It was created by the OpenGL ARB (OpenGL Architecture Review Board) to give developers more direct control of the graphics pipeline without having to use ARB assembly language or hardware-specific languages.
  20. GLSL Uniform: Constant data per draw call, usually used to

    parametrize shaders.(Readonly) Varying: Transfers data between the VSH and the FSH, interpolating along the primitive in the process. Attribute: This is vertex attribute data, the input of the Vertex Shader. It's specified for each vertex in the primitive.
  21. Vertex shader sample uniform mat4 uMVPMatrix; attribute vec4 vPosition; void

    main () { gl_Position = uMVPMatrix * vPosition; }
  22. Model Matrix The matrix M, that contains every translations, rotations

    or scaling, applied to an object is named the model matrix in OpenGL. M = R x S x T Basically, instead of sending down the OpenGL pipeline two, or more, geometrical transformation matrices we’ll send a single matrix for efficiency.
  23. View Matrix The view matrix is functionally equivalent to a

    camera. It does the same thing as a model matrix, but it applies the same transformations equally to every object in the scene. Moving the whole world 5 units towards us is the same as if we had walked 5 units forwards.
  24. Projection Matrix Projection matrix called as perspective matrix is used

    to determine object size. Closer objects should look bigger than farther objects in Z Axis.
  25. OpenGL Coordinate System OpenGL doesn’t really know anything about your

    coordinate space or about the matrices that you’re using. OpenGL only requires that when all of your transformations are done, things should be in normalized device coordinates. These coordinates range from -1 to +1 on each axis, regardless of the shape or size of the actual screen. The bottom left corner will be at (-1, -1), and the top right corner will be at (1, 1). Normalized devices use left-handed coordinate system.
  26. Error API OpenGL is a State Machine working as a

    Port Crane and you don't have access to what happen inside it. So if an error occurs inside it, nothing will happens with your application, because OpenGL is a completely extern core.
  27. EGL EGL is an interface between Khronos rendering APIs (such

    as OpenGL, OpenGL ES or OpenVG) and the underlying native platform windowing system. A windowing system (or window system) is a type of graphical user interface (GUI) which implements the WIMP (windows, icons, menus, pointer) paradigm for a user interface.
  28. EGL in Android Native graphics management from Gingerbread The platform

    provides an interface to its Khronos EGL library, which lets applications manage graphics contexts and create and manage OpenGL ES textures and surfaces from native code.
  29. OpenGL in Android • Who uses OpenGL • Frameworks •

    Environment setup in android • Sample • Sample with textures
  30. OpenGL vs Canvas SDK Canvas API: If you're writing a

    normal GUI application, using the SDK and the Canvas API is probably the most sensible option. If you need custom 2D graphics, there is plenty of power and reasonable performance in the Canvas API. SDK OpenGL Wrappers: If you are writing an SDK application and want to sprinkle in some 3D effects with OpenGL, you could see whether the OpenGL wrapper functions suit your needs.
  31. OpenGL ES in Android • AndroidManifest • How to set

    it to Activity • GLSurfaceView • Renderer • GL10 Params • Sample • Sample with Texture