SlideShare a Scribd company logo
1 of 33
Download to read offline
Getting Started with
   Open GL ES
Vertex
• A point in 3D space
   •x
   •y
   •z
Coordinates
Setting position
      via GLfloat
GLfloat vertex[3];
vertex[0] = 20.0     //x
vertex[1] = 23.0     //y
vertex[2] = 15.75     //z
Vertex Array
• A block of vertex data (vertex
  coordinates, texture coordinates, etc) for
  some or all objects.
• size determined by number of vertices
  submitted x 3 for 3d objects (or 2 for 2d
  objects)
 • vertex array of 6 triangles =
    6 x 3 x 3 = 54
Data structure to
    hold vertex
typedef struct {
GLfloat x;
GLfloat y;
GLfloat z
} vertex3D;
Using Vertex3D

Vertex3D vertex;
vertex.x = 20.0
vertex.y = 23.0
vertex.z = 15.75
Blank OpenGL
          Template

• Jeff Lamarche’s Template
 • http://iphonedevelopment.blogspot.com/
    2008/12/updated-opengl-es-xcode-
    project.html
creating vertices

static inline Vertex3D Vertex3DMake(CGFloat inX,
CGFloat inY, CGFloat inZ)
{
Vertex3D ret;
ret.x = inX;
ret.y = inY
ret.z = inZ
return ret;
Distance
     between vertices
static inline GLfloat
Vertex3DCalculateDistanceBetweenVertices(Vertex3D
first, Vertex3D second)
{
GLfloat deltaX = second.x - first.x;
GLfloat deltaY = second.y - first.y;
GLfloat deltaZ = second.z - first.x;
return sqrtf(deltaX*deltaX + deltaY * deltaY + deltaZ
*deltaZ);
Triangles

A triangle is the same as an array of 9 GLfloats

typedef struct
{
Vertex 3D v1;
Vertex 3D v2;
Vertex 3D v3
} Triangle3D;
Triangles Terminology
• front face - face the viewer sees of an
  object
• winding - order in which vertices are drawn
    matters for mechanics of which direction
    an object faces
•   backface - side that is not drawn
•   backface culling - process to determine
    which triangles are visible ot the user
Viewports
• Portion of viewable space that can be seen
  by viewer
• Perspective Viewport- Converging lines and
  items change size based on distance
• Orthogonal Viewport - No converging lines
  and changes in size to communicate
  distance
GLOrthof()
CGRect rect = view.bounds;
glOrthof(-1.0,
          1.0,
         -1.0 / rect.size.width / rect.size.height),
         -1.0 / rect.size.width / rect.size.height),
         0.01,
         1000.0,
      glViewport(0, 0, rect.size.width,
      rect.size.height);
Perspective

• Frustum - the shape of our space we see.
  Not cubic.
• Field of Vision - angles used to calculate our
  frustum
GLFrustumf()
CGRect rect = view.bounds;
glfloat size = .01 * tanf(DEGREES_TO_RADIANS(45.0)/
2.0);
glFrustumf(-size,
          size,
          -size / rect.size.width /rect.size.height),
          size / rect.size.width / rect.size.height),
         0.01,
         1000.0);
Lights

• You can have up to 8 lights
• must be enabled using
• glEnable(GL_LIGHT0);
• Specify properties of light
Components
           of Light

• Ambient - No clear source.
• Diffuse - even directional light on side of
  object that faces light
• specular - highlight or hotspot
Ambient

const GLfloat light0Ambient[] = {0.05, 0.05,
0.05, 0.05, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT,
light0Ambient);
Diffuse

const GLfloat light0Diffuse[] = {0.5, 0.5, 0.5,
0.5, 1.0};
glLightfv(GL_LIGHT0, GL_DIFFUSE,
light0Diffuse);
Specular


const GLfloat light0Specular[] = {0.7, 0.7, 0.7,
1.0};
Light Position


const GLfloat light0Position[] = {20.0, 20.0, 20.0,
1.0};

// light will be behind viewer20 units up and right
Directional light


const GLfloat light0Direction[] = {0.0, 0.0, -1.0};

glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION,
light0Direction);
Light Angle


glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45);

// sets light angle to 90 degrees
Color

• Defined as the color of light that an object
  reflects.
• OpenGL allows us to specify color for each
  component of light(specular, diffuse &
  ambient) to material.
Color on
              Material
