SlideShare a Scribd company logo
1 of 39
Download to read offline
How to Use OpenGL/ES on Native Activity
Noritsuna Imamura
noritsuna@siprop.org

©SIProp Project, 2006-2008

1
Agenda
What’s OpenGL?
Kind of OpenGL
Vertions

Hello 3D World
World
Polygon
Projection
Lighting
Texture

Hands on
Use OpenGL/ES 2.0
Shader Programming
©SIProp Project, 2006-2008

2
What’s OpenGL?
OpenGL is 3D Graphic API.
Made by SGI
Since: 1992
Current Version: 4.4
Architecture: PIPE Line Process

©SIProp Project, 2006-2008

3
What’s OpenGL/ES?
OpenGL is 3D Graphic API for Embedded.
Subset from OpenGL
Since: 2003
Current Version: 3.0

Android Version

Android API
Level

OpenGL/ES

1.0(Apple Pie)
2.2(Froyo)
4.3(JerryBeans)

1
8
18

1.0, 1.1
2.0
3.0
©SIProp Project, 2006-2008

4
Bible of OpenGL/ES
OpenGL/ES 2.0 Programming Guide
http://www.amazon.com/dp/0321502795/

OpenGL/ES 3.0 Programming Guide
http://www.amazon.com/dp/0321933885/

©SIProp Project, 2006-2008

5
Function

1.0/1.1

2.0

3.0

Compatibility

ー

ー

2.0

Programmable Shader

ー

GLSL ES 1.0

GLSL ES 3.0

Transform Feedback

ー

ー

Supported

Geometry

glNormal
glVertexPointer
glNormalPointer
glTexCordPointe

glVertexAttribPoint
er

glVertexAttribPoint
er

Matrix

glMatrixMode
glLoadIdentity
glPushMatrix

ー

ー

Lighting

glLight/glMaterial

ー

ー

Fog

glFog

ー

ー

Alpha Test

glAlphaFunc

ー

ー

Point Stripe

glTexEnv

ー

ー

User Clip

glClipPlane

ー

ー

Logic Operation

glLogicOp

ー

ー

FrameBuffer Object

Option

Supported

Supported
Multi-Buffer
©SIProp Project, 2006-2008

6
Hello 3D World!!!

©SIProp Project, 2006-2008

7
What’s 3D World?
Frame of Reference
World
Model(Object)

Coordinates
Vertex
Index
Source Site: http://tech-sketch.jp/2011/10/3d1.html
©SIProp Project, 2006-2008

8
How to Draw Polygon?
TRIANGLE_STRIP
Joint 2 Points

TRIANGLES
Draw each Triangle

TRIANGLE_FAN
Joint 2 Points, but
MUST use 1st Point

QUAD_STRIP
Joint 2 Points

QUAD
Draw each Square

POLYGON
Draw as Polygon

©SIProp Project, 2006-2008

9
How to Set in the World?
After Making Model, Set it to the World Frame.
Affine Transform

©SIProp Project, 2006-2008

10
Where is your Viewpoint(Viewport)?
Perspective Projection
zNear
Minimum Viewpoint of Z-Axis

zFar
Maximum Viewpoint of Z-Axis

fovy
Angle of view of Y-Axis

aspect
Width/height of RealWindow

©SIProp Project, 2006-2008

11
Can you see them?
Z-Buffer
ON => Draw by ZAxis
OFF => Draw by Sort
of Drawing

Alpha Blending
ON => Color is
Blended with Back
Model
OFF => No See

©SIProp Project, 2006-2008

12
There is Dark…
Positional Light
Radiate in all directions

Directional Light
Parallel in all directions

©SIProp Project, 2006-2008

13
Bad Surface…
Put Texture Image to Model.
UV-Mapping (U-horizontal, V-vertical)
Set Relation Between Texture Pixel and Model Vertex.

©SIProp Project, 2006-2008

14
How to Programing?
Use Fixed Function Pipeline in OpenGL/ES 1.1
glScale(x, y, z),
glRotate(Angle, x_moment, y_moment, z_moment)
glTranslate(x, y, z)

©SIProp Project, 2006-2008

15
How to Programing in 2.0or3.0?
Use Programmable Pipeline
VertexShader
FragmentShader

©SIProp Project, 2006-2008

16
Function

1.0/1.1

2.0

3.0

Compatibility

ー

ー

2.0

Programmable Shader

ー

GLSL ES 1.0

GLSL ES 3.0

Transform Feedback

ー

ー

Supported

Geometry

glNormal
glVertexPointer
glNormalPointer
glTexCordPointe

glVertexAttribPoint
er

glVertexAttribPoint
er

Matrix

glMatrixMode
glLoadIdentity
glPushMatrix

