SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
Opening ES 2.0/3.0 Programming
Introduction
Champ Yen
http://champyen.blogspot.com

1
Outline
●

3D mathematics

●

OpenGL ES 2.0 overview

●

Vertex/Fragment shader basic understanding

●

Further study.

02/07/14

2
Basic Matrix/Vector Review
●

Vector Notation

●

Vector Operations

●

Matrix Notation

●

Matrix Operations

●

Orthogonality

●

Right-Handed Coordinate

●

Transformation/Translation

02/07/14

3
Vectors - Notation

1, 2, 3
1
2
3

02/07/14

row vector

column vector

a

b

4
Operations of Vectors
●
●
●
●

Negate (vector with opposite direction)
Magnitude (length of a vector)
Multiply by a scalar (scale length)
Normalize (vector with same direction, length = 1)

●

+, -, distance

●

Dot, Cross

02/07/14

5
Operations of Vectors - Dot

Geometric meaning
Dot product tells the similarity between
two vectors.

02/07/14

6
Operations of Vectors - Cross

Geometric meaning

Cross product yields a vector that is perpendicular
to the original two vectors.

02/07/14

7
Matrices - Notation

Mr×c
row

m11 m12 m13 
 m1(c-1) m1c
m21 m22 m23 
 m2(c-1) m2c
m31 m32 m33 
 m3(c-1) m3c









...
m(r-1)1 m(r-1)2 m(r-1)3 
 m(r-1)(c-1) m(r-1)c
mr1 mr2 mr3 
. mr(c-1) mrc

column

02/07/14

8
Matrices Operations
●

Identity matrix

●

Transposition (for Mrc, MTcr, mTij = mji)

●

Multiply with a scalar

●

Multiply two matrices

●

Multiply a vector with a matrix

●

Multiply a matrix with a vector

02/07/14

9
Orthogonality
●
●

Vector : a, b are orthogonal if a dot b = 0
Matrix : matrix m is orthogonal if m*mT = I => MT is M’s
inverse Matrix (M-1)

02/07/14

10
Coordinate – Right-Handed
+y

+x

+z
02/07/14

11
Linear Tranformation
+y
+y
’

A linear transformation
preserves straight and parallel
lines, and there is no
translation—the origin does
not move.
Applications:
ïŹ Rotation
+x ïŹ Scaling
ïŹ Reflection

..

+z
’

+z
02/07/14

+x
’
12
2D Rotation
The coordinate of P’ in XY space is:
(x, y) => (x*cos + y*(-sin), x*sin + y*cos)
+y’

+y

P’

p
+x’

Ξ

02/07/14

cos -sin
sin cos

x
y

+x

13
Rotation in 3D
Mx=

1
0
0

My=

cos
0
-sin

Mz =

0
0
cos -sin
sin cos
0
1
0

cos -sin
sin cos
0
0

Rotation around X axis

sin
0
cos

Rotation around Y axis

0
0
1

Rotation around Z axis

v’ = Mv
02/07/14

14
Translation
+y

P’ - P =

P’
P

+x

P’ =
+z

02/07/14

dx
dy
dz

1
0
0
0

0
1
0
0

0
0
1
0

dx
dy
dz
1

P
1
15
Combination – Transformation & Translation
Rotation then Translation

1
0
0
0

0
1
0
0

0
0
1
0

dx
dy
dz
1

cos -sin 0
sin cos 0
0
0
1
0
0
0

0
0
0
1

x
y
z
1

1
0
0
0

dx
dy
dz
1

x
y
z
1

Translation then Rotation

cos -sin 0
sin cos 0
0
0
1
0
0
0

0
0
0
1

0
1
0
0

0
0
1
0

Yes! We can do multiple things in ONE matrix.
02/07/14

16
What is OpenGL ES?
●

OpenGL-based API for Embedded Systems

●

Removed redundant and expensive functionality

●

Kept as compatible with OpenGL as possible

●

Added features needed for embedded systems

02/07/14

17
http://developer.amd.com/media/gpu_assets/GDCMobile2006-Ginsburg-OpenGLES2.0.pdf
OpenGL ES 2.0 programming
●
●

OpenGL ES 1.1/2.0 pipeline
initialization
ïź

●

setup
ïź
ïź
ïź

●

window system
geometry
shader
texture

per-frame rendering
ïź
ïź

02/07/14

uniform
drawing primitives
18
OpenGL (ES) 1.x Pipeline
Triangles/Lines/Points

API
API

Primitive
Primitive
Processing Vertices
Processing

Vertex
Vertex
Buffer
Buffer
Objects
Objects

Alpha
Alpha
Test
Test

02/07/14

Transform
Transform
and
and
Lighting
Lighting

Primitive
Primitive
Assembly
Assembly

Rasterizer
Rasterizer

Texture
Texture
Environment
Environment

Colour
Colour
Sum
Sum

Fog
Fog

Depth
Depth
Stencil
Stencil

Color
Color
Buffer
Buffer
Blend
Blend

Dither
Dither

http://www.khronos.org/opengles/2_X/

Frame Buffer

19
OpenGL (ES) 2.0 Pipeline
Triangles/Lines/Points