GLfloat ambientAndDiffuse[] = {0.0, 0.1, 0.9, 1.0};

glMaterialfv(GL_FRONT_AND_BACK,
GL_AMBIENT_AND_DIFFUSE, ambientAndDiffuse);

//OpenGL ES only supports applying material to
FRONT_AND_BACK
Colors on different
 components of light
GLfloat ambient[] = {0.0, 0.1, 0.9, 1.0};

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);

GLfloat diffuse[] = {0.0, 0.1, 0.9, 1.0};

glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
Shininess on
            Specular
GLfloat specular[] = {0.3, 0.3, 0.3, 1.0};

glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
specular);

glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 25.0);

//tighter hotspot with shininess at 25 than default
50.
Emission

//giving and object a glow

GLfloat emission[] = {0.0, 0.4, 0.0, 1.0};

glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION,
emission);
Resources
•   http://www.khronos.org/opengles/1_X/

•   http://iphonedevelopment.blogspot.com/2009/05/
    opengl-es-from-ground-up-table-of.html

•   http://maniacdev.com/2009/07/16-killer-opengl-es-
    resources/

•   http://web.me.com/smaurice/AppleCoder/
    iPhone_OpenGL/iPhone_OpenGL.html
OpenGL ES 2.0
        Resources

• Updated for iPhone - http://opengles-
  book.com/

• Shader Language - http://www.khronos.org/
  files/opengles_shading_language.pdf
Gaming Engines

• http://code.google.com/p/cocos2d-iphone/
• http://sio2interactive.com/
• http://www.oolongengine.com/
Thank you
• A special thanks to Jeff Lamarche who’s
    series on Open GL ES from the ground up
    served as a major resources for this
    presentation and who’s openGL template I
    used in several examples. I highly
    recommend that you check out the series
    at:
•   http://iphonedevelopment.blogspot.com/2009/05/
    opengl-es-from-ground-up-table-of.html

More Related Content

What's hot (20)

Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
Open gl
Open glOpen gl
Open gl
 
OpenVG 1.1 Reference Card
OpenVG 1.1 Reference Card OpenVG 1.1 Reference Card
OpenVG 1.1 Reference Card
 
EGL 1.4 Reference Card
EGL 1.4 Reference CardEGL 1.4 Reference Card
EGL 1.4 Reference Card
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
Lecture 6 introduction to open gl and glut
Lecture 6   introduction to open gl and glutLecture 6   introduction to open gl and glut
Lecture 6 introduction to open gl and glut
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
Grafika komputer 2
Grafika komputer 2Grafika komputer 2
Grafika komputer 2
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
OpenGL L03-Utilities
OpenGL L03-UtilitiesOpenGL L03-Utilities
OpenGL L03-Utilities
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
OpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick ReferenceOpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick Reference
 
OpenGL 4.6 Reference Guide
OpenGL 4.6 Reference GuideOpenGL 4.6 Reference Guide
OpenGL 4.6 Reference Guide
 
Instancing
InstancingInstancing
Instancing
 
Open gl
Open glOpen gl
Open gl
 
OpenGL 4.5 Reference Card
OpenGL 4.5 Reference CardOpenGL 4.5 Reference Card
OpenGL 4.5 Reference Card
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
 
GPGPU Programming @DroidconNL 2012 by Alten
GPGPU Programming @DroidconNL 2012 by AltenGPGPU Programming @DroidconNL 2012 by Alten
GPGPU Programming @DroidconNL 2012 by Alten
 

Viewers also liked

Estudio rse medios impresos en panama 2013
Estudio rse medios impresos en panama 2013Estudio rse medios impresos en panama 2013
Estudio rse medios impresos en panama 2013UDELAS
 
Simon Rickett - The power of email marketing
Simon Rickett - The power of email marketingSimon Rickett - The power of email marketing
Simon Rickett - The power of email marketingSimon Rickett
 
252 santo, santo es tu senhor
252   santo, santo es tu senhor252   santo, santo es tu senhor
252 santo, santo es tu senhorSUSSURRO DE AMOR
 
INSETA Article - Page 10
INSETA Article - Page 10INSETA Article - Page 10
INSETA Article - Page 10Cathrine Pitsi
 
HSMA Event Industriestandards im RFP Prozess
HSMA Event Industriestandards im RFP ProzessHSMA Event Industriestandards im RFP Prozess
HSMA Event Industriestandards im RFP ProzessAnsgar Jahns
 
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, OehmichenJFS 2011 - Top 10 der Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, OehmichenOdilo Oehmichen
 
