SlideShare a Scribd company logo
WebGL
by Gyuri Horak
What is WebGl?
● JavaScript extension
● based on OpenGL ES 2.0
● Khronos Group (WebGL main site)
● Firefox 4+, Chrome 9+, Safari 5.1+, Opera
12+
● a bit ugly (C+JS)
● tons of helper libraries
The WebGL context
● <canvas>
● gl = canvas.getContext('webgl')
● gl's methods are OpenGL functions:
○ gl.enable(gl.DEPTH_TEST)
● example1
Issues with numbers
● Matrix operations (glUtils.js, sylvester.js)
● JavaScript (Number class) => OpenGL (lot
of types)
var vertices = [
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
];
var squareVerticesBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER,
squareVerticesBuffer);
gl.bufferData(gl.ARRAY_BUFFER,
new Float32Array(vertices),
gl.STATIC_DRAW);
● example2
Shaders
● standard OpenGL shader language
● from plain text
● <script type="x-shader/x-fragment" id="fShader">...
</script>
● passing attributes to shaders:
vertexColorAttribute = gl.getAttribLocation(shaderProgram,
"aVertexColor");
gl.enableVertexAttribArray(vertexColorAttribute);
● example3
Screen update
● setTimeout / setInterval
● better: requestAnimationFrame
● rotate, onclick
● example4
Tree.js
● the most popular lib built on top of WebGL
currently
● source on github (mrdoob/three.js)
● many examples, tutorials
● easy to use, cutomizable boilerplate
● default boilerplate, previous example in
three.js

More Related Content

KEY
明日から使える(?)Rubyトリビア
PDF
Bitcoin:Next
PPTX
MSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JS
PDF
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
PDF
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
PPTX
The jsdom
明日から使える(?)Rubyトリビア
Bitcoin:Next
MSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JS
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
The jsdom

What's hot (13)

PPTX
The State of JavaScript
PPTX
Михаил Матросов, Повседневный С++: boost и STL
PDF
nebulaconf
PPTX
20160415ken.lee
PPTX
Robust C++ Task Systems Through Compile-time Checks
PPTX
Mysql5.1 character set testing
PPTX
Mysql handle socket
PPTX
Compare mysql5.1.50 mysql5.5.8
PPTX
Mastering the MongoDB Javascript Shell
PPTX
c++ boost and STL
PDF
Base2
PPTX
TDD With Typescript - Noam Katzir
PDF
Memory management
The State of JavaScript
Михаил Матросов, Повседневный С++: boost и STL
nebulaconf
20160415ken.lee
Robust C++ Task Systems Through Compile-time Checks
Mysql5.1 character set testing
Mysql handle socket
Compare mysql5.1.50 mysql5.5.8
Mastering the MongoDB Javascript Shell
c++ boost and STL
Base2
TDD With Typescript - Noam Katzir
Memory management
Ad

Viewers also liked (20)

PDF
Node.js
PDF
How does it work the keyboard
PDF
Advanced python
PDF
How I learned to Stop Worrying and Love the inline-block
PDF
Halado css eu edge
PDF
Node webkit-meetup
PDF
Res tful services
PDF
Synchronization with CouchDB and PouchDB
PDF
Open gl
PDF
Google glass a developers perspective
PDF
Google glass ict day presentation
PDF
Python alapu mobil backend
PDF
What is python
PDF
Miért jó oktatóanyagot készíteni?
PDF
Frontend meetup 2013 08-06
PDF
Frontend meetup 2014.06.25
PDF
Mozilla Shumway - opensource meetup budapest
PDF
Budapest New Tech Meetup - WebRTC
PDF
Budapest New Tech Meetup - node-webkit
PDF
Eu edge intro
Node.js
How does it work the keyboard
Advanced python
How I learned to Stop Worrying and Love the inline-block
Halado css eu edge
Node webkit-meetup
Res tful services
Synchronization with CouchDB and PouchDB
Open gl
Google glass a developers perspective
Google glass ict day presentation
Python alapu mobil backend
What is python
Miért jó oktatóanyagot készíteni?
Frontend meetup 2013 08-06
Frontend meetup 2014.06.25
Mozilla Shumway - opensource meetup budapest
Budapest New Tech Meetup - WebRTC
Budapest New Tech Meetup - node-webkit
Eu edge intro
Ad

