Tuesday, July 19, 2016

Android OpenGL Tutorials

Android OpenGL Tutorials

This is the official Google Android documentation
https://developer.android.com/training/graphics/opengl/index.html

pdf all about opengl es
http://www.pdfdrive.net/all-about-opengl-es-2-e560764.html

Anton tutorial $9.50 kindle book
https://www.amazon.com/Antons-OpenGL-Tutorials-Anton-Gerdelan-ebook/dp/B00LAMQYF2/ref=sr_1_1?s=books&ie=UTF8&qid=1470839771&sr=1-1&keywords=opengl


http://www.pdfdrive.net/opengl-es-302-april-8-2013-khronos-group-e10597635.html


https://software.intel.com/en-us/android/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-2
The OpenGL ES 1.1 application programming interface (API) is a subset of the OpenGL 1.x APIs that have been used on desktop Linux* and Windows* systems for decades. Likewise, the OpenGL ES 2.0 API is a subset of the OpenGL 2.0 API from desktop systems. Therefore, any game porting project should start with an assessment of the OpenGL feature set that the game’s code uses to determine the age of the code and identify the parts that you must rewrite because of differences between the OpenGL version used and the OpenGL ES version targeted on Android.
The major differences between OpenGL 2.0 and OpenGL ES 2.0 fall into three main categories: geometry specification, geometry transformation, and changes in the OpenGL Shading Language (GLSL). OpenGL 2.0 offers four ways to specify geometry: immediate mode, display lists, vertex arrays, and vertex buffer objects. OpenGL ES 2.0 does not support immediate mode (glBegin and glEnd blocks) or display lists, so you must specify geometry with either vertex arrays or vertex buffer objects.
OpenGL 2.0 has functions for loading the model view, projection, and texture matrices plus some convenience functions for combining these matrices, such aglTranslateglRotate, and glScale. OpenGL ES 2.0 has neither these functions nor any of the lighting-related functions because the fixed-function pipeline has been replaced with the shader programming model. For OpenGL ES 2.0, matrix and lighting calculations should be made in the vertex shader.
The shader language for OpenGL ES 2.0 (GLSL ES) is also a subset of the shader language for desktop OpenGL 2.0 (GLSL). One major difference is that GLSL has built-in variables to access states in the fixed-function pipeline in the vertex shader (such as gl_ModelViewMatrix). Because OpenGL ES 2.0 does not support the fixed-function pipeline, these variables are not supported in GLSL ES.
The following OpenGL 2.0 features are lacking in OpenGL ES 2.0:
  • Immediate mode geometry specification
  • Display list geometry specification
  • All fixed-function pipeline processing
  • Fixed transformation and lighting
  • Matrix stack and matrix transformations
  • User clip planes
  • Line and polygon smoothing and stipple
  • Pixel rectangles and bitmaps
  • One-dimensional textures and some texture wrap modes
  • Occlusion queries
  • Fog

The GLU Library

Desktop versions of OpenGL typically provide a library of convenience functions called the OpenGL Utility Library. The GLU consists of functions that are not strictly part of OpenGL or essential for using OpenGL but are helpful when coding 3D applications for OpenGL. A typical GLU library includes functions for constructing model-view and projection matrices, performing general matrix calculations, computing quadric surfaces, tessellating polygons, generating mipmaps, and reporting error messages. Most games on desktop OpenGL use some GLU functions, which can be a problem because Android provides only a minimal implementation of GLU that is available only from the SDK. These classes are listed in Table 2.
Table 2. Summary of Android Classes That Provide GLU Functionality
ClassFunctionality
android.opengl.GLUCreating projection matrices for OpenGL ES
android.graphics.MatrixCreating model–view and general matrices
OpenGL ES 1.1 and 2.0 provide support for generating mipmaps, so the missing functionality is computing quadric surfaces and support for tessellating polygons. If you need these functions, other open source implementations of GLU exist that are more complete and suitable for use with the Android NDK—for example, GLU ES.


GLU 1.3 port for OpenGL ES 1.0 (CM) and above

GLU ES

GLU 1.3 partitial port (libutil and libtess components only) for OpenGL ES 1.x (CM - Common profile) and above. This port supports:

  • Quadrics: gluNewQuadric(), gluDeleteQuadric(), gluQuadricCallback(), gluQuadricNormals(), gluQuadricTexture(), gluQuadricOrientation(), gluQuadricDrawStyle(), gluCylinder(), gluDisk(), gluPartialDisk(), gluSphere().
  • Registry: gluGetString(), gluCheckExtension(), gluErrorString().
  • Projection matrix manipulation: gluOrtho2D(), gluPerspective(), gluLookAt(), gluProject(), gluUnProject(), gluUnProject4(), gluPickMatrix().
  • 2D Mipmaps: gluScaleImage(), gluBuild2DMipmapLevels(), gluBuild2DMipmaps().
  • Tesselation: gluBeginPolygon(), gluDeleteTess(), gluEndPolygon(), gluGetTessProperty(), gluNewTess(), gluNextContour(), gluTessBeginContour(), gluTessBeginPolygon(), gluTessCallback(), gluTessEndContour(), gluTessEndPolygon(), gluTessNormal(), gluTessProperty(), gluTessVertex().
