SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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 WinterRyu 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 0Oleh Burkhay
 
Vaadin today and tomorrow
Vaadin today and tomorrowVaadin today and tomorrow
Vaadin today and tomorrowJoonas Lehtinen
 
WebGL - 3D in your Browser
WebGL - 3D in your BrowserWebGL - 3D in your Browser
WebGL - 3D in your BrowserPhil Reither
 

La actualidad más candente (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 a PhiloGL - WebGLCamp Google HQs - June 2011

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004Seonki Paik
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 
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 applicationsJeff Durta
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazinedrocallaghan
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webappsHenrik 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 2012philogb
 
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 GebC4Media
 
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 webpjcozzi
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric 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.jsiMasters
 
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. 2011philogb
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developersChris Ramakers
 

Similar a 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
 

Más de 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 visualizationphilogb
 
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 Conferencephilogb
 
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 Twitterphilogb
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitterphilogb
 
#interactives at Twitter
#interactives at Twitter#interactives at Twitter
#interactives at Twitterphilogb
 
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 visualizationphilogb
 
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 - BogotaJSphilogb
 
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 Datosphilogb
 
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 webphilogb
 
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. 2011philogb
 
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 webphilogb
 
JavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit OverviewJavaScript InfoVis Toolkit Overview
JavaScript InfoVis Toolkit Overviewphilogb
 
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 Webphilogb
 

Más de 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
 

Último

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

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