Similar to WebGL (20)

KEY
Getting Started with WebGL
PPTX
HTML5DevConf 2013 (October): WebGL is a game changer!
PDF
Installing Games Sucks, Learn WebGL
KEY
Leaving Flatland: getting started with WebGL
PDF
140716 : 同業前端聚會分享 - webgl 與 three.js
PDF
Leaving Flatland: Getting Started with WebGL- SXSW 2012
PDF
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
KEY
WebGL Awesomeness
PDF
Creating Applications with WebGL and Three.js
PDF
Webgl para JavaScripters
PDF
WebGL and three.js
PPTX
WebGL: Yesterday, Today, Tomorrow
PDF
WebGL: 3D Graphics for the Web
PPT
WebGL: GPU acceleration for the open web
PPTX
Pocket web gl sk
PDF
The Power of WebGL - Hackeando sua GPU com JavaScript
PPTX
Interactive 3D graphics for web with three.js, Andrey Vedilin, DataArt
PPTX
WebGL - 3D programming
PPTX
Demistifying the 3D Web - part 2
PPTX
OpenGL - Bringing the 3D World into the Android
Getting Started with WebGL
HTML5DevConf 2013 (October): WebGL is a game changer!
Installing Games Sucks, Learn WebGL
Leaving Flatland: getting started with WebGL
140716 : 同業前端聚會分享 - webgl 與 three.js
Leaving Flatland: Getting Started with WebGL- SXSW 2012
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
WebGL Awesomeness
Creating Applications with WebGL and Three.js
Webgl para JavaScripters
WebGL and three.js
WebGL: Yesterday, Today, Tomorrow
WebGL: 3D Graphics for the Web
WebGL: GPU acceleration for the open web
Pocket web gl sk
The Power of WebGL - Hackeando sua GPU com JavaScript
Interactive 3D graphics for web with three.js, Andrey Vedilin, DataArt
WebGL - 3D programming
Demistifying the 3D Web - part 2
OpenGL - Bringing the 3D World into the Android

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation theory and applications.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectroscopy.pptx food analysis technology
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...

WebGL

  • 2. What is WebGl? ● JavaScript extension ● based on OpenGL ES 2.0 ● Khronos Group (WebGL main site) ● Firefox 4+, Chrome 9+, Safari 5.1+, Opera 12+ ● a bit ugly (C+JS) ● tons of helper libraries
  • 3. The WebGL context ● <canvas> ● gl = canvas.getContext('webgl') ● gl's methods are OpenGL functions: ○ gl.enable(gl.DEPTH_TEST) ● example1
  • 4. Issues with numbers ● Matrix operations (glUtils.js, sylvester.js) ● JavaScript (Number class) => OpenGL (lot of types) var vertices = [ 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, -1.0, 0.0 ]; var squareVerticesBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesBuffer); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); ● example2
  • 5. Shaders ● standard OpenGL shader language ● from plain text ● <script type="x-shader/x-fragment" id="fShader">... </script> ● passing attributes to shaders: vertexColorAttribute = gl.getAttribLocation(shaderProgram, "aVertexColor"); gl.enableVertexAttribArray(vertexColorAttribute); ● example3
  • 6. Screen update ● setTimeout / setInterval ● better: requestAnimationFrame ● rotate, onclick ● example4
  • 7. Tree.js ● the most popular lib built on top of WebGL currently ● source on github (mrdoob/three.js) ● many examples, tutorials ● easy to use, cutomizable boilerplate ● default boilerplate, previous example in three.js