ー

ー

Lighting

glLight/glMaterial

ー

ー

Fog

glFog

ー

ー

Alpha Test

glAlphaFunc

ー

ー

Point Stripe

glTexEnv

ー

ー

User Clip

glClipPlane

ー

ー

Logic Operation

glLogicOp

ー

ー

FrameBuffer Object

Option

Supported

Supported
Multi-Buffer
©SIProp Project, 2006-2008

17
What’s Programmable Shader?
Shader(Renderer) that use GLSL (OpenGL
Shading Language).
Vertex Shader
Convert Model Information to World Frame

Geometry Shader (Primitive Shader)
Convert Primitive Data

Pixel Shader (Fragment Shader)
Effect to Each Pixels
Ex. Fogging, Shadowing, …

©SIProp Project, 2006-2008

18
Hello 3D Programming World!!!

©SIProp Project, 2006-2008

19
Today’s Target

©SIProp Project, 2006-2008

20
Naming Rule of Functions
glXXX

yyXXXf

OpenGL Func

eglXXX

float

yyXXXd

OpenGL/ES Func

gluXXX

double

yyXXXi

GUI Tools of Func

int

AGL, GLX, WGL
glutXXX
GLUT Func
GLUT is GUI Tools
of 3rd Party

yyXXX2d
2D of Double

yyXXX3d
3D of Double
©SIProp Project, 2006-2008

21
Setting Files
AndroidManifest.xml
1.

<uses-feature android:glEsVersion="0x00020000"/>

jni/Android.mk
1.

LOCAL_LDLIBS
lEGL -lGLESv2

+= -lm -llog -lc -ldl -lz -landroid -

©SIProp Project, 2006-2008

22
Init EGL World(System) 1/2
Configuration
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

const EGLint attribs[] = {
// Uset Open GL ES 2.0
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT,
// Set Surface Type as Double Buffer
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
// Minimum Frame Size of Blue
EGL_BLUE_SIZE, 8,
// Minimum Frame Size of Green
EGL_GREEN_SIZE, 8,
// Minimum Frame Size of Red
EGL_RED_SIZE, 8,
// Size of Depth Buffer
EGL_DEPTH_SIZE, 16,
// Terminator
EGL_NONE
©SIProp Project, 2006-2008
};

23
Init EGL World(System) 2/2
Init & Create
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

15.
16.
17.

// Get EGL Display Connection
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// Init Display
eglInitialize(display, 0, 0);
// Choose Frame Buffer List
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
// Get Frame Buffer Setting
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
// Set Frame Buffer to NativeActivity
ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
// Get Window Surface
surface = eglCreateWindowSurface(display, config, engine->app->window,
NULL);
// Get Rendering Context
const EGLint attrib_list[] = { EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE };
context = eglCreateContext(display, config, NULL, attrib_list);
// Attach Rendering Context to Window Surface
eglMakeCurrent(display, surface, surface, context);
©SIProp Project, 2006-2008

24
Init Cube Data
Create Programmable Shader!
glMyModel.cpp -> initCube()
1.
2.

// Create Shader Program
glProgram_Cube =
createProgram(gVertexShader_cube,
gFragmentShader_cube);

3.

// Bind Vertex to "Position" in VertexShader
Program
glBindAttribLocation(glProgram_Cube,
ATTRIB_VERTEX, "Position");
// Bind Color to "SourceColor" in VertexShader
Program
glBindAttribLocation(glProgram_Cube,
ATTRIB_COLOR, "SourceColor");

4.

5.
6.

7.
8.

// Set program
glUseProgram(glProgram_Cube);

©SIProp Project, 2006-2008

25
Setting of Programmable Shader
Write Shader Program using GLSL ES
Vertex Shader Source Code
1.
2.
3.
4.
5.
6.
7.
8.
9.

// Vertex Shader Program
static const char gVertexShader_cube[] =
"attribute vec4 Position;
n"
"attribute vec4 SourceColor;
n"
"varying vec4 DestinationColor;n"
"uniform mat4 Projection;
n"
"uniform mat4 Modelview;
n"
"void main() {n"
"
gl_Position = Projection * Modelview *
Position; n"
10.
"
DestinationColor = SourceColor; n"
11.
"}n";
©SIProp Project, 2006-2008

26
Setting of Programmable Shader
Fragment Shader Source Code

1.
2.
3.
4.
5.
6.

// FragmentShader of Color
static const char gFragmentShader_cube[] =
"varying lowp vec4 DestinationColor; n"
"void main() {n"
"gl_FragColor = DestinationColor;n"
"}n";

©SIProp Project, 2006-2008

27
About GLSL: Type
Type

Meaning

void

Same in C Lang