API
API

Primitive
Primitive
Processing Vertices
Processing

Vertex
Vertex
Shader
Shader

Vertex
Vertex
Buffer
Buffer
Objects
Objects

Primitive
Primitive
Assembly
Assembly

Rasterizer
Rasterizer

Fragment
Fragment
Shader
Shader

Depth
Depth
Stencil
Stencil

Color
Color
Buffer
Buffer
Blend
Blend

Dither
Dither

Frame Buffer

This isn’t your father’s OpenGL! (*)
02/07/14

*) OpenGL SuperBible 4/E

20
OpenGL ES 2.0 Overview
●

Shader only

●

Not backwards compatible to 1.x

●

ES GLSL forms core of API

●

●

Shifts some burden to application But puts more power in
your hands
Convergence of desktop and handheld!

02/07/14

21
http://developer.amd.com/media/gpu_assets/GDCMobile2006-Ginsburg-OpenGLES2.0.pdf
Initialize
●

●

●

EGL
Play the same role as glx/wgl/cgl.
glDepthRange(n, f);
Specify the depth of window coordinate.
glViewport(x, y, w, h);
Specify the bottom-left corner and display width/height of
window coordinate.

02/07/14

22
What you see may not be what you think.
Normalized Device Coordinate
(-1, 1, 1)

Window Coordinate

(1, 1, 1)

glViewPort
glDepthRange

(0, h, 1)
(0, h, 0)

(w, h, 1)
(w, h, 0)

Viewport
Transform

(-1, -1, 1)
(1, -1, 1)

(0, 0, 1)
(0, 0, 0)

(-1, -1, -1)
02/07/14

eye

(1, -1, -1)

(w, 0, 1)
(w, 0, 0)

eye
23
What’s shader?
●

●
●

●

a set of software instructions which is used primarily to
calculate rendering effects. (*)
Apply to each vertex or pixel.
Expose the capability to program a specific stage in
graphics pipeline.
Leverage CPU burden to GPU.

02/07/14

*) http://en.wikipedia.org/wiki/Shader

24
Vertex & Fragments

02/07/14

25
Shader Create/Compilation
GLuint LoadShader(GLenum type, const char *shaderSrc)
{
GLuint shader;
GLint compiled;
// Create the shader object, type must be GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
shader = glCreateShader(type);
if(shader == 0)
return 0;
// Load the shader source
glShaderSource(shader, 1, &shaderSrc, NULL); // Compile the shader
glCompileShader(shader);
// Check the compile status
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if(!compiled){




glDeleteShader(shader);
return 0;
}
return shader;
}
02/07/14

26
Program Create/Link
// Create the program object
programObject = glCreateProgram();
if(programObject == 0)
return 0;
glAttachShader(programObject, vertexShader);
glAttachShader(programObject, fragmentShader);
// Link the program
glLinkProgram(programObject);
// Check the link status
glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
if(!linked){



glDeleteProgram(programObject);
return FALSE;
}


// Use the program object
glUseProgram(programObject);

02/07/14

Linked Program
Vertex
Shader
Object
Fragment
Shader
Object

27
Vertex Shaders
output to fragment shader

02/07/14

28
GLSL
●

OpenGL Shading Language

●

C-Like Grammar

●

consistent version # with OpenGL since 3.3

●

GLSL ES 1.00 is based on GLSL 1.20

02/07/14

29
GLSL ES – Basic Types

vector/matrix types

textures
02/07/14

30
http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
Vertex Shader - Example
// uniforms used by the shaders
uniform mat4 u_mvp; // matrix to convert P from
// model space to clip space.
// attributes input to the vertex shader
attribute vec4 a_position; // input position value
attribute vec4 a_color;
// input vertex color
// varying variables – input to the fragment shader
varying vec4 v_color;
// output vertex color
void main()
{
v_color = a_color;
gl_Position = u_mvp * a_position;
}
02/07/14

31
Vertex Shader
Attributes: position, color,
normal, texture coordinate

 etc
Uniform: transform matrix,
light direction 
 etc

per-vertex info.
global info.

(0, 0.5, 0)

(-0.5, -0.5, 0)

02/07/14

(0.5, -0.5, 0)

32
Vertice Attributes
/* vertex without VBO, copy to GPU before
rendering each time*/
glEnableVertexAttribArray(vtxIdx);
glVertexAttribPointer(vtxIdx, vtxSize,
GL_FLOAT, GL_FALSE, vtxStride,
vtxBuf);



glBindAttribLocation(programObject,
vtxIdx, “a_position”);
glDrawElements(GL_TRIANGLES,
numIdx, GL_UNSIGNED_SHORT,
indices);

02/07/14

/* vertex with VBO, stored in GPU side */
glGenBuffer(1, &vboIds);
glBindBuffer(GL_ARRAY_BUFFER,
vboIdx);
glBufferData(GL_ARRAY_BUFFER,
vtxStride*numVtx, vtxBuf,
GL_STATIC);
offset = 0;
glEnableVertexAttribArray(vtxIdx);
glVertexAttribPointer(vtxIdx, vtxSize,
GL_FLOAT, GL_FALSE, vtxStride,
(void*)offset);



