SlideShare a Scribd company logo
PhiloGL
                           A WebGL Framework for
                        data visualization, creative coding
                             and game development




                          Nicolas Garcia Belmonte - June 2011

Friday, June 10, 2011
Friday, June 10, 2011
Data Visualization
                            JavaScript




Friday, June 10, 2011
HTML Document




Friday, June 10, 2011
How most people see a WebGL app:




                                   WebGL Canvas




Friday, June 10, 2011
How I see a WebGL app:


                        Web Workers    File API


                                       Forms

                                       Images
                        WebGL Canvas
                                       Audio

                                        Video

                         2D Canvas      XHR




Friday, June 10, 2011
Examples




Friday, June 10, 2011
PhiloGL


                        • Idiomatic JavaScript
                        • Rich Module System
                        • Flexible and Performance Focused


Friday, June 10, 2011
Idiomatic JavaScript


                            Concise & Expressive




Friday, June 10, 2011
Idiomatic JavaScript


                               Uniforms




Friday, June 10, 2011
Idiomatic JavaScript

             gl.uniform1i
             gl.uniform2i
             gl.uniform3i
             gl.uniform4i
             gl.uniform1f
             gl.uniform2f
                                ?!
                            gl.uniformMatrix1fv
                                                  gl.uniform1iv
                                                  gl.uniform2iv
                                                  gl.uniform3iv
                                                  gl.uniform4iv
                                                  gl.uniform1fv
                                                  gl.uniform2fv
             gl.uniform3f                         gl.uniform3fv
                            gl.uniformMatrix2fv
             gl.uniform4f                         gl.uniform4fv
                            gl.uniformMatrix3fv
                            gl.uniformMatrix4fv


Friday, June 10, 2011
Idiomatic JavaScript


                        program.setUniform(name, value);




Friday, June 10, 2011
Idiomatic JavaScript


                                Buffers




Friday, June 10, 2011
Idiomatic JavaScript
                    //setup part...
                    var positionLocation = gl.getAttribLocation(program,
                    ‘position’);
                    gl.enableVertexAttribArray(positionLocation);
                    var positionBuffer = gl.createBuffer();
                    gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
                    var vertices = [
                        0.0, 1.0, 0.0,
                       -1.0, -1.0, 0.0,
                        1.0, -1.0, 0.0
                    ];
                    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices),
                    gl.STATIC_DRAW);

                    //render part...
                    gl.bindBuffer(gl.ARRAY_BUFFER, position);
                    gl.vertexAttribPointer(positionLocation, 3, gl.FLOAT,
                    false, 0, 0);


Friday, June 10, 2011
Idiomatic JavaScript

                        //setup part...
                        app.setBuffer(‘position’, {
                          size: 3,
                          value: vertices
                        });

                        //render...
                        app.setBuffer(‘position’, true); //bind
                        app.setBuffer(‘position’, false); //unbind




Friday, June 10, 2011
Idiomatic JavaScript


                               Textures




Friday, June 10, 2011
Idiomatic JavaScript
   //setup...
   var texture = gl.createTexture();
   var img = new Image();
   img.onload = function () {
      gl.bindTexture(gl.TEXTURE_2D, texture);
      gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
      gl.bindTexture(gl.TEXTURE_2D, null);
   };
   img.src = "nehe.gif";

   //bind...
   gl.activeTexture(gl.TEXTURE0);
   gl.bindTexture(gl.TEXTURE_2D, texture);



Friday, June 10, 2011
Idiomatic JavaScript

                        PhiloGL.IO.Textures({
                          src: [‘image1.png’, ‘image2.png’, ...],
                          onComplete: function() {
                            app.setTexture(‘image1.png’, true); //bind.
                          }
                        });




Friday, June 10, 2011
Idiomatic JavaScript


                               Programs




Friday, June 10, 2011
Idiomatic JavaScript
              function getShader(gl, id) {
                  var shaderScript = document.getElementById(id);
                  if (!shaderScript) {
                      return null;
                  }

                  var str = "";                                                   Program.fromShaderSources
                  var k = shaderScript.firstChild;
                  while (k) {
                      if (k.nodeType == 3) {
                          str += k.textContent;
                      }
                      k = k.nextSibling;                                          Program.fromShaderURIs
                  }

                  var shader;
                  if (shaderScript.type == "x-shader/x-fragment") {
                      shader = gl.createShader(gl.FRAGMENT_SHADER);
                  } else if (shaderScript.type == "x-shader/x-vertex") {          Program.fromShaderIds
                      shader = gl.createShader(gl.VERTEX_SHADER);
                  } else {
                      return null;
                  }
                  gl.shaderSource(shader, str);
                  gl.compileShader(shader);
                  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
                      alert(gl.getShaderInfoLog(shader));
                      return null;
                  }
                  return shader;
              }

              var shaderProgram;
              function initShaders() {
                  var fragmentShader = getShader(gl, "shader-fs");
                  var vertexShader = getShader(gl, "shader-vs");
                  shaderProgram = gl.createProgram();
                  gl.attachShader(shaderProgram, vertexShader);
                  gl.attachShader(shaderProgram, fragmentShader);
                  gl.linkProgram(shaderProgram);
                  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
                      alert("Could not initialise shaders");
                  }
                  gl.useProgram(shaderProgram);
              }