bool

Same in C++ Lang

int

Same in C Lang

float

Same in C Lang

vecX

Vector Type

bvecX

Logical Vector Type

ivecX

Int Vector Type

matX

Matrix Type

samplerXD

Handler of Texture

sampleCube

Handler of Cubic Texture

samplerXDShadow

Handler of Depth Texture

http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.clean.pdf
©SIProp Project, 2006-2008

28
About GLSL: Value
Value

Meaning

const

Same in C Lang

uniform

Global Value

in(Varying)

Input Value

out(Varying)

Output Value

inout(Varying)

Input/Output Value

©SIProp Project, 2006-2008

29
About GLSL: Built-in Function
Function Name

Meaning

radians()

degrees to radians

degrees()

radians to degrees

sin()

Sine

cos()

Cosine

tan()

Tangent

texture()

Set Texture

texture3D()

Set 3D Texture

imageLoad()

Load Image File

imageStore()

Store Image File

©SIProp Project, 2006-2008

30
About GLSL: Built-in Value
Value Name

Type

Meaning

gl_Vertex

vec4

Vertex Coordinates

gl_Normal

vec3

Vertex Normal vector

gl_Color

Vec4

Vertex Color

gl_ModelViewMatrix

mat4

ModelView Matrix

gl_ProjectionMatrix

mat4

Projection Matrix

gl_FrontColor

Vec4

Front Color

gl_BackColor

Vec4

Back Color

gl_TextCoord[]

Vec4

Texture Coordinates

gl_Position

Vec4

Vertex Position

gl_FragColor

Vec4

Color Frag

gl_FlagDepth

float

Depth Frag

©SIProp Project, 2006-2008

31
Check createProgram() Func
glPGShaderTools.cpp
NOT built-in Function. Everyone write same way.

1.

GLuint createProgram(const char* pVertexSource,
const char* pFragmentSource) {

2.

GLuint vertexShader =
loadShader(GL_VERTEX_SHADER, pVertexSource);
if (!vertexShader)
return 0;

3.
4.

5.

GLuint pixelShader =
loadShader(GL_FRAGMENT_SHADER,
pFragmentSource);

6.
©SIProp Project, 2006-2008

32
Set Projection
glPGShaderTools.cpp -> prepareFrame()
getPerspective() is NOT built-in…
1.
2.

3.

GLint projectionUniform =
glGetUniformLocation(glProgram, "Projection");
mat4 projectionMatrix = getPerspective(45, (float)
width / height, 0.5f, 500);
glUniformMatrix4fv(projectionUniform, 1, 0,
projectionMatrix.Pointer());

OpenGL/ES Version… All Built-in…
1.
2.
3.

glMatrixMode(GL_PROJECTON);
glLoadIdentity();
gluPerspective(45, (float)width / height, 0.5f, 500);
©SIProp Project, 2006-2008

33
Where is your Viewpoint(Viewport)?
Perspective Projection
zNear
Minimum Viewpoint of Z-Axis

zFar
Maximum Viewpoint of Z-Axis

fovy
Angle of view of Y-Axis

aspect
Width/height of RealWindow

©SIProp Project, 2006-2008

34
Draw Cube! 1/2
glMyModels.cpp -> drawCube()
Check Matrix.hpp & Vertex.hpp
They have “Affine Transform” Code…
Affine Transform Built-in Func is in OpenGL/ES 1.1…
1.
2.
3.
4.
5.
6.
7.

// Pose for Cube
mat4 rotationX = mat4::RotateX(engine->angleX);
mat4 rotationY = mat4::RotateY(engine->angleY);
mat4 rotationZ = mat4::RotateZ(engine->angleZ);
mat4 scale = mat4::Scale(1.0);
mat4 translation = mat4::Translate(0, 0, -10);
mat4 modelviewMatrix =
scale * rotationX * rotationY *
rotationZ *translation;

8.
9.

// Set pose
int modelviewUniform = glGetUniformLocation(glProgram_Cube,
"Modelview");
glUniformMatrix4fv(modelviewUniform, 1, 0,
modelviewMatrix.Pointer());

10.

©SIProp Project, 2006-2008

35
Draw Cube! 2/2
Draw Cube Polygon
1.
2.
3.
4.
5.
6.
7.
8.
9.

// Set Vertex Array
glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, GL_FALSE,
0, cubeVertices);
// Set Color Array
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE,
0, cubeColors);
//Enabled
glEnableVertexAttribArray(ATTRIB_VERTEX);
glEnableVertexAttribArray(ATTRIB_COLOR);
// Draw
glDrawElements(GL_TRIANGLE_STRIP, 14, GL_UNSIGNED_SHORT,
cubeIndices);