glBindAttribLocation(programObject,
vtxIdx, “a_position”);
glDrawElements(GL_TRIANGLES,
numIdx, GL_UNSIGNED_SHORT,
indices);
33
Primitives & Rasterization

02/07/14

34
Uniforms
GLint location;
GLfloat mvp[16];


 (calculate ModelViewProjection matrix)
location = glGetUniformLocation(programObject, “u_mvp”);
glUniform4fv(location, mvp);




103/02/07

35
Coordinate Transformation
world space

e
ey

eye space

model space
View Matrix
Rotate
Translation

Model Matrix
Rotate/Scaling
Translation

Perspective
Projection

103/02/07

Projection
Matrix

(Mproj * (Mview * (Mmodel * vertex))) = (Mproj * Mview * Mmodel) * vertex
= Mmvp * vertex

NDC, clip coordinate

36
View Matrix(cont.)
world space’ = world space – Peye

+y
+y’

+y

+x’
+z’

world space

e
ey

+x’

+y’

+z’

Translation

ey

e

+x

+x
+z

+z
103/02/07

37
View Matrix(cont.)
+y

M
+y’

X’

Y’

Z’

=

X

Y

Z

+x’
+z’

world space’

I

e
ey

+x

=

-1
∎

M=

X’

Y’

1
0
0

Z’

=

T
X’

Y’

Z’

0
1
0

0
0
1

X’

=

Y’
Z’

103/02/07

38
Perspective Projection Matrix

103/02/07

http://www.songho.ca/opengl/gl_projectionmatrix.html
http://read.pudn.com/downloads130/doc/556616/perspective.doc

39
View Matrix
Mview
X’
Y’
Z’
0 0 0

0
0
0
1

Mview =

103/02/07

1
0
0
0

0
1
0
0

0
0 -Peye
1
0 1

xw
yw
zw
1

=

xe
ye
ze
1

X’
-dot(X’,Pe)
Y’
-dot(Y’,Pe)
Z’
-dot(Z’,Pe)
0 0 0
1
40
Perspective Projection Matrix

103/02/07

http://www.songho.ca/opengl/gl_projectionmatrix.html
http://read.pudn.com/downloads130/doc/556616/perspective.doc

41
Fragment Shader

Color of a pixel in a fragment

103/02/07

42
Fragment Shader - Example

varying vec4 v_color;
// input vertex color
void main(void)
{
gl_FragColor = v_color;
}

103/02/07

43
Fragment Shader
The varying inputs of fragment shader from vertex shader
is interpolated for each pixel of a fragment.

103/02/07

44
Per-fragment Lightinng
Per-vertex Lighting

Per-fragment Lighting

103/02/07

45
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=222753
Textures – 2D Texture
// Generate a texture object
glGenTextures(1, &textureId);
// Bind the texture object
glBindTexture(GL_TEXTURE_2D, textureId);
// Load the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height,
0, GL_RGB,GL_UNSIGNED_BYTE, pixels);
// Set the filtering mode
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER, GL_NEAREST);

..
// Get the sampler locations
location = glGetUniformLocation(programObject, "s_texture");
// 

// Bind the texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
// Set the sampler texture unit to 0
glUniform1i(location, 0);
103/02/07

●

Only Texture2D is supported
(0.0, 1.0)

(1.0, 1.0)

(0.0, 0.0)

(1.0, 0.0)

46
Fragment Shader – Texture Example

varying vec2 v_textcoord;
uniform sampler2D s_texture;
void main(void)
{
gl_FragColor
= texture2D(s_texture, v_textcoord);
}

103/02/07

47
Texture - Environment Cube Mapping
Environment mapping provides good reflection effect.

103/02/07

48
Depth Test
glEnable(GL_DEPTH_TEST);
without depth test

103/02/07

with depth test

49
Culling
Culling opertaion discards the specific side of each triagles.

glFrontFace(GL_CW);

//clockwise

glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
Clockwise

V0
103/02/07

Counter-Clockwise

V1

V2

V2

V1

V0
50
Scissor/Stencil/Dithering

Scissor

Stencil

Dithering
103/02/07

http://angra.blog31.fc2.com/blog-entry-52.html
http://iphone-3d-programming.labs.oreilly.com/ch06.html

51
Frame Buffer Objects – release the power of GPU
motion blur

Depth of Field

Bloom lighting
Light Scattering

103/02/07

http://developer.nvidia.com/docs/IO/8230/GDC2003_OpenGLShaderTricks.pdf
http://en.wikipedia.org/wiki/Bloom_%28shader_effect%29
http://developer.amd.com/media/gpu_assets/Scheuermann_DepthOfField.pdf
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
http://www.fabiensanglard.net/lightScattering/index.php

52
More Power on Desktop
●
●
●
●
●
●
●
●

3D texture
Uniform Buffer Object
Floating-Point Depth/Texture/Render buffer
Double Precision
Shader subroutines
Geometry Shader
Tessellation Shader


..

103/02/07