Friday, June 10, 2011
Idiomatic JavaScript


                               Declarative




Friday, June 10, 2011
Idiomatic JavaScript
                          //Create application
                          PhiloGL('canvasId', {
                            program: {
                               from: 'uris',
                               vs: 'shader.vs.glsl',
                               fs: 'shader.fs.glsl'
                            },
                            camera: {
                               position: {
                                  x: 0, y: 0, z: -50
                               }
                            },
                            textures: {
                               src: ['arroway.jpg', 'earth.jpg']
                            },
                            events: {
                               onDragMove: function(e) {
                                  //do things...
                               },
                               onMouseWheel: function(e) {
                                  //do things...
                               }
                            },
                            onError: function() {
                               alert("There was an error creating the app.");
                            },
                            onLoad: function(app) {
                               /* Do things here */
                            }
                          });
Friday, June 10, 2011
Idiomatic JavaScript
                            app.gl
                            app.canvas
                            app.camera
                            app.scene
                            app.events
                            app.program
                            app.textures
                            app.framebuffers
                            app.renderbuffers


Friday, June 10, 2011
Module System
                            •   Core
                            •   Math
                            •   WebGL
                            •   Program
                            •   Shaders
                            •   O3D
                            •   Camera
                            •   Scene
                            •   Event
                            •   Fx
                            •   IO
                            •   Workers


Friday, June 10, 2011
Module System
                        Math classes have generic methods


                              var v1 = new Vec3(0, 1, 2),
                                  v2 = new Vec3(1, 2, 3);

                              v1.add(v2);

                              //or...
                              Vec3.add(v1, v2);

                              //May just be {x, y, z}




Friday, June 10, 2011
Module System
                                 Workers - Divide & Conquer

                        var workerGroup = new WorkerGroup(‘worker.js’, 10);

                        workerGroup.map(function(i) {
                            //return a worker config
                        });

                        workerGroup.reduce({
                          reduceFn: function(a, b) {
                            //merge worker results
                          }
                        });




Friday, June 10, 2011
Module System
                        Rich and mobile-ready event system

                                  onClick
                                  onRightClick
                                  onTouchStart
                                  onTouchMove
                                  onTouchEnd
                                  onMouseWheel
                                  ...




Friday, June 10, 2011
Module System
                                       XHR and JSONP
           new IO.XHR({
             url: ‘http://some/query/’,

               onError: function() {
                  alert(‘There was an error’);     IO.JSONP({
               },                                    url: ‘http://some/query/’,

               onProgress: function(e) {             callbackKey: ‘fn’,
                  if (e.total) {
                      alert(e.loaded / e.total);     onComplete: function(json) {
                  }                                    //handle data
               },                                    }

               onSuccess: function(data) {         });
                 //handle data
               }

           }).send();
Friday, June 10, 2011
Module System
                                           Tween
                        var fx = new Fx({
                          duration: 1000,
                          transition: Fx.Transition.Back.easeOut,

                         onCompute: function(delta) {
                           obj.height = Fx.compute(from, to, delta);
                         },

                          onComplete: function() {
                            alert(‘done!’);
                          }
                        });

                           Fx.requestAnimationFrame
Friday, June 10, 2011
Other Examples




Friday, June 10, 2011
Complete documentation and examples.




Friday, June 10, 2011
Thanks :)

                                    Project page:
                        http://senchalabs.github.com/philogl/



                        Twitter:                    Home page:
                        @philogb          http://philogb.github.com/

Friday, June 10, 2011

More Related Content

What's hot

Huahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
Huahin Framework for Hadoop, Hadoop Conference Japan 2013 WinterHuahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
Huahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
Ryu Kobayashi
 
クラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャクラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャ
Tomoharu ASAMI
 
Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0
Oleh Burkhay
 
Vaadin today and tomorrow
Vaadin today and tomorrowVaadin today and tomorrow
Vaadin today and tomorrow
Joonas Lehtinen
 