©SIProp Project, 2006-2008

36
Vertex of Cube
Draw Cube Polygon
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

// Vertex List of Cube
const GLfloat cubeVertices[] = {
/*
x
y
-1.0,
-1.0,
1.0,
1.0,
-1.0,
1.0,
-1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
-1.0,
-1.0,
-1.0,
1.0,
-1.0,
-1.0,
-1.0,
1.0,
-1.0,
1.0,
1.0,
-1.0,
};

z

*/

//0
//1
//2
//3
//4
//5
//6
//7

©SIProp Project, 2006-2008

37
How to Draw Polygon?
TRIANGLE_STRIP
Joint 2 Points

TRIANGLES
Draw each Triangle

TRIANGLE_FAN
Joint 2 Points, but
MUST use 1st Point

QUAD_STRIP
Joint 2 Points

QUAD
Draw each Square

POLYGON
Draw as Polygon

©SIProp Project, 2006-2008

38
Today’s Target

©SIProp Project, 2006-2008

39

More Related Content

What's hot

Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020 Bogusz Jelinski
 
Getting started with the NDK
Getting started with the NDKGetting started with the NDK
Getting started with the NDKKirill Kounik
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golangTing-Li Chou
 
Drone 1.0 Feature
Drone 1.0 FeatureDrone 1.0 Feature
Drone 1.0 FeatureBo-Yi Wu
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and PracticeBo-Yi Wu
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for androidzhang ghui
 
Orion RESTful git API
Orion RESTful git APIOrion RESTful git API
Orion RESTful git APITomasz Zarna
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionJuraj Michálek
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in phpBo-Yi Wu
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerGraham Charters
 
drone continuous Integration
drone continuous Integrationdrone continuous Integration
drone continuous IntegrationBo-Yi Wu
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Xavier Hallade
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...KAI CHU CHUNG
 
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...Puppet
 

What's hot (20)

Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020
 
Rest, sockets em golang
Rest, sockets em golangRest, sockets em golang
Rest, sockets em golang
 
Getting started with the NDK
Getting started with the NDKGetting started with the NDK
Getting started with the NDK
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
Drone 1.0 Feature
Drone 1.0 FeatureDrone 1.0 Feature
Drone 1.0 Feature
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and Practice
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
 
Orion RESTful git API
Orion RESTful git APIOrion RESTful git API
Orion RESTful git API
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django session
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in php
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
drone continuous Integration
drone continuous Integrationdrone continuous Integration
drone continuous Integration
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
NDK Introduction
NDK IntroductionNDK Introduction
NDK Introduction
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
 
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
 
Android NDK
Android NDKAndroid NDK
Android NDK
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 

Viewers also liked

Thinking Hybrid - Python/C++ Integration
Thinking Hybrid - Python/C++ IntegrationThinking Hybrid - Python/C++ Integration
Thinking Hybrid - Python/C++ IntegrationGuy K. Kloss
 
Investigation report on 64 bit support in Android Open Source Project
Investigation report on 64 bit support in Android Open Source ProjectInvestigation report on 64 bit support in Android Open Source Project
Investigation report on 64 bit support in Android Open Source Projecthidenorly
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2CommonsWare
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerCommonsWare
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depthChris Simmonds
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia FrameworkOpersys inc.
 
Practical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacksPractical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacksSecurity Session
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
 
Troubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersTroubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersCisco Mobility
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginXavier Hallade
 
Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia FrameworkPicker Weng
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidXavier Hallade
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementationChethan Pchethan
 

Viewers also liked (19)

Thinking Hybrid - Python/C++ Integration
Thinking Hybrid - Python/C++ IntegrationThinking Hybrid - Python/C++ Integration
Thinking Hybrid - Python/C++ Integration
 
Investigation report on 64 bit support in Android Open Source Project
Investigation report on 64 bit support in Android Open Source ProjectInvestigation report on 64 bit support in Android Open Source Project
Investigation report on 64 bit support in Android Open Source Project
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
 
IOMX in Android
IOMX in AndroidIOMX in Android
IOMX in Android
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
64-bit Android
64-bit Android64-bit Android
64-bit Android
 
Guide to Open Source Compliance
Guide to Open Source ComplianceGuide to Open Source Compliance
Guide to Open Source Compliance
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Practical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacksPractical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacks
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Troubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized ControllersTroubleshooting Wireless LANs with Centralized Controllers
Troubleshooting Wireless LANs with Centralized Controllers
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
 
Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia Framework
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on Android
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 

Similar to How to Use OpenGL/ES on Native Activity

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityMark Kilgard
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGLJungsoo Nam
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012philogb
 
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 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
 
CS 354 Programmable Shading
CS 354 Programmable ShadingCS 354 Programmable Shading
CS 354 Programmable ShadingMark Kilgard
 
Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES AndroidMindos Cheng
 
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
 
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfJIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfSamiraKids
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionChamp Yen
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Prabindh Sundareson
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGLGary Yeh
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsMark Kilgard
 
Shader Programming With Unity
Shader Programming With UnityShader Programming With Unity
Shader Programming With UnityMindstorm Studios
 

Similar to How to Use OpenGL/ES on Native Activity (20)

How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow to Use OpenMP on Native Activity
How to Use OpenMP on Native Activity
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
 
Android native gl
Android native glAndroid native gl
Android native gl
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
 
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 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
 
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...
 
CS 354 Programmable Shading
CS 354 Programmable ShadingCS 354 Programmable Shading
CS 354 Programmable Shading
 
Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES Android
 
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
 
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdfJIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
JIT Spraying Never Dies - Bypass CFG By Leveraging WARP Shader JIT Spraying.pdf
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming Introduction
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUs
 
Introduction to OpenGL.ppt
Introduction to OpenGL.pptIntroduction to OpenGL.ppt
Introduction to OpenGL.ppt
 
Shader Programming With Unity
Shader Programming With UnityShader Programming With Unity
Shader Programming With Unity
 

More from Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院)