Ilm library techniques with tivoli storage and ibm total storage products sg2...
Ilm library techniques with tivoli storage and ibm total storage products sg2...Ilm library techniques with tivoli storage and ibm total storage products sg2...
Ilm library techniques with tivoli storage and ibm total storage products sg2...Banking at Ho Chi Minh city
 
Informazione locale e comunità. La sfida glocal
Informazione locale e comunità. La sfida glocalInformazione locale e comunità. La sfida glocal
Informazione locale e comunità. La sfida glocalLorenzo Fabbri
 
Intervenciones alimentario nutricionales cesfam garin
Intervenciones alimentario nutricionales cesfam garinIntervenciones alimentario nutricionales cesfam garin
Intervenciones alimentario nutricionales cesfam garinCesfamgarin
 
Cuadros favoritos de 2º ESO. I.E.S. Alhakén II
Cuadros favoritos de 2º ESO. I.E.S. Alhakén IICuadros favoritos de 2º ESO. I.E.S. Alhakén II
Cuadros favoritos de 2º ESO. I.E.S. Alhakén IICórdoba, Spain
 
WCPT in 2016: European Region conference, Limassol April 2016
WCPT in 2016:  European Region conference, Limassol April 2016WCPT in 2016:  European Region conference, Limassol April 2016
WCPT in 2016: European Region conference, Limassol April 2016WCPT1951
 
Présentation1 sable bitumineux
Présentation1 sable bitumineux Présentation1 sable bitumineux
Présentation1 sable bitumineux nizou123
 

Viewers also liked (20)

Estudio rse medios impresos en panama 2013
Estudio rse medios impresos en panama 2013Estudio rse medios impresos en panama 2013
Estudio rse medios impresos en panama 2013
 
Lassen DMC
Lassen DMCLassen DMC
Lassen DMC
 
Simon Rickett - The power of email marketing
Simon Rickett - The power of email marketingSimon Rickett - The power of email marketing
Simon Rickett - The power of email marketing
 
252 santo, santo es tu senhor
252   santo, santo es tu senhor252   santo, santo es tu senhor
252 santo, santo es tu senhor
 
Presentación ABI
Presentación ABIPresentación ABI
Presentación ABI
 
INSETA Article - Page 10
INSETA Article - Page 10INSETA Article - Page 10
INSETA Article - Page 10
 
HSMA Event Industriestandards im RFP Prozess
HSMA Event Industriestandards im RFP ProzessHSMA Event Industriestandards im RFP Prozess
HSMA Event Industriestandards im RFP Prozess
 
Piccolandy1
Piccolandy1Piccolandy1
Piccolandy1
 
Securitytools
SecuritytoolsSecuritytools
Securitytools
 
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, OehmichenJFS 2011 - Top 10 der Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 der Tools & Methoden - Baumgartner, Oehmichen
 
Ilm library techniques with tivoli storage and ibm total storage products sg2...
Ilm library techniques with tivoli storage and ibm total storage products sg2...Ilm library techniques with tivoli storage and ibm total storage products sg2...
Ilm library techniques with tivoli storage and ibm total storage products sg2...
 
Informazione locale e comunità. La sfida glocal
Informazione locale e comunità. La sfida glocalInformazione locale e comunità. La sfida glocal
Informazione locale e comunità. La sfida glocal
 
Que es la tentacion
Que es la tentacionQue es la tentacion
Que es la tentacion
 
Intervenciones alimentario nutricionales cesfam garin
Intervenciones alimentario nutricionales cesfam garinIntervenciones alimentario nutricionales cesfam garin
Intervenciones alimentario nutricionales cesfam garin
 
Cuadros favoritos de 2º ESO. I.E.S. Alhakén II
Cuadros favoritos de 2º ESO. I.E.S. Alhakén IICuadros favoritos de 2º ESO. I.E.S. Alhakén II
Cuadros favoritos de 2º ESO. I.E.S. Alhakén II
 
Asignacion 5 laminas
Asignacion 5 laminas Asignacion 5 laminas
Asignacion 5 laminas
 
Borrador proyecto
Borrador proyectoBorrador proyecto
Borrador proyecto
 
Introduccion a Node.js
Introduccion a Node.jsIntroduccion a Node.js
Introduccion a Node.js
 