WebGL - 3D in your Browser
WebGL - 3D in your BrowserWebGL - 3D in your Browser
WebGL - 3D in your Browser
Phil Reither
 
Inside jQuery (2011)
Inside jQuery (2011)Inside jQuery (2011)
Inside jQuery (2011)
Kenneth Auchenberg
 

What's hot (6)

Huahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
Huahin Framework for Hadoop, Hadoop Conference Japan 2013 WinterHuahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
Huahin Framework for Hadoop, Hadoop Conference Japan 2013 Winter
 
クラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャクラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャ
 
Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0
 
Vaadin today and tomorrow
Vaadin today and tomorrowVaadin today and tomorrow
Vaadin today and tomorrow
 
WebGL - 3D in your Browser
WebGL - 3D in your BrowserWebGL - 3D in your Browser
WebGL - 3D in your Browser
 
Inside jQuery (2011)
Inside jQuery (2011)Inside jQuery (2011)
Inside jQuery (2011)
 

Similar to PhiloGL - WebGLCamp Google HQs - June 2011

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
Ravi Mone
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004
Seonki Paik
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
gerbille
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
Matt Hirsch - MIT Media Lab
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
Chihoon Byun
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazine
drocallaghan
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
gerbille
 
Bottom Up
Bottom UpBottom Up
Bottom Up
Brian Moschel
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webapps
Henrik Joreteg
 
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
philogb
 
Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
C4Media
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
pjcozzi
 
Deep dive into Oracle ADF
Deep dive into Oracle ADFDeep dive into Oracle ADF
Deep dive into Oracle ADF
Euegene Fedorenko
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
Eric Weimer
 
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.jsJS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
iMasters
 
New Tools for Visualization in JavaScript - Sept. 2011
New Tools for Visualization in JavaScript - Sept. 2011New Tools for Visualization in JavaScript - Sept. 2011
New Tools for Visualization in JavaScript - Sept. 2011
philogb
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
Chris Ramakers
 

Similar to PhiloGL - WebGLCamp Google HQs - June 2011 (20)

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazine
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
Bottom Up
Bottom UpBottom Up
Bottom Up
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webapps
 
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
 
Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
Deep dive into Oracle ADF
Deep dive into Oracle ADFDeep dive into Oracle ADF
Deep dive into Oracle ADF
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.jsJS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
 
New Tools for Visualization in JavaScript - Sept. 2011
New Tools for Visualization in JavaScript - Sept. 2011New Tools for Visualization in JavaScript - Sept. 2011
New Tools for Visualization in JavaScript - Sept. 2011
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 

More from philogb

OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualization
philogb
 
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
philogb
 
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
philogb
 
The Geography of Tweets - BBC Developer Conference
The Geography of Tweets - BBC Developer ConferenceThe Geography of Tweets - BBC Developer Conference
The Geography of Tweets - BBC Developer Conference
philogb
 
Hacking public-facing data visualizations at Twitter
Hacking public-facing data visualizations at TwitterHacking public-facing data visualizations at Twitter
Hacking public-facing data visualizations at Twitter
philogb
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitter
philogb
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitter
philogb
 
La visualisation de données comme outil pour découvrir et partager des idées ...
La visualisation de données comme outil pour découvrir et partager des idées ...La visualisation de données comme outil pour découvrir et partager des idées ...
La visualisation de données comme outil pour découvrir et partager des idées ...
philogb
 
Exploring Web standards for data visualization
Exploring Web standards for data visualizationExploring Web standards for data visualization
Exploring Web standards for data visualization
philogb
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
philogb
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
philogb
 
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
InfoVis para la Web: Teoria, Herramientas y Ejemplos.InfoVis para la Web: Teoria, Herramientas y Ejemplos.
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
philogb
 
Una web todos los dispositivos.
Una web todos los dispositivos.Una web todos los dispositivos.
Una web todos los dispositivos.
philogb
 
Nuevas herramientas de visualizacion en JavaScript
Nuevas herramientas de visualizacion en JavaScript Nuevas herramientas de visualizacion en JavaScript
Nuevas herramientas de visualizacion en JavaScript
philogb
 
Data visualization for the web
Data visualization for the webData visualization for the web
Data visualization for the web
philogb
 
Principles of Analytical Design - Visually Meetup - Sept. 2011
Principles of Analytical Design - Visually Meetup - Sept. 2011Principles of Analytical Design - Visually Meetup - Sept. 2011
Principles of Analytical Design - Visually Meetup - Sept. 2011
philogb
 
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
philogb
 
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
JavaScript InfoVis Toolkit - Create interactive data visualizations for the webJavaScript InfoVis Toolkit - Create interactive data visualizations for the web
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
philogb
 
JavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit OverviewJavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit Overview
philogb
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
philogb
 

More from philogb (20)

OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualization
 
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
 
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
 
The Geography of Tweets - BBC Developer Conference
The Geography of Tweets - BBC Developer ConferenceThe Geography of Tweets - BBC Developer Conference
The Geography of Tweets - BBC Developer Conference
 
Hacking public-facing data visualizations at Twitter
Hacking public-facing data visualizations at TwitterHacking public-facing data visualizations at Twitter
Hacking public-facing data visualizations at Twitter
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitter
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitter
 
La visualisation de données comme outil pour découvrir et partager des idées ...
La visualisation de données comme outil pour découvrir et partager des idées ...La visualisation de données comme outil pour découvrir et partager des idées ...
La visualisation de données comme outil pour découvrir et partager des idées ...
 
Exploring Web standards for data visualization
Exploring Web standards for data visualizationExploring Web standards for data visualization
Exploring Web standards for data visualization
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
InfoVis para la Web: Teoria, Herramientas y Ejemplos.InfoVis para la Web: Teoria, Herramientas y Ejemplos.
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
 
Una web todos los dispositivos.
Una web todos los dispositivos.Una web todos los dispositivos.
Una web todos los dispositivos.
 
Nuevas herramientas de visualizacion en JavaScript
Nuevas herramientas de visualizacion en JavaScript Nuevas herramientas de visualizacion en JavaScript
Nuevas herramientas de visualizacion en JavaScript
 
Data visualization for the web
Data visualization for the webData visualization for the web
Data visualization for the web
 
Principles of Analytical Design - Visually Meetup - Sept. 2011
Principles of Analytical Design - Visually Meetup - Sept. 2011Principles of Analytical Design - Visually Meetup - Sept. 2011
Principles of Analytical Design - Visually Meetup - Sept. 2011
 
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
 
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
JavaScript InfoVis Toolkit - Create interactive data visualizations for the webJavaScript InfoVis Toolkit - Create interactive data visualizations for the web
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
 
JavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit OverviewJavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit Overview
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
 

Recently uploaded

Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
AlexanderRichford
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 

Recently uploaded (20)

Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 