More from Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院) (20)

What is the world where you can make your own semiconductors?
What is the world where you can make your own semiconductors?What is the world where you can make your own semiconductors?
What is the world where you can make your own semiconductors?
 
半導体製造(TinyTapeout)に挑戦しよう!
半導体製造(TinyTapeout)に挑戦しよう!半導体製造(TinyTapeout)に挑戦しよう!
半導体製造(TinyTapeout)に挑戦しよう!
 
Introduction of ISHI-KAI with OpenMPW
Introduction of ISHI-KAI with OpenMPWIntroduction of ISHI-KAI with OpenMPW
Introduction of ISHI-KAI with OpenMPW
 
Kernel/VMレイヤーを自分色に染める!By ISHI会
Kernel/VMレイヤーを自分色に染める!By ISHI会Kernel/VMレイヤーを自分色に染める!By ISHI会
Kernel/VMレイヤーを自分色に染める!By ISHI会
 
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPi
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPiPrinciple Representation of The 8 Qubits Quantum Computer by RaspberryPi
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPi
 
Microwaveguquantum
MicrowaveguquantumMicrowaveguquantum
Microwaveguquantum
 
The easiest way of setup QuTiP on Windows
The easiest way of setup QuTiP on WindowsThe easiest way of setup QuTiP on Windows
The easiest way of setup QuTiP on Windows
 
GNU Radio Study for Super beginner
GNU Radio Study for Super beginnerGNU Radio Study for Super beginner
GNU Radio Study for Super beginner
 
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
 
Self‐Contained SDR Grand Station with Raspberry Pi 3
Self‐Contained SDR Grand Station with Raspberry Pi 3Self‐Contained SDR Grand Station with Raspberry Pi 3
Self‐Contained SDR Grand Station with Raspberry Pi 3
 
衛星追尾用パラボラアンテナ建設記
衛星追尾用パラボラアンテナ建設記衛星追尾用パラボラアンテナ建設記
衛星追尾用パラボラアンテナ建設記
 
All list of the measuring machines for microwave
All list of the measuring machines for microwaveAll list of the measuring machines for microwave
All list of the measuring machines for microwave
 
5000円で誰でも作れる新世代衛星地上局
5000円で誰でも作れる新世代衛星地上局5000円で誰でも作れる新世代衛星地上局
5000円で誰でも作れる新世代衛星地上局
 
How to setup mastodon in chinese
How to setup mastodon in chineseHow to setup mastodon in chinese
How to setup mastodon in chinese
 
Radiation Test -Raspberry PI Zero-
Radiation Test -Raspberry PI Zero-Radiation Test -Raspberry PI Zero-
Radiation Test -Raspberry PI Zero-
 
將DNA在廚房抽出的程序
將DNA在廚房抽出的程序將DNA在廚房抽出的程序
將DNA在廚房抽出的程序
 
Protocol of the DNA Extraction in Kitchen
Protocol of the DNA Extraction in KitchenProtocol of the DNA Extraction in Kitchen
Protocol of the DNA Extraction in Kitchen
 
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
 
Zedroid - Android (5.0 and later) on Zedboard
Zedroid - Android (5.0 and later) on ZedboardZedroid - Android (5.0 and later) on Zedboard
Zedroid - Android (5.0 and later) on Zedboard
 
3D Printed Google Cardboard for workshop
3D Printed Google Cardboard for workshop3D Printed Google Cardboard for workshop
3D Printed Google Cardboard for workshop
 

