SlideShare a Scribd company logo
OpenGL
by Sebestyén Gábor
What is OpenGL?
● Standard specification of cross-platform API
● 2D and 3D graphics
● Draw complex 3D scenes built up from
primitives
● 1992, SGI
What is OpenGL?
● Low-level procedural API (think LOGO)
● “Dictate the exact steps” (vs Scene Graph)
● OpenGL pipeline
OpenGL ES
● Designed for embedded systems
● Fixed-point data types
● No glBegin()...glEnd() frames for primitives
● Use vertex arrays instead
● Chosen for WebGL
History
● Early 1990s - IRIS GL (SGI), PHIGS (DEC,
IBM, Sun)
● 1992 OpenGL Standard Spec
● standardize hardware access
● 1995 Microsoft DirectX
● 2006 Khronos Group controls OpenGL spec
Versions
● 1992 1.0 first version
● 1997 1.1 support textures on GPU
● 2004 2.0 GLSL, ARB
● 2008 3.0 (answer to DirectX 10)
● 2010 4.0
● 2011 4.2
Architecture
Pipeline
● Command evaluations
○ vertices and attributes
● Per-vertex operations
● Rasterization
○ vertex -> fragment
● Framebuffer operations
Primitives
Lots of things we skip now
● Lighting and Materials
● Textures
● Shading Language
● Clipping, Culling, and Visibility Testing
● etc.
My first OpenGL app
#1 Boilerplate
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glu.h>
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(800,600);
glutCreateWindow("Hello World");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Explanation
● Includes
● Initialization Code
● Main Loop
Includes on Linux
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glu.h>
Includes on OS X
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
Libraries
● OpenGL - basic functionality
● GLU - GL Utility
● GLUT - GL Utility Toolkit
OpenGL Utility Library
● Texture mipmaps from base images
● Map coordinates between screen and object
space
● Draw quadric surfaces and NURBS
Mipmaps
OpenGL Utility Toolkit
● Cross-platform tool
● Windowing & input API
● Best for learning OpenGL
● Not open-source
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH |
GLUT_DOUBLE);
glutInitWindowSize(800,600);
glutCreateWindow("Hello World");
glutDisplayFunc(display);
glutMainLoop();
return 0;
#2 Spinning Cube
Explanation
● Init Cube
● Display function
● Clear scene
● Set rotation
● Draw Cube
int main(int argc, char *argv[])
{
..
//
glMatrixMode(GL_PROJECTION);
gluPerspective(45, //view angle
1.0, //aspect ratio
10.0, //near clip
200.0);//far clip
glMatrixMode(GL_MODELVIEW);
// enabe face culling function
glEnable(GL_CULL_FACE);
initCube();
glutMainLoop();
..
}
void display()
{
...
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0, 0, -50);
glRotatef(rotateBy, 1, 1, 0); //rotate by rotateBy degrees about the vector
(1,1,0)
...
glBegin(GL_QUADS);
for (b=0; b<4; b++)
{
currentVer = cube.quad[a].ver[b];
glColor3fv(cube.ver[ currentVer ].col);
glVertex3fv(cube.ver[ currentVer ].pos);
}
glEnd();
...
}
#3 Textured Cube
Explanation
● Initialize inline texture data
● Initialize texture subsystem
● Map texture to surface
const float texCoords[4][2]=
{
{0.0, 0.0},
{0.0, 1.0},
{1.0, 1.0},
{1.0, 0.0}
};
UV coordinates
// Init texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
Initialize texture
int display()
{
...
// enable textures
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
...
}
Turn on textures (redraw function)
int display()
{
...
// draw cube
for (a=0; a<6; a++) //quads loop
{
glBegin(GL_QUADS);
for (b=0; b<4; b++) //points loop
{
currentVer = cube.quad[a].ver[b]; //sets the current vertex to
this point's vertex
// glColor3fv(cube.ver[ currentVer ].col); //changes the colour to the
current vertex's colour
glTexCoord2fv(texCoords[b]);
glVertex3fv(cube.ver[ currentVer ].pos); //draws a vertex at the current
vertex's position
}
glEnd();
}
...
}
Lights
Motivation
● Surface = color + shader
● Vertex colors
● Shaders: FLAT vs SMOOTH
● We want more spectacular look!
● Light sources
● Materials
Lights
● Pixel colors are calculated from components
below
● Ambient
● Diffuse (‘soft’ lighting)
● Specular (‘hard’ lighting)
● Emission
Ambient Diffuse A + D
Shading Languages
Shading Languages
● Greater flexibility at vertex and fragment
level
● OpenGL ARB
● OpenGL GLSL, DirectX HLSL, nVidia Cg, ...
Lights
● Pixel colors are calculated from components
below
● Ambient
● Diffuse (‘soft’ lighting)
● Specular (‘hard’ lighting)
● Emission
Vertex Shader
● Executed when glVertex() / glDrawArrays()
called
● vertex, normal transformations
● normalization, rescaling
● lighting, texcoord generation / transformation
Fragment Shader
● Operates on every fragments
● Texture access
● Fog
Data Types
● vec2, vec3, vec4
● ivec2, ivec3, ivec4
● bvec2, bvec3, bvec4
● mat2, mat3, mat4
Input
● Attributes - vertex level, read-only (vertex
pos)
● Uniforms - invariant during rendering (light
pos, color)
● Varying - used to pass data from vertex
shader to
● fragment shader
Built-in Types
● Attributes
○ gl_Vertex
○ gl_Normal
○ gl_Color
○ gl_MultiTexCoordX
Built-in Types
● Uniforms
○ gl_ModelViewMatrix
○ gl_ModelViewProjectionMatrix
○ gl_NormalMatrix
Built-in Types
● Varying
○ gl_FrontColor
○ gl_BackColor
○ gl_TexCoord
uniform sampler2D my_color_texture;
uniform mat4 my_texture_matrix;
varying vec3 vertex_to_light_vector;
varying vec3 vertex_to_eye_vector;
attribute vec3 tangent;
attribute vec3 binormal;
Examples
void main()
{
// Transforming The Vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
void main()
{
// Setting Each Pixel To Red
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
Examples
Vertex Shader part
varying vec2 texture_coordinate;
void main()
{
// Transforming The Vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
texture_coordinate = vec2(gl_MultiTexCoord0);
}
Texture Mapper
Fragment Shader part
varying vec2 texture_coordinate;
uniform sampler2D my_color_texture;
void main()
{
// Sampling The Texture And Passing It To The Frame Buffer
gl_FragColor = texture2D(my_color_texture, texture_coordinate);
}
Texture Mapper

More Related Content

What's hot

Opengl basics
Opengl basicsOpengl basics
Opengl basics
pushpa latha
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
Yi-Lung Tsai
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
Syed Zaid Irshad
 
Baiscs of OpenGL
Baiscs of OpenGLBaiscs of OpenGL
Baiscs of OpenGL
Mrinmoy Dalal
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
ch samaram
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
elnaqah
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
Arvind Devaraj
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
Mohammed Romi
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
Mark Kilgard
 
OpenGL Shading Language
OpenGL Shading LanguageOpenGL Shading Language
OpenGL Shading Language
Jungsoo Nam
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
abigail Dayrit
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES Presentation
Eric Cheng
 
SIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGLSIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGL
Mark Kilgard
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
Mark Kilgard
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
Mark Kilgard
 
OpenGL 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
Mark Kilgard
 
Introduction to open_gl_in_android
Introduction to open_gl_in_androidIntroduction to open_gl_in_android
Introduction to open_gl_in_android
tamillarasan
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
Jungsoo Nam
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to Vulkan
Mark Kilgard
 
NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016
Mark Kilgard
 

What's hot (20)

Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
Baiscs of OpenGL
Baiscs of OpenGLBaiscs of OpenGL
Baiscs of OpenGL
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
OpenGL Shading Language
OpenGL Shading LanguageOpenGL Shading Language
OpenGL Shading Language
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES Presentation
 
SIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGLSIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGL
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
OpenGL 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
 
Introduction to open_gl_in_android
Introduction to open_gl_in_androidIntroduction to open_gl_in_android
Introduction to open_gl_in_android
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to Vulkan
 
NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016
 

Viewers also liked

Chapter 00 - Computer Graphics using Open GL
Chapter 00 - Computer Graphics using Open GLChapter 00 - Computer Graphics using Open GL
Chapter 00 - Computer Graphics using Open GL
Thanh Bình
 
Hàm can bản
Hàm can bảnHàm can bản
Hàm can bản
tienhien110293
 

Viewers also liked (7)

Chapter 00 - Computer Graphics using Open GL
Chapter 00 - Computer Graphics using Open GLChapter 00 - Computer Graphics using Open GL
Chapter 00 - Computer Graphics using Open GL
 
Lect05 array
Lect05 arrayLect05 array
Lect05 array
 
Lab4
Lab4Lab4
Lab4
 
Lect09 string
Lect09 stringLect09 string
Lect09 string
 
Hàm can bản
Hàm can bảnHàm can bản
Hàm can bản
 
Tn ktlt
Tn ktltTn ktlt
Tn ktlt
 
Tut6 solution
Tut6 solutionTut6 solution
Tut6 solution
 

Similar to Open gl

september11.ppt
september11.pptseptember11.ppt
september11.ppt
CharlesMatu2
 
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
HIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
HIMANKMISHRA2
 
Introduction to accelerated graphics
Introduction to accelerated graphicsIntroduction to accelerated graphics
Introduction to accelerated graphics
Ruslan Novikov
 
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
 
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
ICS
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
Cass Everitt
 
Efficient Image Processing - Nicolas Roard
Efficient Image Processing - Nicolas RoardEfficient Image Processing - Nicolas Roard
Efficient Image Processing - Nicolas Roard
Paris Android User Group
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
Prabindh Sundareson
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
ICS
 
High performance graphics and computation - OpenGL ES and RenderScript
High performance graphics and computation - OpenGL ES and RenderScript High performance graphics and computation - OpenGL ES and RenderScript
High performance graphics and computation - OpenGL ES and RenderScript
BlrDroid
 
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
changehee lee
 
Chapter-3.pdf
Chapter-3.pdfChapter-3.pdf
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
changehee lee
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...
rsebbe
 
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
Prabindh Sundareson
 
OpenGL Interaction
OpenGL InteractionOpenGL Interaction
OpenGL Interaction
Sandip Jadhav
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx
ssuser255bf1
 
Android High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscriptAndroid High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscript
Arvind Devaraj
 
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
Mark Kilgard
 

Similar to Open gl (20)

september11.ppt
september11.pptseptember11.ppt
september11.ppt
 
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
 
Introduction to accelerated graphics
Introduction to accelerated graphicsIntroduction to accelerated graphics
Introduction to accelerated graphics
 
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
 
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
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
Efficient Image Processing - Nicolas Roard
Efficient Image Processing - Nicolas RoardEfficient Image Processing - Nicolas Roard
Efficient Image Processing - Nicolas Roard
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
 
High performance graphics and computation - OpenGL ES and RenderScript
High performance graphics and computation - OpenGL ES and RenderScript High performance graphics and computation - OpenGL ES and RenderScript
High performance graphics and computation - OpenGL ES and RenderScript
 
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
 
Chapter-3.pdf
Chapter-3.pdfChapter-3.pdf
Chapter-3.pdf
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...
 
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 Interaction
OpenGL InteractionOpenGL Interaction
OpenGL Interaction
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx
 
Android High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscriptAndroid High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscript
 
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
 

More from EU Edge

Synchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBSynchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDB
EU Edge
 
How I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-blockHow I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-block
EU Edge
 
Node.js
Node.jsNode.js
Node.js
EU Edge
 
What is python
What is pythonWhat is python
What is python
EU Edge
 
Advanced python
Advanced pythonAdvanced python
Advanced python
EU Edge
 
WebGL
WebGLWebGL
WebGL
EU Edge
 
Python alapu mobil backend
Python alapu mobil backendPython alapu mobil backend
Python alapu mobil backend
EU Edge
 
Res tful services
Res tful servicesRes tful services
Res tful services
EU Edge
 
Google glass a developers perspective
Google glass   a developers perspectiveGoogle glass   a developers perspective
Google glass a developers perspective
EU Edge
 
Google glass ict day presentation
Google glass   ict day presentationGoogle glass   ict day presentation
Google glass ict day presentation
EU Edge
 
How does it work the keyboard
How does it work   the keyboardHow does it work   the keyboard
How does it work the keyboard
EU Edge
 
Node webkit-meetup
Node webkit-meetupNode webkit-meetup
Node webkit-meetup
EU Edge
 
Frontend meetup 2014.06.25
Frontend meetup 2014.06.25Frontend meetup 2014.06.25
Frontend meetup 2014.06.25
EU Edge
 
Eu edge intro
Eu edge introEu edge intro
Eu edge intro
EU Edge
 
Halado css eu edge
Halado css   eu edgeHalado css   eu edge
Halado css eu edgeEU Edge
 
Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?EU Edge
 

More from EU Edge (16)

Synchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBSynchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDB
 
How I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-blockHow I learned to Stop Worrying and Love the inline-block
How I learned to Stop Worrying and Love the inline-block
 
Node.js
Node.jsNode.js
Node.js
 
What is python
What is pythonWhat is python
What is python
 
Advanced python
Advanced pythonAdvanced python
Advanced python
 
WebGL
WebGLWebGL
WebGL
 
Python alapu mobil backend
Python alapu mobil backendPython alapu mobil backend
Python alapu mobil backend
 
Res tful services
Res tful servicesRes tful services
Res tful services
 
Google glass a developers perspective
Google glass   a developers perspectiveGoogle glass   a developers perspective
Google glass a developers perspective
 
Google glass ict day presentation
Google glass   ict day presentationGoogle glass   ict day presentation
Google glass ict day presentation
 
How does it work the keyboard
How does it work   the keyboardHow does it work   the keyboard
How does it work the keyboard
 
Node webkit-meetup
Node webkit-meetupNode webkit-meetup
Node webkit-meetup
 
Frontend meetup 2014.06.25
Frontend meetup 2014.06.25Frontend meetup 2014.06.25
Frontend meetup 2014.06.25
 
Eu edge intro
Eu edge introEu edge intro
Eu edge intro
 
Halado css eu edge
Halado css   eu edgeHalado css   eu edge
Halado css eu edge
 
Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?Miért jó oktatóanyagot készíteni?
Miért jó oktatóanyagot készíteni?
 

Recently uploaded

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

Open gl

  • 2. What is OpenGL? ● Standard specification of cross-platform API ● 2D and 3D graphics ● Draw complex 3D scenes built up from primitives ● 1992, SGI
  • 3. What is OpenGL? ● Low-level procedural API (think LOGO) ● “Dictate the exact steps” (vs Scene Graph) ● OpenGL pipeline
  • 4. OpenGL ES ● Designed for embedded systems ● Fixed-point data types ● No glBegin()...glEnd() frames for primitives ● Use vertex arrays instead ● Chosen for WebGL
  • 5. History ● Early 1990s - IRIS GL (SGI), PHIGS (DEC, IBM, Sun) ● 1992 OpenGL Standard Spec ● standardize hardware access ● 1995 Microsoft DirectX ● 2006 Khronos Group controls OpenGL spec
  • 6. Versions ● 1992 1.0 first version ● 1997 1.1 support textures on GPU ● 2004 2.0 GLSL, ARB ● 2008 3.0 (answer to DirectX 10) ● 2010 4.0 ● 2011 4.2
  • 9. ● Command evaluations ○ vertices and attributes ● Per-vertex operations ● Rasterization ○ vertex -> fragment ● Framebuffer operations
  • 11. Lots of things we skip now ● Lighting and Materials ● Textures ● Shading Language ● Clipping, Culling, and Visibility Testing ● etc.
  • 14. #include <GL/gl.h> #include <GL/glut.h> #include <GL/glu.h> int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(800,600); glutCreateWindow("Hello World"); glutDisplayFunc(display); glutMainLoop(); return 0; }
  • 16. Includes on Linux #include <GL/gl.h> #include <GL/glut.h> #include <GL/glu.h> Includes on OS X #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h>
  • 17. Libraries ● OpenGL - basic functionality ● GLU - GL Utility ● GLUT - GL Utility Toolkit
  • 18. OpenGL Utility Library ● Texture mipmaps from base images ● Map coordinates between screen and object space ● Draw quadric surfaces and NURBS
  • 20. OpenGL Utility Toolkit ● Cross-platform tool ● Windowing & input API ● Best for learning OpenGL ● Not open-source
  • 21. glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(800,600); glutCreateWindow("Hello World"); glutDisplayFunc(display); glutMainLoop(); return 0;
  • 23. Explanation ● Init Cube ● Display function ● Clear scene ● Set rotation ● Draw Cube
  • 24. int main(int argc, char *argv[]) { .. // glMatrixMode(GL_PROJECTION); gluPerspective(45, //view angle 1.0, //aspect ratio 10.0, //near clip 200.0);//far clip glMatrixMode(GL_MODELVIEW); // enabe face culling function glEnable(GL_CULL_FACE); initCube(); glutMainLoop(); .. }
  • 25. void display() { ... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0, 0, -50); glRotatef(rotateBy, 1, 1, 0); //rotate by rotateBy degrees about the vector (1,1,0) ... glBegin(GL_QUADS); for (b=0; b<4; b++) { currentVer = cube.quad[a].ver[b]; glColor3fv(cube.ver[ currentVer ].col); glVertex3fv(cube.ver[ currentVer ].pos); } glEnd(); ... }
  • 27. Explanation ● Initialize inline texture data ● Initialize texture subsystem ● Map texture to surface
  • 28. const float texCoords[4][2]= { {0.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {1.0, 0.0} }; UV coordinates
  • 29. // Init texture glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); Initialize texture
  • 30. int display() { ... // enable textures glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); ... } Turn on textures (redraw function)
  • 31. int display() { ... // draw cube for (a=0; a<6; a++) //quads loop { glBegin(GL_QUADS); for (b=0; b<4; b++) //points loop { currentVer = cube.quad[a].ver[b]; //sets the current vertex to this point's vertex // glColor3fv(cube.ver[ currentVer ].col); //changes the colour to the current vertex's colour glTexCoord2fv(texCoords[b]); glVertex3fv(cube.ver[ currentVer ].pos); //draws a vertex at the current vertex's position } glEnd(); } ... }
  • 33. Motivation ● Surface = color + shader ● Vertex colors ● Shaders: FLAT vs SMOOTH ● We want more spectacular look! ● Light sources ● Materials
  • 34. Lights ● Pixel colors are calculated from components below ● Ambient ● Diffuse (‘soft’ lighting) ● Specular (‘hard’ lighting) ● Emission
  • 36.
  • 38. Shading Languages ● Greater flexibility at vertex and fragment level ● OpenGL ARB ● OpenGL GLSL, DirectX HLSL, nVidia Cg, ...
  • 39. Lights ● Pixel colors are calculated from components below ● Ambient ● Diffuse (‘soft’ lighting) ● Specular (‘hard’ lighting) ● Emission
  • 40. Vertex Shader ● Executed when glVertex() / glDrawArrays() called ● vertex, normal transformations ● normalization, rescaling ● lighting, texcoord generation / transformation
  • 41. Fragment Shader ● Operates on every fragments ● Texture access ● Fog
  • 42. Data Types ● vec2, vec3, vec4 ● ivec2, ivec3, ivec4 ● bvec2, bvec3, bvec4 ● mat2, mat3, mat4
  • 43. Input ● Attributes - vertex level, read-only (vertex pos) ● Uniforms - invariant during rendering (light pos, color) ● Varying - used to pass data from vertex shader to ● fragment shader
  • 44. Built-in Types ● Attributes ○ gl_Vertex ○ gl_Normal ○ gl_Color ○ gl_MultiTexCoordX
  • 45. Built-in Types ● Uniforms ○ gl_ModelViewMatrix ○ gl_ModelViewProjectionMatrix ○ gl_NormalMatrix
  • 46. Built-in Types ● Varying ○ gl_FrontColor ○ gl_BackColor ○ gl_TexCoord
  • 47. uniform sampler2D my_color_texture; uniform mat4 my_texture_matrix; varying vec3 vertex_to_light_vector; varying vec3 vertex_to_eye_vector; attribute vec3 tangent; attribute vec3 binormal; Examples
  • 48. void main() { // Transforming The Vertex gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } void main() { // Setting Each Pixel To Red gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } Examples
  • 49. Vertex Shader part varying vec2 texture_coordinate; void main() { // Transforming The Vertex gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; // Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader texture_coordinate = vec2(gl_MultiTexCoord0); } Texture Mapper
  • 50. Fragment Shader part varying vec2 texture_coordinate; uniform sampler2D my_color_texture; void main() { // Sampling The Texture And Passing It To The Frame Buffer gl_FragColor = texture2D(my_color_texture, texture_coordinate); } Texture Mapper