53
Further Study
OpenGL ES 2.0 Programming Guide by Aaftab Munshi, Aaftab Munshi and Aaftab Munshi,
Addison-Wesley, ISBN13: 978-0321502797

OpenGL ES SuperBible 4th/5th edition by Richard S. Wright, Nicholas S Haemel, Graham
Sellers and Benjamin Lipchak, Addison-Wesley, ISBN13: 978-0321712615

3D Math Primer for Graphics and Game Development by Fletcher Dunn and Ian Parberry,
Jones & Bartlett Publishers , ISBN13: 978-1556229114

GPU Gems 3 by Hubert Nguyen, Addison-Wesley, ISBN13: 978-0321515261
Free Online: http://developer.nvidia.com/object/gpu-gems-3.html

103/02/07

54
Further Study
GPU Pro 2 edited by Wolfgang Engel, A K Peters/CRC Press (GPU Pro Series)
Original ShaderX series (http://tog.acm.org/resources/shaderx/)

OpenGL ES 2.0 specification (API 2.0.25, GLSL ES 1.0.17)
http://www.khronos.org/registry/gles/
OpenGL 4.1 Specification
http://www.opengl.org/registry/
NeHe
http://nehe.gamedev.net/
LightHouse3D
http://www.lighthouse3d.com/opengl/

103/02/07

55
Q&A
Thanks.

103/02/07

56

Weitere Àhnliche Inhalte

Was ist angesagt?

CCNP ROUTE V7 CH2
CCNP ROUTE V7 CH2CCNP ROUTE V7 CH2
CCNP ROUTE V7 CH2Chaing Ravuth
 
verification_planning_systemverilog_uvm_2020
verification_planning_systemverilog_uvm_2020verification_planning_systemverilog_uvm_2020
verification_planning_systemverilog_uvm_2020Sameh El-Ashry
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Samsung Open Source Group
 
GPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O ArchitectureGPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O Architectureguestb3fc97
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4Mohamed Abdallah
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblySam Bowne
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & ProfilingAnil Kumar Pugalia
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
Security issues in FPGA based systems.
Security issues in FPGA based systems.Security issues in FPGA based systems.
Security issues in FPGA based systems.Rajeev Verma
 
A Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowA Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowKoan-Sin Tan
 
Verilog HDL- 2
Verilog HDL- 2Verilog HDL- 2
Verilog HDL- 2Prabhavathi P
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT Mia Chang
 
Andes RISC-V vector extension demystified-tutorial
Andes RISC-V vector extension demystified-tutorialAndes RISC-V vector extension demystified-tutorial
Andes RISC-V vector extension demystified-tutorialRISC-V International
 
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...MIPI Alliance
 
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturVLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturPramod Kumar S
 
101 CCNA Labs with Solutions.pdf
101 CCNA Labs with Solutions.pdf101 CCNA Labs with Solutions.pdf
101 CCNA Labs with Solutions.pdfBiVnHu1
 
Verilog-A.pptx
Verilog-A.pptxVerilog-A.pptx
Verilog-A.pptxAbdullahAl20
 
OpenWRT manual
OpenWRT manualOpenWRT manual
OpenWRT manualfosk
 

Was ist angesagt? (20)

CCNP ROUTE V7 CH2
CCNP ROUTE V7 CH2CCNP ROUTE V7 CH2
CCNP ROUTE V7 CH2
 
verification_planning_systemverilog_uvm_2020
verification_planning_systemverilog_uvm_2020verification_planning_systemverilog_uvm_2020
verification_planning_systemverilog_uvm_2020
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64
 
GPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O ArchitectureGPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O Architecture
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 Disassembly
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVMBuild Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Presentation Contiki OS - Vietnamese
Presentation Contiki OS - VietnamesePresentation Contiki OS - Vietnamese
Presentation Contiki OS - Vietnamese
 
Security issues in FPGA based systems.
Security issues in FPGA based systems.Security issues in FPGA based systems.
Security issues in FPGA based systems.
 
A Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlowA Sneak Peek of MLIR in TensorFlow
A Sneak Peek of MLIR in TensorFlow
 
Verilog HDL- 2
Verilog HDL- 2Verilog HDL- 2
Verilog HDL- 2
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT
 
Andes RISC-V vector extension demystified-tutorial
Andes RISC-V vector extension demystified-tutorialAndes RISC-V vector extension demystified-tutorial
Andes RISC-V vector extension demystified-tutorial
 
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...
MIPI DevCon 2016: MIPI C-PHY - Introduction From Basic Theory to Practical Im...
 
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturVLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
 
101 CCNA Labs with Solutions.pdf
101 CCNA Labs with Solutions.pdf101 CCNA Labs with Solutions.pdf
101 CCNA Labs with Solutions.pdf
 
Verilog-A.pptx
Verilog-A.pptxVerilog-A.pptx
Verilog-A.pptx
 
OpenWRT manual
OpenWRT manualOpenWRT manual
OpenWRT manual
 

Andere mochten auch

OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering System
OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering SystemOpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering System
OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering Systemoasiskim
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES PresentationEric Cheng
 
OpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsOpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsChamp Yen
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtICS
 
Simd programming introduction
Simd programming introductionSimd programming introduction
Simd programming introductionChamp Yen
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - ShadersNick Pruehs
 
Introduction to protein structure
Introduction to protein structureIntroduction to protein structure
Introduction to protein structureBilal El Houdaigui
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015Mark Kilgard
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open glArvind Devaraj
 
CG OpenGL vectors geometric & transformations-course 5
CG OpenGL vectors geometric & transformations-course 5CG OpenGL vectors geometric & transformations-course 5
CG OpenGL vectors geometric & transformations-course 5fungfung Chen
 
kgc2014 LINE Rangers/Stage íŹëž˜ì‹œ 및 얎뷰징 대응
kgc2014 LINE Rangers/StageíŹëž˜ì‹œ 및 얎뷰징 대응kgc2014 LINE Rangers/StageíŹëž˜ì‹œ 및 얎뷰징 대응
kgc2014 LINE Rangers/Stage íŹëž˜ì‹œ 및 얎뷰징 대응sewoon Nam
 
jQTouch at jQuery Conference 2010
jQTouch at jQuery Conference 2010jQTouch at jQuery Conference 2010
jQTouch at jQuery Conference 2010David Kaneda
 
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...David Kaneda
 
Introduction to LESS
Introduction to LESSIntroduction to LESS
Introduction to LESSManish Shekhawat
 
Play With Android
Play With AndroidPlay With Android
Play With AndroidChamp Yen
 
jQTouch and Titanium
jQTouch and TitaniumjQTouch and Titanium
jQTouch and TitaniumMarc Grabanski
 
Introduction to open_gl_in_android
Introduction to open_gl_in_androidIntroduction to open_gl_in_android
Introduction to open_gl_in_androidtamillarasan
 

Andere mochten auch (20)

OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering System
OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering SystemOpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering System
OpenGL ES 2.0 Programming and Cocos2d-x v3.3 Rendering System
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES Presentation
 
OpenGL Basics
OpenGL BasicsOpenGL Basics
OpenGL Basics
 
OpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsOpenCL Kernel Optimization Tips
OpenCL Kernel Optimization Tips
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Simd programming introduction
Simd programming introductionSimd programming introduction
Simd programming introduction
 
Bai 1
Bai 1Bai 1
Bai 1
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
 
Introduction to protein structure
Introduction to protein structureIntroduction to protein structure
Introduction to protein structure
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open gl
 
CG OpenGL vectors geometric & transformations-course 5
CG OpenGL vectors geometric & transformations-course 5CG OpenGL vectors geometric & transformations-course 5
CG OpenGL vectors geometric & transformations-course 5
 
Part I : Introduction to Protein Structure
Part I : Introduction to Protein StructurePart I : Introduction to Protein Structure
Part I : Introduction to Protein Structure
 
kgc2014 LINE Rangers/Stage íŹëž˜ì‹œ 및 얎뷰징 대응
kgc2014 LINE Rangers/StageíŹëž˜ì‹œ 및 얎뷰징 대응kgc2014 LINE Rangers/StageíŹëž˜ì‹œ 및 얎뷰징 대응
kgc2014 LINE Rangers/Stage íŹëž˜ì‹œ 및 얎뷰징 대응
 
jQTouch at jQuery Conference 2010
jQTouch at jQuery Conference 2010jQTouch at jQuery Conference 2010
jQTouch at jQuery Conference 2010
 
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
 
Introduction to LESS
Introduction to LESSIntroduction to LESS
Introduction to LESS
 
Play With Android
Play With AndroidPlay With Android
Play With Android
 
jQTouch and Titanium
jQTouch and TitaniumjQTouch and Titanium
jQTouch and Titanium
 
Introduction to open_gl_in_android
Introduction to open_gl_in_androidIntroduction to open_gl_in_android
Introduction to open_gl_in_android
 

Ähnlich wie OpenGL ES 2.x Programming Introduction

Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES AndroidMindos Cheng
 
Opengl basics
Opengl basicsOpengl basics
Opengl basicspushpa latha
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Prabindh Sundareson
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IđŸ’» Anton Gerdelan
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsPrabindh Sundareson
 
OpenGL Shading Language
OpenGL Shading LanguageOpenGL Shading Language
OpenGL Shading LanguageJungsoo Nam
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glchangehee lee
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark Kilgard
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).pptHIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.pptHIMANKMISHRA2
 