WCPT in 2016: European Region conference, Limassol April 2016
WCPT in 2016:  European Region conference, Limassol April 2016WCPT in 2016:  European Region conference, Limassol April 2016
WCPT in 2016: European Region conference, Limassol April 2016
 
Présentation1 sable bitumineux
Présentation1 sable bitumineux Présentation1 sable bitumineux
Présentation1 sable bitumineux
 

Similar to Getting Started with OpenGL ES

computer graphics slides by Talha shah
computer graphics slides by Talha shahcomputer graphics slides by Talha shah
computer graphics slides by Talha shahSyed Talha
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationMark Kilgard
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185Mahmoud Samir Fayed
 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Takao Wada
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupMark Kilgard
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingMark Kilgard
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10fungfung Chen
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184Mahmoud Samir Fayed
 
3 d graphics with opengl part 2
3 d graphics with opengl  part 23 d graphics with opengl  part 2
3 d graphics with opengl part 2Sardar Alam
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210Mahmoud Samir Fayed
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180Mahmoud Samir Fayed
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7Vanishree Arun
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentationBill Adams
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 

Similar to Getting Started with OpenGL ES (20)

computer graphics slides by Talha shah
computer graphics slides by Talha shahcomputer graphics slides by Talha shah
computer graphics slides by Talha shah
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and Representation
 
Development with OpenGL and Qt
Development with OpenGL and QtDevelopment with OpenGL and Qt
Development with OpenGL and Qt
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185
 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping Setup
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
 
3 d graphics with opengl part 2
3 d graphics with opengl  part 23 d graphics with opengl  part 2
3 d graphics with opengl part 2
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189
 
The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202
 
The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
 
The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentation
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 

More from John Wilker

Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11John Wilker
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2dJohn Wilker
 
User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.John Wilker
 
Physics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignPhysics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignJohn Wilker
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...John Wilker
 
Getting Started with iPhone Game Development
Getting Started with iPhone Game DevelopmentGetting Started with iPhone Game Development
Getting Started with iPhone Game DevelopmentJohn Wilker
 
Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your AppsJohn Wilker
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessJohn Wilker
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeJohn Wilker
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core AnimationJohn Wilker
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer GamingJohn Wilker
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessJohn Wilker
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchJohn Wilker
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGLJohn Wilker
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkJohn Wilker
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateJohn Wilker
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhoneJohn Wilker
 

More from John Wilker (20)

Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2d
 
User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.
 
Physics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignPhysics Solutions for Innovative Game Design
Physics Solutions for Innovative Game Design
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...
 
Getting Started with iPhone Game Development
Getting Started with iPhone Game DevelopmentGetting Started with iPhone Game Development
Getting Started with iPhone Game Development
 
Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your Apps
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application Responsiveness
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLime
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core Animation
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer Gaming
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve Responsiveness
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouch
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGL
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and Framework
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegate
 