Recently uploaded

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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
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
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
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
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

How to Use OpenGL/ES on Native Activity

  • 1. How to Use OpenGL/ES on Native Activity Noritsuna Imamura noritsuna@siprop.org ©SIProp Project, 2006-2008 1
  • 2. Agenda What’s OpenGL? Kind of OpenGL Vertions Hello 3D World World Polygon Projection Lighting Texture Hands on Use OpenGL/ES 2.0 Shader Programming ©SIProp Project, 2006-2008 2
  • 3. What’s OpenGL? OpenGL is 3D Graphic API. Made by SGI Since: 1992 Current Version: 4.4 Architecture: PIPE Line Process ©SIProp Project, 2006-2008 3
  • 4. What’s OpenGL/ES? OpenGL is 3D Graphic API for Embedded. Subset from OpenGL Since: 2003 Current Version: 3.0 Android Version Android API Level OpenGL/ES 1.0(Apple Pie) 2.2(Froyo) 4.3(JerryBeans) 1 8 18 1.0, 1.1 2.0 3.0 ©SIProp Project, 2006-2008 4
  • 5. Bible of OpenGL/ES OpenGL/ES 2.0 Programming Guide http://www.amazon.com/dp/0321502795/ OpenGL/ES 3.0 Programming Guide http://www.amazon.com/dp/0321933885/ ©SIProp Project, 2006-2008 5
  • 6. Function 1.0/1.1 2.0 3.0 Compatibility ー ー 2.0 Programmable Shader ー GLSL ES 1.0 GLSL ES 3.0 Transform Feedback ー ー Supported Geometry glNormal glVertexPointer glNormalPointer glTexCordPointe glVertexAttribPoint er glVertexAttribPoint er Matrix glMatrixMode glLoadIdentity glPushMatrix ー ー Lighting glLight/glMaterial ー ー Fog glFog ー ー Alpha Test glAlphaFunc ー ー Point Stripe glTexEnv ー ー User Clip glClipPlane ー ー Logic Operation glLogicOp ー ー FrameBuffer Object Option Supported Supported Multi-Buffer ©SIProp Project, 2006-2008 6
  • 7. Hello 3D World!!! ©SIProp Project, 2006-2008 7
  • 8. What’s 3D World? Frame of Reference World Model(Object) Coordinates Vertex Index Source Site: http://tech-sketch.jp/2011/10/3d1.html ©SIProp Project, 2006-2008 8
  • 9. How to Draw Polygon? TRIANGLE_STRIP Joint 2 Points TRIANGLES Draw each Triangle TRIANGLE_FAN Joint 2 Points, but MUST use 1st Point QUAD_STRIP Joint 2 Points QUAD Draw each Square POLYGON Draw as Polygon ©SIProp Project, 2006-2008 9
  • 10. How to Set in the World? After Making Model, Set it to the World Frame. Affine Transform ©SIProp Project, 2006-2008 10
  • 11. Where is your Viewpoint(Viewport)? Perspective Projection zNear Minimum Viewpoint of Z-Axis zFar Maximum Viewpoint of Z-Axis fovy Angle of view of Y-Axis aspect Width/height of RealWindow ©SIProp Project, 2006-2008 11
  • 12. Can you see them? Z-Buffer ON => Draw by ZAxis OFF => Draw by Sort of Drawing Alpha Blending ON => Color is Blended with Back Model OFF => No See ©SIProp Project, 2006-2008 12
  • 13. There is Dark… Positional Light Radiate in all directions Directional Light Parallel in all directions ©SIProp Project, 2006-2008 13
  • 14. Bad Surface… Put Texture Image to Model. UV-Mapping (U-horizontal, V-vertical) Set Relation Between Texture Pixel and Model Vertex. ©SIProp Project, 2006-2008 14
  • 15. How to Programing? Use Fixed Function Pipeline in OpenGL/ES 1.1 glScale(x, y, z), glRotate(Angle, x_moment, y_moment, z_moment) glTranslate(x, y, z) ©SIProp Project, 2006-2008 15
  • 16. How to Programing in 2.0or3.0? Use Programmable Pipeline VertexShader FragmentShader ©SIProp Project, 2006-2008 16
  • 17. Function 1.0/1.1 2.0 3.0 Compatibility ー ー 2.0 Programmable Shader ー GLSL ES 1.0 GLSL ES 3.0 Transform Feedback ー ー Supported Geometry glNormal glVertexPointer glNormalPointer glTexCordPointe glVertexAttribPoint er glVertexAttribPoint er Matrix glMatrixMode glLoadIdentity glPushMatrix ー ー Lighting glLight/glMaterial ー ー Fog glFog ー ー Alpha Test glAlphaFunc ー ー Point Stripe glTexEnv ー ー User Clip glClipPlane ー ー Logic Operation glLogicOp ー ー FrameBuffer Object Option Supported Supported Multi-Buffer ©SIProp Project, 2006-2008 17
  • 18. What’s Programmable Shader? Shader(Renderer) that use GLSL (OpenGL Shading Language). Vertex Shader Convert Model Information to World Frame Geometry Shader (Primitive Shader) Convert Primitive Data Pixel Shader (Fragment Shader) Effect to Each Pixels Ex. Fogging, Shadowing, … ©SIProp Project, 2006-2008 18
  • 19. Hello 3D Programming World!!! ©SIProp Project, 2006-2008 19
  • 21. Naming Rule of Functions glXXX yyXXXf OpenGL Func eglXXX float yyXXXd OpenGL/ES Func gluXXX double yyXXXi GUI Tools of Func int AGL, GLX, WGL glutXXX GLUT Func GLUT is GUI Tools of 3rd Party yyXXX2d 2D of Double yyXXX3d 3D of Double ©SIProp Project, 2006-2008 21
  • 22. Setting Files AndroidManifest.xml 1. <uses-feature android:glEsVersion="0x00020000"/> jni/Android.mk 1. LOCAL_LDLIBS lEGL -lGLESv2 += -lm -llog -lc -ldl -lz -landroid - ©SIProp Project, 2006-2008 22
  • 23. Init EGL World(System) 1/2 Configuration 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. const EGLint attribs[] = { // Uset Open GL ES 2.0 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Set Surface Type as Double Buffer EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Minimum Frame Size of Blue EGL_BLUE_SIZE, 8, // Minimum Frame Size of Green EGL_GREEN_SIZE, 8, // Minimum Frame Size of Red EGL_RED_SIZE, 8, // Size of Depth Buffer EGL_DEPTH_SIZE, 16, // Terminator EGL_NONE ©SIProp Project, 2006-2008 }; 23
  • 24. Init EGL World(System) 2/2 Init & Create 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. // Get EGL Display Connection EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); // Init Display eglInitialize(display, 0, 0); // Choose Frame Buffer List eglChooseConfig(display, attribs, &config, 1, &numConfigs); // Get Frame Buffer Setting eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); // Set Frame Buffer to NativeActivity ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format); // Get Window Surface surface = eglCreateWindowSurface(display, config, engine->app->window, NULL); // Get Rendering Context const EGLint attrib_list[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; context = eglCreateContext(display, config, NULL, attrib_list); // Attach Rendering Context to Window Surface eglMakeCurrent(display, surface, surface, context); ©SIProp Project, 2006-2008 24
  • 25. Init Cube Data Create Programmable Shader! glMyModel.cpp -> initCube() 1. 2. // Create Shader Program glProgram_Cube = createProgram(gVertexShader_cube, gFragmentShader_cube); 3. // Bind Vertex to "Position" in VertexShader Program glBindAttribLocation(glProgram_Cube, ATTRIB_VERTEX, "Position"); // Bind Color to "SourceColor" in VertexShader Program glBindAttribLocation(glProgram_Cube, ATTRIB_COLOR, "SourceColor"); 4. 5. 6. 7. 8. // Set program glUseProgram(glProgram_Cube); ©SIProp Project, 2006-2008 25
  • 26. Setting of Programmable Shader Write Shader Program using GLSL ES Vertex Shader Source Code 1. 2. 3. 4. 5. 6. 7. 8. 9. // Vertex Shader Program static const char gVertexShader_cube[] = "attribute vec4 Position; n" "attribute vec4 SourceColor; n" "varying vec4 DestinationColor;n" "uniform mat4 Projection; n" "uniform mat4 Modelview; n" "void main() {n" " gl_Position = Projection * Modelview * Position; n" 10. " DestinationColor = SourceColor; n" 11. "}n"; ©SIProp Project, 2006-2008 26
  • 27. Setting of Programmable Shader Fragment Shader Source Code 1. 2. 3. 4. 5. 6. // FragmentShader of Color static const char gFragmentShader_cube[] = "varying lowp vec4 DestinationColor; n" "void main() {n" "gl_FragColor = DestinationColor;n" "}n"; ©SIProp Project, 2006-2008 27
  • 28. About GLSL: Type Type Meaning void Same in C Lang bool Same in C++ Lang int Same in C Lang float Same in C Lang vecX Vector Type bvecX Logical Vector Type ivecX Int Vector Type matX Matrix Type samplerXD Handler of Texture sampleCube Handler of Cubic Texture samplerXDShadow Handler of Depth Texture http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.clean.pdf ©SIProp Project, 2006-2008 28
  • 29. About GLSL: Value Value Meaning const Same in C Lang uniform Global Value in(Varying) Input Value out(Varying) Output Value inout(Varying) Input/Output Value ©SIProp Project, 2006-2008 29
  • 30. About GLSL: Built-in Function Function Name Meaning radians() degrees to radians degrees() radians to degrees sin() Sine cos() Cosine tan() Tangent texture() Set Texture texture3D() Set 3D Texture imageLoad() Load Image File imageStore() Store Image File ©SIProp Project, 2006-2008 30
  • 31. About GLSL: Built-in Value Value Name Type Meaning gl_Vertex vec4 Vertex Coordinates gl_Normal vec3 Vertex Normal vector gl_Color Vec4 Vertex Color gl_ModelViewMatrix mat4 ModelView Matrix gl_ProjectionMatrix mat4 Projection Matrix gl_FrontColor Vec4 Front Color gl_BackColor Vec4 Back Color gl_TextCoord[] Vec4 Texture Coordinates gl_Position Vec4 Vertex Position gl_FragColor Vec4 Color Frag gl_FlagDepth float Depth Frag ©SIProp Project, 2006-2008 31
  • 32. Check createProgram() Func glPGShaderTools.cpp NOT built-in Function. Everyone write same way. 1. GLuint createProgram(const char* pVertexSource, const char* pFragmentSource) { 2. GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource); if (!vertexShader) return 0; 3. 4. 5. GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource); 6. ©SIProp Project, 2006-2008 32
  • 33. Set Projection glPGShaderTools.cpp -> prepareFrame() getPerspective() is NOT built-in… 1. 2. 3. GLint projectionUniform = glGetUniformLocation(glProgram, "Projection"); mat4 projectionMatrix = getPerspective(45, (float) width / height, 0.5f, 500); glUniformMatrix4fv(projectionUniform, 1, 0, projectionMatrix.Pointer()); OpenGL/ES Version… All Built-in… 1. 2. 3. glMatrixMode(GL_PROJECTON); glLoadIdentity(); gluPerspective(45, (float)width / height, 0.5f, 500); ©SIProp Project, 2006-2008 33
  • 34. Where is your Viewpoint(Viewport)? Perspective Projection zNear Minimum Viewpoint of Z-Axis zFar Maximum Viewpoint of Z-Axis fovy Angle of view of Y-Axis aspect Width/height of RealWindow ©SIProp Project, 2006-2008 34
  • 35. Draw Cube! 1/2 glMyModels.cpp -> drawCube() Check Matrix.hpp & Vertex.hpp They have “Affine Transform” Code… Affine Transform Built-in Func is in OpenGL/ES 1.1… 1. 2. 3. 4. 5. 6. 7. // Pose for Cube mat4 rotationX = mat4::RotateX(engine->angleX); mat4 rotationY = mat4::RotateY(engine->angleY); mat4 rotationZ = mat4::RotateZ(engine->angleZ); mat4 scale = mat4::Scale(1.0); mat4 translation = mat4::Translate(0, 0, -10); mat4 modelviewMatrix = scale * rotationX * rotationY * rotationZ *translation; 8. 9. // Set pose int modelviewUniform = glGetUniformLocation(glProgram_Cube, "Modelview"); glUniformMatrix4fv(modelviewUniform, 1, 0, modelviewMatrix.Pointer()); 10. ©SIProp Project, 2006-2008 35
  • 36. Draw Cube! 2/2 Draw Cube Polygon 1. 2. 3. 4. 5. 6. 7. 8. 9. // Set Vertex Array glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, GL_FALSE, 0, cubeVertices); // Set Color Array glVertexAttribPointer(ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, cubeColors); //Enabled glEnableVertexAttribArray(ATTRIB_VERTEX); glEnableVertexAttribArray(ATTRIB_COLOR); // Draw glDrawElements(GL_TRIANGLE_STRIP, 14, GL_UNSIGNED_SHORT, cubeIndices); ©SIProp Project, 2006-2008 36
  • 37. Vertex of Cube Draw Cube Polygon 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. // Vertex List of Cube const GLfloat cubeVertices[] = { /* x y -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, }; z */ //0 //1 //2 //3 //4 //5 //6 //7 ©SIProp Project, 2006-2008 37
  • 38. How to Draw Polygon? TRIANGLE_STRIP Joint 2 Points TRIANGLES Draw each Triangle TRIANGLE_FAN Joint 2 Points, but MUST use 1st Point QUAD_STRIP Joint 2 Points QUAD Draw each Square POLYGON Draw as Polygon ©SIProp Project, 2006-2008 38