GL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfGL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfshaikhshehzad024
 
Seminar presentation on OpenGL
Seminar presentation on OpenGLSeminar presentation on OpenGL
Seminar presentation on OpenGLMegha V
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsPrabindh Sundareson
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGLJungsoo Nam
 

Ähnlich wie OpenGL ES 2.x Programming Introduction (20)

Android native gl
Android native glAndroid native gl
Android native gl
 
Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES Android
 
How to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native ActivityHow to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native Activity
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI Platforms
 
OpenGL Shading Language
OpenGL Shading LanguageOpenGL Shading Language
OpenGL Shading Language
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_gl
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
 
GL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfGL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdf
 
Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0
 
Seminar presentation on OpenGL
Seminar presentation on OpenGLSeminar presentation on OpenGL
Seminar presentation on OpenGL
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
2D graphics
2D graphics2D graphics
2D graphics
 

KĂŒrzlich hochgeladen

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

KĂŒrzlich hochgeladen (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

OpenGL ES 2.x Programming Introduction

  • 1. Opening ES 2.0/3.0 Programming Introduction Champ Yen http://champyen.blogspot.com 1
  • 2. Outline ● 3D mathematics ● OpenGL ES 2.0 overview ● Vertex/Fragment shader basic understanding ● Further study. 02/07/14 2
  • 3. Basic Matrix/Vector Review ● Vector Notation ● Vector Operations ● Matrix Notation ● Matrix Operations ● Orthogonality ● Right-Handed Coordinate ● Transformation/Translation 02/07/14 3
  • 4. Vectors - Notation 1, 2, 3 1 2 3 02/07/14 row vector column vector a b 4
  • 5. Operations of Vectors ● ● ● ● Negate (vector with opposite direction) Magnitude (length of a vector) Multiply by a scalar (scale length) Normalize (vector with same direction, length = 1) ● +, -, distance ● Dot, Cross 02/07/14 5
  • 6. Operations of Vectors - Dot Geometric meaning Dot product tells the similarity between two vectors. 02/07/14 6
  • 7. Operations of Vectors - Cross Geometric meaning Cross product yields a vector that is perpendicular to the original two vectors. 02/07/14 7
  • 8. Matrices - Notation Mr×c row m11 m12 m13 
 m1(c-1) m1c m21 m22 m23 
 m2(c-1) m2c m31 m32 m33 
 m3(c-1) m3c 








... m(r-1)1 m(r-1)2 m(r-1)3 
 m(r-1)(c-1) m(r-1)c mr1 mr2 mr3 
. mr(c-1) mrc column 02/07/14 8
  • 9. Matrices Operations ● Identity matrix ● Transposition (for Mrc, MTcr, mTij = mji) ● Multiply with a scalar ● Multiply two matrices ● Multiply a vector with a matrix ● Multiply a matrix with a vector 02/07/14 9
  • 10. Orthogonality ● ● Vector : a, b are orthogonal if a dot b = 0 Matrix : matrix m is orthogonal if m*mT = I => MT is M’s inverse Matrix (M-1) 02/07/14 10
  • 12. Linear Tranformation +y +y ’ A linear transformation preserves straight and parallel lines, and there is no translation—the origin does not move. Applications: ïŹ Rotation +x ïŹ Scaling ïŹ Reflection 
.. +z ’ +z 02/07/14 +x ’ 12
  • 13. 2D Rotation The coordinate of P’ in XY space is: (x, y) => (x*cos + y*(-sin), x*sin + y*cos) +y’ +y P’ p +x’ Ξ 02/07/14 cos -sin sin cos x y +x 13
  • 14. Rotation in 3D Mx= 1 0 0 My= cos 0 -sin Mz = 0 0 cos -sin sin cos 0 1 0 cos -sin sin cos 0 0 Rotation around X axis sin 0 cos Rotation around Y axis 0 0 1 Rotation around Z axis v’ = Mv 02/07/14 14
  • 15. Translation +y P’ - P = P’ P +x P’ = +z 02/07/14 dx dy dz 1 0 0 0 0 1 0 0 0 0 1 0 dx dy dz 1 P 1 15
  • 16. Combination – Transformation & Translation Rotation then Translation 1 0 0 0 0 1 0 0 0 0 1 0 dx dy dz 1 cos -sin 0 sin cos 0 0 0 1 0 0 0 0 0 0 1 x y z 1 1 0 0 0 dx dy dz 1 x y z 1 Translation then Rotation cos -sin 0 sin cos 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 Yes! We can do multiple things in ONE matrix. 02/07/14 16
  • 17. What is OpenGL ES? ● OpenGL-based API for Embedded Systems ● Removed redundant and expensive functionality ● Kept as compatible with OpenGL as possible ● Added features needed for embedded systems 02/07/14 17 http://developer.amd.com/media/gpu_assets/GDCMobile2006-Ginsburg-OpenGLES2.0.pdf
  • 18. OpenGL ES 2.0 programming ● ● OpenGL ES 1.1/2.0 pipeline initialization ïź ● setup ïź ïź ïź ● window system geometry shader texture per-frame rendering ïź ïź 02/07/14 uniform drawing primitives 18
  • 19. OpenGL (ES) 1.x Pipeline Triangles/Lines/Points API API Primitive Primitive Processing Vertices Processing Vertex Vertex Buffer Buffer Objects Objects Alpha Alpha Test Test 02/07/14 Transform Transform and and Lighting Lighting Primitive Primitive Assembly Assembly Rasterizer Rasterizer Texture Texture Environment Environment Colour Colour Sum Sum Fog Fog Depth Depth Stencil Stencil Color Color Buffer Buffer Blend Blend Dither Dither http://www.khronos.org/opengles/2_X/ Frame Buffer 19
  • 20. OpenGL (ES) 2.0 Pipeline Triangles/Lines/Points API API Primitive Primitive Processing Vertices Processing Vertex Vertex Shader Shader Vertex Vertex Buffer Buffer Objects Objects Primitive Primitive Assembly Assembly Rasterizer Rasterizer Fragment Fragment Shader Shader Depth Depth Stencil Stencil Color Color Buffer Buffer Blend Blend Dither Dither Frame Buffer This isn’t your father’s OpenGL! (*) 02/07/14 *) OpenGL SuperBible 4/E 20
  • 21. OpenGL ES 2.0 Overview ● Shader only ● Not backwards compatible to 1.x ● ES GLSL forms core of API ● ● Shifts some burden to application But puts more power in your hands Convergence of desktop and handheld! 02/07/14 21 http://developer.amd.com/media/gpu_assets/GDCMobile2006-Ginsburg-OpenGLES2.0.pdf
  • 22. Initialize ● ● ● EGL Play the same role as glx/wgl/cgl. glDepthRange(n, f); Specify the depth of window coordinate. glViewport(x, y, w, h); Specify the bottom-left corner and display width/height of window coordinate. 02/07/14 22
  • 23. What you see may not be what you think. Normalized Device Coordinate (-1, 1, 1) Window Coordinate (1, 1, 1) glViewPort glDepthRange (0, h, 1) (0, h, 0) (w, h, 1) (w, h, 0) Viewport Transform (-1, -1, 1) (1, -1, 1) (0, 0, 1) (0, 0, 0) (-1, -1, -1) 02/07/14 eye (1, -1, -1) (w, 0, 1) (w, 0, 0) eye 23
  • 24. What’s shader? ● ● ● ● a set of software instructions which is used primarily to calculate rendering effects. (*) Apply to each vertex or pixel. Expose the capability to program a specific stage in graphics pipeline. Leverage CPU burden to GPU. 02/07/14 *) http://en.wikipedia.org/wiki/Shader 24
  • 26. Shader Create/Compilation GLuint LoadShader(GLenum type, const char *shaderSrc) { GLuint shader; GLint compiled; // Create the shader object, type must be GL_VERTEX_SHADER or GL_FRAGMENT_SHADER shader = glCreateShader(type); if(shader == 0) return 0; // Load the shader source glShaderSource(shader, 1, &shaderSrc, NULL); // Compile the shader glCompileShader(shader); // Check the compile status glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); if(!compiled){ 


 glDeleteShader(shader); return 0; } return shader; } 02/07/14 26
  • 27. Program Create/Link // Create the program object programObject = glCreateProgram(); if(programObject == 0) return 0; glAttachShader(programObject, vertexShader); glAttachShader(programObject, fragmentShader); // Link the program glLinkProgram(programObject); // Check the link status glGetProgramiv(programObject, GL_LINK_STATUS, &linked); if(!linked){ 

 glDeleteProgram(programObject); return FALSE; } 
 // Use the program object glUseProgram(programObject); 02/07/14 Linked Program Vertex Shader Object Fragment Shader Object 27
  • 28. Vertex Shaders output to fragment shader 02/07/14 28
  • 29. GLSL ● OpenGL Shading Language ● C-Like Grammar ● consistent version # with OpenGL since 3.3 ● GLSL ES 1.00 is based on GLSL 1.20 02/07/14 29
  • 30. GLSL ES – Basic Types vector/matrix types textures 02/07/14 30 http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
  • 31. Vertex Shader - Example // uniforms used by the shaders uniform mat4 u_mvp; // matrix to convert P from // model space to clip space. // attributes input to the vertex shader attribute vec4 a_position; // input position value attribute vec4 a_color; // input vertex color // varying variables – input to the fragment shader varying vec4 v_color; // output vertex color void main() { v_color = a_color; gl_Position = u_mvp * a_position; } 02/07/14 31
  • 32. Vertex Shader Attributes: position, color, normal, texture coordinate 
 etc Uniform: transform matrix, light direction 
 etc per-vertex info. global info. (0, 0.5, 0) (-0.5, -0.5, 0) 02/07/14 (0.5, -0.5, 0) 32
  • 33. Vertice Attributes /* vertex without VBO, copy to GPU before rendering each time*/ glEnableVertexAttribArray(vtxIdx); glVertexAttribPointer(vtxIdx, vtxSize, GL_FLOAT, GL_FALSE, vtxStride, vtxBuf); 

 glBindAttribLocation(programObject, vtxIdx, “a_position”); glDrawElements(GL_TRIANGLES, numIdx, GL_UNSIGNED_SHORT, indices); 02/07/14 /* vertex with VBO, stored in GPU side */ glGenBuffer(1, &vboIds); glBindBuffer(GL_ARRAY_BUFFER, vboIdx); glBufferData(GL_ARRAY_BUFFER, vtxStride*numVtx, vtxBuf, GL_STATIC); offset = 0; glEnableVertexAttribArray(vtxIdx); glVertexAttribPointer(vtxIdx, vtxSize, GL_FLOAT, GL_FALSE, vtxStride, (void*)offset); 

 glBindAttribLocation(programObject, vtxIdx, “a_position”); glDrawElements(GL_TRIANGLES, numIdx, GL_UNSIGNED_SHORT, indices); 33
  • 35. Uniforms GLint location; GLfloat mvp[16]; 

 (calculate ModelViewProjection matrix) location = glGetUniformLocation(programObject, “u_mvp”); glUniform4fv(location, mvp); 

 103/02/07 35
  • 36. Coordinate Transformation world space e ey eye space model space View Matrix Rotate Translation Model Matrix Rotate/Scaling Translation Perspective Projection 103/02/07 Projection Matrix (Mproj * (Mview * (Mmodel * vertex))) = (Mproj * Mview * Mmodel) * vertex = Mmvp * vertex NDC, clip coordinate 36
  • 37. View Matrix(cont.) world space’ = world space – Peye +y +y’ +y +x’ +z’ world space e ey +x’ +y’ +z’ Translation ey e +x +x +z +z 103/02/07 37
  • 40. View Matrix Mview X’ Y’ Z’ 0 0 0 0 0 0 1 Mview = 103/02/07 1 0 0 0 0 1 0 0 0 0 -Peye 1 0 1 xw yw zw 1 = xe ye ze 1 X’ -dot(X’,Pe) Y’ -dot(Y’,Pe) Z’ -dot(Z’,Pe) 0 0 0 1 40
  • 42. Fragment Shader Color of a pixel in a fragment 103/02/07 42
  • 43. Fragment Shader - Example varying vec4 v_color; // input vertex color void main(void) { gl_FragColor = v_color; } 103/02/07 43
  • 44. Fragment Shader The varying inputs of fragment shader from vertex shader is interpolated for each pixel of a fragment. 103/02/07 44
  • 45. Per-fragment Lightinng Per-vertex Lighting Per-fragment Lighting 103/02/07 45 http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=222753
  • 46. Textures – 2D Texture // Generate a texture object glGenTextures(1, &textureId); // Bind the texture object glBindTexture(GL_TEXTURE_2D, textureId); // Load the texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,GL_UNSIGNED_BYTE, pixels); // Set the filtering mode glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