Using SQLite
Using SQLiteUsing SQLite
Using SQLite
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhone
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Getting Started with OpenGL ES

  • 1. Getting Started with Open GL ES
  • 2. Vertex • A point in 3D space •x •y •z
  • 4. Setting position via GLfloat GLfloat vertex[3]; vertex[0] = 20.0 //x vertex[1] = 23.0 //y vertex[2] = 15.75 //z
  • 5. Vertex Array • A block of vertex data (vertex coordinates, texture coordinates, etc) for some or all objects. • size determined by number of vertices submitted x 3 for 3d objects (or 2 for 2d objects) • vertex array of 6 triangles = 6 x 3 x 3 = 54
  • 6. Data structure to hold vertex typedef struct { GLfloat x; GLfloat y; GLfloat z } vertex3D;
  • 7. Using Vertex3D Vertex3D vertex; vertex.x = 20.0 vertex.y = 23.0 vertex.z = 15.75
  • 8. Blank OpenGL Template • Jeff Lamarche’s Template • http://iphonedevelopment.blogspot.com/ 2008/12/updated-opengl-es-xcode- project.html
  • 9. creating vertices static inline Vertex3D Vertex3DMake(CGFloat inX, CGFloat inY, CGFloat inZ) { Vertex3D ret; ret.x = inX; ret.y = inY ret.z = inZ return ret;
  • 10. Distance between vertices static inline GLfloat Vertex3DCalculateDistanceBetweenVertices(Vertex3D first, Vertex3D second) { GLfloat deltaX = second.x - first.x; GLfloat deltaY = second.y - first.y; GLfloat deltaZ = second.z - first.x; return sqrtf(deltaX*deltaX + deltaY * deltaY + deltaZ *deltaZ);
  • 11. Triangles A triangle is the same as an array of 9 GLfloats typedef struct { Vertex 3D v1; Vertex 3D v2; Vertex 3D v3 } Triangle3D;
  • 12. Triangles Terminology • front face - face the viewer sees of an object • winding - order in which vertices are drawn matters for mechanics of which direction an object faces • backface - side that is not drawn • backface culling - process to determine which triangles are visible ot the user
  • 13. Viewports • Portion of viewable space that can be seen by viewer • Perspective Viewport- Converging lines and items change size based on distance • Orthogonal Viewport - No converging lines and changes in size to communicate distance
  • 14. GLOrthof() CGRect rect = view.bounds; glOrthof(-1.0, 1.0, -1.0 / rect.size.width / rect.size.height), -1.0 / rect.size.width / rect.size.height), 0.01, 1000.0, glViewport(0, 0, rect.size.width, rect.size.height);
  • 15. Perspective • Frustum - the shape of our space we see. Not cubic. • Field of Vision - angles used to calculate our frustum
  • 16. GLFrustumf() CGRect rect = view.bounds; glfloat size = .01 * tanf(DEGREES_TO_RADIANS(45.0)/ 2.0); glFrustumf(-size, size, -size / rect.size.width /rect.size.height), size / rect.size.width / rect.size.height), 0.01, 1000.0);
  • 17. Lights • You can have up to 8 lights • must be enabled using • glEnable(GL_LIGHT0); • Specify properties of light
  • 18. Components of Light • Ambient - No clear source. • Diffuse - even directional light on side of object that faces light • specular - highlight or hotspot
  • 19. Ambient const GLfloat light0Ambient[] = {0.05, 0.05, 0.05, 0.05, 1.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, light0Ambient);
  • 20. Diffuse const GLfloat light0Diffuse[] = {0.5, 0.5, 0.5, 0.5, 1.0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, light0Diffuse);
  • 21. Specular const GLfloat light0Specular[] = {0.7, 0.7, 0.7, 1.0};
  • 22. Light Position const GLfloat light0Position[] = {20.0, 20.0, 20.0, 1.0}; // light will be behind viewer20 units up and right
  • 23. Directional light const GLfloat light0Direction[] = {0.0, 0.0, -1.0}; glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light0Direction);
  • 24. Light Angle glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45); // sets light angle to 90 degrees
  • 25. Color • Defined as the color of light that an object reflects. • OpenGL allows us to specify color for each component of light(specular, diffuse & ambient) to material.
  • 26. Color on Material GLfloat ambientAndDiffuse[] = {0.0, 0.1, 0.9, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ambientAndDiffuse); //OpenGL ES only supports applying material to FRONT_AND_BACK
  • 27. Colors on different components of light GLfloat ambient[] = {0.0, 0.1, 0.9, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); GLfloat diffuse[] = {0.0, 0.1, 0.9, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
  • 28. Shininess on Specular GLfloat specular[] = {0.3, 0.3, 0.3, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 25.0); //tighter hotspot with shininess at 25 than default 50.
  • 29. Emission //giving and object a glow GLfloat emission[] = {0.0, 0.4, 0.0, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emission);
  • 30. Resources • http://www.khronos.org/opengles/1_X/ • http://iphonedevelopment.blogspot.com/2009/05/ opengl-es-from-ground-up-table-of.html • http://maniacdev.com/2009/07/16-killer-opengl-es- resources/ • http://web.me.com/smaurice/AppleCoder/ iPhone_OpenGL/iPhone_OpenGL.html
  • 31. OpenGL ES 2.0 Resources • Updated for iPhone - http://opengles- book.com/ • Shader Language - http://www.khronos.org/ files/opengles_shading_language.pdf
  • 32. Gaming Engines • http://code.google.com/p/cocos2d-iphone/ • http://sio2interactive.com/ • http://www.oolongengine.com/
  • 33. Thank you • A special thanks to Jeff Lamarche who’s series on Open GL ES from the ground up served as a major resources for this presentation and who’s openGL template I used in several examples. I highly recommend that you check out the series at: • http://iphonedevelopment.blogspot.com/2009/05/ opengl-es-from-ground-up-table-of.html