PhiloGL - WebGLCamp Google HQs - June 2011

  • 1. PhiloGL A WebGL Framework for data visualization, creative coding and game development Nicolas Garcia Belmonte - June 2011 Friday, June 10, 2011
  • 3. Data Visualization JavaScript Friday, June 10, 2011
  • 5. How most people see a WebGL app: WebGL Canvas Friday, June 10, 2011
  • 6. How I see a WebGL app: Web Workers File API Forms Images WebGL Canvas Audio Video 2D Canvas XHR Friday, June 10, 2011
  • 8. PhiloGL • Idiomatic JavaScript • Rich Module System • Flexible and Performance Focused Friday, June 10, 2011
  • 9. Idiomatic JavaScript Concise & Expressive Friday, June 10, 2011
  • 10. Idiomatic JavaScript Uniforms Friday, June 10, 2011
  • 11. Idiomatic JavaScript gl.uniform1i gl.uniform2i gl.uniform3i gl.uniform4i gl.uniform1f gl.uniform2f ?! gl.uniformMatrix1fv gl.uniform1iv gl.uniform2iv gl.uniform3iv gl.uniform4iv gl.uniform1fv gl.uniform2fv gl.uniform3f gl.uniform3fv gl.uniformMatrix2fv gl.uniform4f gl.uniform4fv gl.uniformMatrix3fv gl.uniformMatrix4fv Friday, June 10, 2011
  • 12. Idiomatic JavaScript program.setUniform(name, value); Friday, June 10, 2011
  • 13. Idiomatic JavaScript Buffers Friday, June 10, 2011
  • 14. Idiomatic JavaScript //setup part... var positionLocation = gl.getAttribLocation(program, ‘position’); gl.enableVertexAttribArray(positionLocation); var positionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); //render part... gl.bindBuffer(gl.ARRAY_BUFFER, position); gl.vertexAttribPointer(positionLocation, 3, gl.FLOAT, false, 0, 0); Friday, June 10, 2011
  • 15. Idiomatic JavaScript //setup part... app.setBuffer(‘position’, { size: 3, value: vertices }); //render... app.setBuffer(‘position’, true); //bind app.setBuffer(‘position’, false); //unbind Friday, June 10, 2011
  • 16. Idiomatic JavaScript Textures Friday, June 10, 2011
  • 17. Idiomatic JavaScript //setup... var texture = gl.createTexture(); var img = new Image(); img.onload = function () { gl.bindTexture(gl.TEXTURE_2D, texture); gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.bindTexture(gl.TEXTURE_2D, null); }; img.src = "nehe.gif"; //bind... gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, texture); Friday, June 10, 2011
  • 18. Idiomatic JavaScript PhiloGL.IO.Textures({ src: [‘image1.png’, ‘image2.png’, ...], onComplete: function() { app.setTexture(‘image1.png’, true); //bind. } }); Friday, June 10, 2011
  • 19. Idiomatic JavaScript Programs Friday, June 10, 2011
  • 20. Idiomatic JavaScript function getShader(gl, id) { var shaderScript = document.getElementById(id); if (!shaderScript) { return null; } var str = ""; Program.fromShaderSources var k = shaderScript.firstChild; while (k) { if (k.nodeType == 3) { str += k.textContent; } k = k.nextSibling; Program.fromShaderURIs } var shader; if (shaderScript.type == "x-shader/x-fragment") { shader = gl.createShader(gl.FRAGMENT_SHADER); } else if (shaderScript.type == "x-shader/x-vertex") { Program.fromShaderIds shader = gl.createShader(gl.VERTEX_SHADER); } else { return null; } gl.shaderSource(shader, str); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { alert(gl.getShaderInfoLog(shader)); return null; } return shader; } var shaderProgram; function initShaders() { var fragmentShader = getShader(gl, "shader-fs"); var vertexShader = getShader(gl, "shader-vs"); shaderProgram = gl.createProgram(); gl.attachShader(shaderProgram, vertexShader); gl.attachShader(shaderProgram, fragmentShader); gl.linkProgram(shaderProgram); if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { alert("Could not initialise shaders"); } gl.useProgram(shaderProgram); } Friday, June 10, 2011
  • 21. Idiomatic JavaScript Declarative Friday, June 10, 2011
  • 22. Idiomatic JavaScript //Create application PhiloGL('canvasId', { program: { from: 'uris', vs: 'shader.vs.glsl', fs: 'shader.fs.glsl' }, camera: { position: { x: 0, y: 0, z: -50 } }, textures: { src: ['arroway.jpg', 'earth.jpg'] }, events: { onDragMove: function(e) { //do things... }, onMouseWheel: function(e) { //do things... } }, onError: function() { alert("There was an error creating the app."); }, onLoad: function(app) { /* Do things here */ } }); Friday, June 10, 2011
  • 23. Idiomatic JavaScript app.gl app.canvas app.camera app.scene app.events app.program app.textures app.framebuffers app.renderbuffers Friday, June 10, 2011
  • 24. Module System • Core • Math • WebGL • Program • Shaders • O3D • Camera • Scene • Event • Fx • IO • Workers Friday, June 10, 2011
  • 25. Module System Math classes have generic methods var v1 = new Vec3(0, 1, 2), v2 = new Vec3(1, 2, 3); v1.add(v2); //or... Vec3.add(v1, v2); //May just be {x, y, z} Friday, June 10, 2011
  • 26. Module System Workers - Divide & Conquer var workerGroup = new WorkerGroup(‘worker.js’, 10); workerGroup.map(function(i) { //return a worker config }); workerGroup.reduce({ reduceFn: function(a, b) { //merge worker results } }); Friday, June 10, 2011
  • 27. Module System Rich and mobile-ready event system onClick onRightClick onTouchStart onTouchMove onTouchEnd onMouseWheel ... Friday, June 10, 2011
  • 28. Module System XHR and JSONP new IO.XHR({ url: ‘http://some/query/’, onError: function() { alert(‘There was an error’); IO.JSONP({ }, url: ‘http://some/query/’, onProgress: function(e) { callbackKey: ‘fn’, if (e.total) { alert(e.loaded / e.total); onComplete: function(json) { } //handle data }, } onSuccess: function(data) { }); //handle data } }).send(); Friday, June 10, 2011
  • 29. Module System Tween var fx = new Fx({ duration: 1000, transition: Fx.Transition.Back.easeOut, onCompute: function(delta) { obj.height = Fx.compute(from, to, delta); }, onComplete: function() { alert(‘done!’); } }); Fx.requestAnimationFrame Friday, June 10, 2011
  • 31. Complete documentation and examples. Friday, June 10, 2011
  • 32. Thanks :) Project page: http://senchalabs.github.com/philogl/ Twitter: Home page: @philogb http://philogb.github.com/ Friday, June 10, 2011