.. // Get the sampler locations location = glGetUniformLocation(programObject, "s_texture"); // 
 // Bind the texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureId); // Set the sampler texture unit to 0 glUniform1i(location, 0); 103/02/07 ● Only Texture2D is supported (0.0, 1.0) (1.0, 1.0) (0.0, 0.0) (1.0, 0.0) 46
  • 47. Fragment Shader – Texture Example varying vec2 v_textcoord; uniform sampler2D s_texture; void main(void) { gl_FragColor = texture2D(s_texture, v_textcoord); } 103/02/07 47
  • 48. Texture - Environment Cube Mapping Environment mapping provides good reflection effect. 103/02/07 48
  • 49. Depth Test glEnable(GL_DEPTH_TEST); without depth test 103/02/07 with depth test 49
  • 50. Culling Culling opertaion discards the specific side of each triagles. glFrontFace(GL_CW); //clockwise glCullFace(GL_BACK); glEnable(GL_CULL_FACE); Clockwise V0 103/02/07 Counter-Clockwise V1 V2 V2 V1 V0 50
  • 52. Frame Buffer Objects – release the power of GPU motion blur Depth of Field Bloom lighting Light Scattering 103/02/07 http://developer.nvidia.com/docs/IO/8230/GDC2003_OpenGLShaderTricks.pdf http://en.wikipedia.org/wiki/Bloom_%28shader_effect%29 http://developer.amd.com/media/gpu_assets/Scheuermann_DepthOfField.pdf http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html http://www.fabiensanglard.net/lightScattering/index.php 52
  • 53. More Power on Desktop ● ● ● ● ● ● ● ● 3D texture Uniform Buffer Object Floating-Point Depth/Texture/Render buffer Double Precision Shader subroutines Geometry Shader Tessellation Shader 