https://maniacdev.com/2009/12/iphone-opengles-animation-tutorial
Here’s some other OpenGL ES Tutorials, and my list of iPhone OpenGL ES resources.

https://maniacdev.com/2009/04/converting-opengl-code-to-iphone-opengl-es
One of the major problems I found was that the Glu library is missing in OpenGL ES, fortunately Michael Gorchak has begun work on a GluES librarywhich includes much of the missing funcitonality also in the Cocos2D frameworkyou can find implementations of gluLookAt and gluPerspective functions in the Glu module.


http://www.cs.utah.edu/gdc/projects/alpha1/help/man/html/model_repo/model_teapot/model_teapot.html
Teapot Subdivision byRuss Fish (standing Martin Newell's and Hank Driskill's shoulders)
The original model was passed from researcher to researcher for many years, since design systems that produced good curved surface models were extremely rare in those days, and it made a good benchmark for rendering methods. Frank Crow posted the original Teapot Bezier patch control points to the Net, perhaps sometime around 1986.

The original teapot model had a few problems:  It was very visibly NOT a solid model.

Minor visible parts were left out. There was no bottom to the teapot, nor a rim for the lid to rest on. You could see in through the bottom, or past the edge of the lid, to see that there was no inside, either.

The intersection between the spout and the body of the teapot was left implicit. The spout was modeled to simply penetrate through the body surface, so the hidden-surface portion of the image rendering method covered up the portion of the spout which was inside the body.

It was not round. It was pretty close (within 1% or so), so perhaps this is a quibble. A wheel-thrown teapot would be round, but a moulded teapot like the real one of Martin's which the model represents need not be round. However, the very slightly four-lobed cross-sectional shape of the teapot was as close as a cubic Bezier curve could come to representing a circular cross section, reflecting the inability of non-rational Bezier curves to represent conic sections such as circles.

In 1992, Hank Driskill got the idea to make a modern trimmed-NURBS solid model of the Utah Teapot. This was featured (with the addition of warp nacelles) on his SigGraph Tee-Shirt Contest winning "Utah, the Next Generation" tee-shirts.

http://cs.lmu.edu/~ray/notes/openglexamples/

https://www3.ntu.edu.sg/home/ehchua/programming/android/Android_3D.html

https://www.khronos.org/assets/uploads/books/openglr_es_20_programming_guide_sample.pdf

Transformations in OpenGL Transformations in OpenGL

https://www.cs.cmu.edu/afs/cs/.../lec03a.pdf

Carnegie Mellon University
Some sample code. Display(){ … glMatrixMode(GL_MODELVIEW);. glLoadIdentity();. glTranslatef(0.0, 0.0, -6.0);. glRotatef(45.0, 0.0, 0.0);. glScalef(2.0, 2.0, 2.0);.

CUNY

In this document Create an Activity with GLSurfaceView Draw a Shape on GLSurfaceView Define a Triangle Draw the Triangle Apply Projection and Camera Views Add Motion Respond to Touch Events Related Samples API Demos - graphics OpenGL ES 1.0 Sample TouchRotateActivity See also 3D with OpenGL OpenGL ES 2.0 Tutorials: O


http://www.programforandroid.com/android-programming-tutorials/opengl-es-2-0/

OpenGL ES 2.0


This tutorial shows you how to create a simple Android application that uses the OpenGL ES 2.0 API to perform some basic graphics operations. You’ll learn how to:
  • Create an activity using GLSurfaceView and GLSurfaceView.Renderer
  • Create and draw a graphic object
  • Define a projection to correct for screen geometry
  • Define a camera view
  • Rotate a graphic object
  • Make graphics touch interactive
The Android framework supports both the OpenGL ES 1.0/1.1 and OpenGL ES 2.0 APIs. You should carefully consider which version of the OpenGL ES API (1.0/1.1 or 2.0) is most appropriate for your needs. For more information, see Choosing an OpenGL API Version. If you would prefer to use OpenGL ES 1.0, see the OpenGL ES 1.0 tutorial.
Before you start, you should understand how to create a basic Android application. If you do not know how to create an app, follow the Hello World Tutorial to familiarize yourself with the process.
Caution: OpenGL ES 2.0 is currently not supported by the Android Emulator. You must have a physical test device running Android 2.2 (API Level 8) or higher in order to run and test the example code in this tutorial.