• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Open gles
 

Open gles

on

  • 1,977 views

 

Statistics

Views

Total Views
1,977
Views on SlideShare
1,977
Embed Views
0

Actions

Likes
2
Downloads
38
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Open gles Open gles Presentation Transcript

    • OpenGL & OpenGLES
    • Introduction to OpenGL
      • OpenGL (Open Graphics Library)[2] is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics.
      • The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes.
      • OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992[3] and is widely used in CAD, virtual reality, scientific visualization,information visualization, and flight simulation.
      • It is also used in video games,where it competes with Direct3D on Microsoft Windows platforms .
      • OpenGL is managed by a non-profit technology consortium, the Khronos Group.
    • Introduction to OpenGLES
      • OpenGL ES (OpenGL for Embedded Systems) is a subset of the OpenGL 3D graphics API designed for embedded devices such as mobile phones, PDAs and video game consoles.
      • It is defined and promoted by the Khronos Group,a graphics hardware and software industry consortium interested in open
      • APIs for graphics and multimedia.
    • The following APIs will provide central understanding in OpenGL & OpenGLES
      • 􀀁 glVertexPointer
      • 􀀁 glDrawElements
      • 􀀁 glColor
      • 􀀁 glClear
      • 􀀁 gluLookAt
      • 􀀁 glFrustum
      • 􀀁 glViewport
    • OpenGL ES offers two primary methods to facilitate drawing:
      • glVertexPointer: to specify a series of points or
      • vertices.
      • glDrawElements: to draw them using one of the
      • primitive shapes
      • glVertexPointer(
      • // Are we using (x,y) or (x,y,z) in each point
      • 3,
      • // each value is a float value in the buffer
      • GL10.GL_FLOAT,
      • // Between two points there is no space
      • 0,
      • // pointer to the start of the buffer
      • mFVertexBuffer );
      glVertexPointer API Definition
      • glVertexPointer takes native buffer rather than array floats.We need to convert these java-based floats into an accceptable C-like native buffer.We use Java.nio classes to convert float array into native buffer.
      • java.nio.ByteBuffer vbb =
      • java.nio.ByteBuffer.allocateDirect(3 * 3 * 4);
      • vbb.order(ByteOrder.nativeOrder());
      • java.nio.FloatBuffer mFVertexBuffer = vbb.asFloatBuffer();
    • glDrawElements API Definition
      • glDrawElements(
      • // type of shape
      • GL10.GL_TRIANGLE_STRIP,
      • // Number of indices
      • 3,
      • // How big each index is
      • GL10.GL_UNSIGNED_SHORT,
      • // buffer containing the 3 indices
      • mIndexBuffer );
    • glColor
      • We use it to set the default color for the subsequent drawing that takes place.
      • //Set the current color
      • glColor4f(1.0f, 0, 0, 0.5f);
      • Where 4f refers to 4 arguments, all are float
    • glClear
      • This method is used to erase the drawing surface. we can reset not only the color, but also the depth and the type of stencils used.
      • GL_COLOR_BUFFER_BIT,
      • GL_DEPTH_BUFFER_BIT,
      • GL_STENCIL_BUFFER_BIT .
    • Understanding OpenGL Camera and Coordinates
      • gluLookAt: Controls the direction of the camera
      • glFrustum: Controls the viewing volume or zoom
      • glViewport: Controls the size of the screen or the size of the camera’s “film”
    • Y-axis Frustrum Z-axis Point it up height 0,0,0 Near(3) Far(7)
      • gluLookAt(gl, 0,0,5, 0,0,0, 0,1,0);
      location of the camera Eye point direction the camera is pointing Look-at point whether the camera is up, down, or slanted Up vector
      • glFrustrum: to specify the area of the scene that you are interested in.The area as bounded by a box, also called the frustum or viewing volume.
      • frustrum= far point - near point
      • In OpenGL, you can imagine this box in one of two ways.
      • Prespective projection.
      • Orthographic projection.
      • Specifying a Frustum through glFrustum
      • //calculate aspect ratio first
      • float ratio = (float) w / h;
      • //indicate that we want a perspective projection
      • glMatrixMode(GL10.GL_PROJECTION);
      • //Specify the frustum: the viewing volume
      • gl.glFrustumf(
      • -ratio, // Left side of the viewing box
      • ratio, // right side of the viewing box
      • 1, // top of the viewing box
      • -1, // bottom of the viewing box
      • 3, // how far is the front of the box from the camera
      • 7 ); // how far is the back of the box from the camera
    • glViewport
      • It is responsible for specifying the rectangular area on the screen onto which the viewing volume will be projected.
      • glViewport( 0, // lower left "x" of the rectangle on
      • the screen.
      • 0 ,// lower left "y" of the rectangle on
      • the screen
      • width, // width of the rectangle on the
      • screen
      • height ); // height of the rectangle on the
      • screen
      • The other classes in the package include:
      • GLU: This utility class contains utilities that wrap the underlying OpenGL ES API in order to aggregate some common functionality.
      • GLUtils: This utility class contains Android-specific utilities that are built to make interacting with the OpenGL ES easier.
      • Matrix: This is the transformation matrix that is essential for transformations such as scaling, moving, etc.
      • Visibility: It deals with the visibility aspects of OpenGL such as what triangle meshes are visible on the screen.
      • GLDebugHelper :A static utility class that allows you to wrap the “GL”and “EGL” interfaces so that you can control logging, errors, additional checks, etc.
      • GLSurfaceView.EGLConfigChooser :An EGL tells OpenGL the type of display characteristics.
      • GLSurfaceView.GLWrapper: This interface allows you to wrap the“gl” interface so that you can intercept the OpenGL calls across the entire system.
      • GLSurfaceView.Renderer: This interface allows for derived classes to draw. It allows GLSurfaceView to call draw when the surface has changed, etc
      • public static interface GLSurfaceView.Renderer
      • {
      • void onDrawFrame(GL10 gl);
      • void onSuraceChanged(GL10 gl, int width, int height);
      • void onSurfaceCreated(GL10 gl, EGLConfig config);
      • }
      • onDrawFrame():- This is called to draw the current
      • frame.The main drawing happens
      • in this method .
      • onSurfaceCreated():- Whenever new surface is
      • created this method is called,we
      • can also call a no of OpenGL API’s
      • such as dithering or depth control.
      • onSurfaceChanged():- Whenever surface changes such
      • as width height of the window
      • this method is called.
      • Thank You