.. 103/02/07 53
  • 54. Further Study OpenGL ES 2.0 Programming Guide by Aaftab Munshi, Aaftab Munshi and Aaftab Munshi, Addison-Wesley, ISBN13: 978-0321502797 OpenGL ES SuperBible 4th/5th edition by Richard S. Wright, Nicholas S Haemel, Graham Sellers and Benjamin Lipchak, Addison-Wesley, ISBN13: 978-0321712615 3D Math Primer for Graphics and Game Development by Fletcher Dunn and Ian Parberry, Jones & Bartlett Publishers , ISBN13: 978-1556229114 GPU Gems 3 by Hubert Nguyen, Addison-Wesley, ISBN13: 978-0321515261 Free Online: http://developer.nvidia.com/object/gpu-gems-3.html 103/02/07 54
  • 55. Further Study GPU Pro 2 edited by Wolfgang Engel, A K Peters/CRC Press (GPU Pro Series) Original ShaderX series (http://tog.acm.org/resources/shaderx/) OpenGL ES 2.0 specification (API 2.0.25, GLSL ES 1.0.17) http://www.khronos.org/registry/gles/ OpenGL 4.1 Specification http://www.opengl.org/registry/ NeHe http://nehe.gamedev.net/ LightHouse3D http://www.lighthouse3d.com/opengl/ 103/02/07 55