SlideShare a Scribd company logo
1 of 19
Download to read offline
Unconventional webapps with
  GWT/Elemental, WebRTC &
          WebGL
                     Alberto Mancini
                   alberto@jooink.com

Blog: http://jooink.blogspot.com

Online Demo:
      http://www.jooink.com/experiments/DevFest2012
GWT 2.5 Elemental

Elemental is a new library for fast, lightweight,
and "to the metal" web programming in GWT.

Elemental includes every HTML5 feature, ... DOM access
... WebGL, WebAudio, WebSockets, WebRTC, Web
Intents, Shadow DOM, the File API, and more.
... we generate Java code directly from the WebIDL files
used by JavaScript engines. (like DART)
Unconventional


... insomma qualcosa che non ci sembrava
possibile fare con il solo browser, tipo accedere
a devices attaccati al 'client', una webcam
per esempio.



L'idea e' farsi una foto ...
WebRTC

WebRTC (Web Real-Time Communication) is an API
definition being drafted by W3C and IETF.

The goal of WebRTC is to enable applications such as
voice calling, video chat and P2P file sharing without
plugins.

Specification & Up to date info: http://www.webrtc.org

Support:   Chrome 22+, ... well work-in-progress at least for firefox.


what we need: getUserMedia (chrome !!)
WebRTC (with Elemental)
Video in a canvas
     final VideoElement videoElement =
                        Browser.getDocument().createVideoElement();
    final CanvasElement canvas =
                        Browser.getDocument().createCanvasElement();
    final CanvasRenderingContext2D ctx2d =
              (CanvasRenderingContext2D)canvas.getContext("2d");
       ...
      //repeatedly, e.g. in a Timer or RepeatingCommand
      ctx2d.drawImage(videoElement, 0, 0);

Take snapshot as easy as:
    Image img = new Image(canvas.toDataURL("png"));
WebRTC (with Elemental)
binding <video/> to userMedia (search for facelogin on googlecode)
public void
 bindVideoToUserMedia(final VideoElement video, final EventListener l) {
      final Mappable map = (Mappable) JsMappable.createObject();
      map.setAt("video", true);
      Browser.getWindow().getNavigator().webkitGetUserMedia(map,
                 new NavigatorUserMediaSuccessCallback() {
                             public boolean onNavigatorUserMediaSuccessCallback
                                                     (LocalMediaStream stream) {
                                         setVideoSrc(video, stream);
                                         video.play(); ...
      }, new NavigatorUserMediaErrorCallback() {...});
  }

private static native void setVideoSrc( VideoElement v, LocalMediaStream s) /*-{
      v.src = window.webkitURL.createObjectURL(s);
}-*/;
WebGL
WebGL (Web Graphics Library) is a JavaScript API for
rendering interactive 3D graphics and 2D graphics within
any compatible web browser without the use of plug-ins.

Specification: http://www.khronos.org/webgl/

Support: http://caniuse.com/webgl



Chrome 22+, FireFox 15+, Safari 6+, Opera 12+ (partial)
WebGL (with Elemental)
Video in a canvas (3d rendering context)
  ...
  WebGLRenderingContext ctx3d =
        (WebGLRenderingContext)canvas.getContext("experimental-webgl");

Drawing is a bit harder:
  create a texture, create a background rectangle,
  use the video as a texture
  ctx3d.texImage2D(WebGLRenderingContext.TEXTURE_2D, 0,
        WebGLRenderingContext.RGBA, WebGLRenderingContext.RGBA,
          WebGLRenderingContext.UNSIGNED_BYTE, videoElement);
WebGL (with Elemental)
  shaders

Vertex Shader                                          Fragment Shader

precision mediump float;                               precision mediump float;
attribute vec2 a_position;                             uniform sampler2D u_image;
attribute vec2 a_texCoord;                             varying vec2 v_texCoord;
uniform vec2 u_resolution;
varying vec2 v_texCoord;                               void main() {
void main() {                                            gl_FragColor =
  vec2 zeroToOne = a_position / u_resolution;                texture2D(u_image, v_texCoord);
  vec2 zeroToTwo = zeroToOne * 2.0;                    }
  vec2 clipSpace = zeroToTwo - 1.0;
  gl_Position = vec4(clipSpace * vec2(1, -1), 1, 1);
  v_texCoord = a_texCoord;
}




             from html5rocks.com's WebGL Fundamentals ... probably :o
WebGL (with Elemental)
  shaders

Fragment Shader                                        Fragment Shader
...
// Sepia tone                                          precision mediump float;
// Convert to greyscale using NTSC weightings          uniform sampler2D u_image;
   float grey = dot(texture2D(u_image,                 uniform sampler2D SECOND_u_image;
       v_texCoord).rgb, vec3(0.299, 0.587, 0.114));    uniform float alpha;
   gl_FragColor =                                      varying vec2 v_texCoord;
       vec4(grey * vec3(1.2, 1.0, 0.8), 1.0);           void main(void) {
...                                                      vec4 prev = texture2D(SECOND_u_image,
// Negative                                                      vec2(v_texCoord.s,1.0-v_texCoord.t));
 vec4 texColour =                                        vec4 cur = texture2D(u_image, v_texCoord);
      texture2D(u_image, v_texCoord);                    gl_FragColor = alpha*prev + (1.0-alpha)*cur;
 gl_FragColor = vec4(1.0 - texColour.rgb, 1.0);        }




from http://r3dux.org/2011/06/glsl-image-processing/
WebGL (with Elemental)
  3D


WebGL e' una libreria 2D !!

Trasformazioni prospettiche (proiezioni), frustum, modelview
vanno implementate.

VertexShader: applichera' le trasformazioni (matrici) che noi gli
forniremo, vertice per vertice

FragmentShader: usera', pixel-per-pixel, le informazioni
calcolate vertice-per-vertice (ed interpolate dal 'sistema')
per assegnare il colore
WebGL (with Elemental)
    3D


double a = (right + left) / (right - left);
double b = (top + bottom) / (top - bottom);
double c = (farPlane + nearPlane) / (farPlane - nearPlane);
double d = (2 * farPlane * nearPlane) / (farPlane - nearPlane);
double x = (2 * nearPlane) / (right - left);
double y = (2 * nearPlane) / (top - bottom);
double[] perspectiveMatrix = new double[]{
     x, 0, a, 0,
     0, y, b, 0,
     0, 0, c, d,
     0, 0, -1, 0
 };


....
ctx3d.uniformMatrix4fv(pMatrixUniform, false, Utilities.createArrayOfFloat32(perspectiveMatrix));
...
private native static Float32Array createFloat32Array(JsArrayOfNumber a) /*-{
       return new Float32Array(a);
}-*/;
WebGL (with Elemental)
  3D/Wavefront-OBJ


Loading Wavefront-obj files ...

parser in java facile da trovare in rete


ClientBundle DataResource perfetto per il loading
asincrono dei modelli


Javascript per calcolare le normali se non sono nel
modello
Unconventional

Tutto quello che abbiamo visto fino ad ora si poteva fare,
probabilmente con lo stesso sforzo, direttamente in javascript.



  Ma usare GWT ci da o no una marcia in piu' ?



Nota:
non stiamo dicendo che quello che segue non si potesse fare in
javascript, ndr: Turing completeness, se ce ne fosse bisogno !
GWT



Compiler: Java -> Javascript


Javascript as a target language
NyARToolkit

ARToolKit is a computer tracking library for creation of strong augmented
reality applications that overlay virtual imagery on the real world.
NyARToolKit is an ARToolkit class library released for virtual machines,
particularly those that host Java, C# and Android.

Up to date info
http://nyatla.jp/nyartoolkit/wp/?page_id=198


Support:
Java ... "Write once, run anywhere" (WORA), or sometimes write once, run
everywhere (WORE) ... in my browser ?!?!?!
NyARToolkit con GWT
http://jooink.blogpsot.com
super-source tag
per InputStream & altre parti della JRE non disponibili in GWT

byte[] raster;
UInt8ClampedArray image = ImageData.getData();
private static native byte[] toArrayOfBytes(Uint8ClampedArray a) /*-{
   return a;
}-*/;



Documented in JAPANESE !!!
How It Works



   cam    WebRTC      <video/>
                                 canvas    ImageData




                                                   Elemental/jsni
               WebGL + model
  video




                        GWT(NyARToolkit)      byte[]
          mv matrix
Demo http://www.jooink.com/experiments/DevFest2012

More Related Content

What's hot

OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-timeJohan Thelin
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Johan Thelin
 
NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)Igalia
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key conceptsICS
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? ICS
 
Back from BUILD - WebGL
Back from BUILD -  WebGLBack from BUILD -  WebGL
Back from BUILD - WebGLdavrous
 
Multimedia in WebKitGtk+, past/present/future
Multimedia in WebKitGtk+, past/present/futureMultimedia in WebKitGtk+, past/present/future
Multimedia in WebKitGtk+, past/present/futurephiln2
 
WebKit and GStreamer
WebKit and GStreamerWebKit and GStreamer
WebKit and GStreamercalvaris
 
Petri Niemi Qt Web Kit
Petri Niemi Qt Web KitPetri Niemi Qt Web Kit
Petri Niemi Qt Web KitNokiaAppForum
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the expertsICS
 
WebKit, HTML5 media and GStreamer on multiple platforms
WebKit, HTML5 media and GStreamer on multiple platforms WebKit, HTML5 media and GStreamer on multiple platforms
WebKit, HTML5 media and GStreamer on multiple platforms philn2
 
WPE WebKit for Android
WPE WebKit for AndroidWPE WebKit for Android
WPE WebKit for AndroidIgalia
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKitAriya Hidayat
 
Qt Multiplatform development
Qt Multiplatform developmentQt Multiplatform development
Qt Multiplatform developmentSergio Shevchenko
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JSFestUA
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...Vitalii Kukhar
 
Ultrasound Image Viewer - Qt + SGX
Ultrasound Image Viewer - Qt + SGXUltrasound Image Viewer - Qt + SGX
Ultrasound Image Viewer - Qt + SGXPrabindh Sundareson
 
Async await in C++
Async await in C++Async await in C++
Async await in C++cppfrug
 
GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?philn2
 

What's hot (20)

OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-time
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011
 
NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
Back from BUILD - WebGL
Back from BUILD -  WebGLBack from BUILD -  WebGL
Back from BUILD - WebGL
 
Multimedia in WebKitGtk+, past/present/future
Multimedia in WebKitGtk+, past/present/futureMultimedia in WebKitGtk+, past/present/future
Multimedia in WebKitGtk+, past/present/future
 
WebKit and GStreamer
WebKit and GStreamerWebKit and GStreamer
WebKit and GStreamer
 
Petri Niemi Qt Web Kit
Petri Niemi Qt Web KitPetri Niemi Qt Web Kit
Petri Niemi Qt Web Kit
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
WebKit, HTML5 media and GStreamer on multiple platforms
WebKit, HTML5 media and GStreamer on multiple platforms WebKit, HTML5 media and GStreamer on multiple platforms
WebKit, HTML5 media and GStreamer on multiple platforms
 
WPE WebKit for Android
WPE WebKit for AndroidWPE WebKit for Android
WPE WebKit for Android
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
 
Qt Multiplatform development
Qt Multiplatform developmentQt Multiplatform development
Qt Multiplatform development
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
 
Ultrasound Image Viewer - Qt + SGX
Ultrasound Image Viewer - Qt + SGXUltrasound Image Viewer - Qt + SGX
Ultrasound Image Viewer - Qt + SGX
 
Async await in C++
Async await in C++Async await in C++
Async await in C++
 
GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?
 

Similar to Unconventional webapps with GWT/Elemental, WebRTC & WebGL

Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
Building Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter LuhBuilding Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter LuhFITC
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Takao Wada
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slidestamillarasan
 
How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?Flutter Agency
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGLTony Parisi
 
The next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRThe next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRCodemotion
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
GL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfGL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfshaikhshehzad024
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not FlashThomas Fuchs
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
Game development with_lib_gdx
Game development with_lib_gdxGame development with_lib_gdx
Game development with_lib_gdxGabriel Grill
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
OpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering TechniquesOpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering TechniquesNarann29
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?Ankara JUG
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer ToolsMark Billinghurst
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLDouglass Turner
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010Chris Ramsdale
 

Similar to Unconventional webapps with GWT/Elemental, WebRTC & WebGL (20)

Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
COLLADA & WebGL
COLLADA & WebGLCOLLADA & WebGL
COLLADA & WebGL
 
Building Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter LuhBuilding Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slides
 
How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGL
 
The next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRThe next frontier: WebGL and WebVR
The next frontier: WebGL and WebVR
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
GL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdfGL Shading Language Document by OpenGL.pdf
GL Shading Language Document by OpenGL.pdf
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Game development with_lib_gdx
Game development with_lib_gdxGame development with_lib_gdx
Game development with_lib_gdx
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
OpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering TechniquesOpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering Techniques
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSL
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 

More from firenze-gtug

Html5 apps - GWT oriented
Html5 apps - GWT orientedHtml5 apps - GWT oriented
Html5 apps - GWT orientedfirenze-gtug
 
Android ndk - ottimizzazione su dispositivi Intel
Android ndk - ottimizzazione su dispositivi IntelAndroid ndk - ottimizzazione su dispositivi Intel
Android ndk - ottimizzazione su dispositivi Intelfirenze-gtug
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca TosiGwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca Tosifirenze-gtug
 
Youtube broadcast live - Massimiliano D'Ambrosio
Youtube broadcast live - Massimiliano D'AmbrosioYoutube broadcast live - Massimiliano D'Ambrosio
Youtube broadcast live - Massimiliano D'Ambrosiofirenze-gtug
 
Intro BeagleBone Black - Massimiliano D'Ambrosio
Intro BeagleBone Black - Massimiliano D'AmbrosioIntro BeagleBone Black - Massimiliano D'Ambrosio
Intro BeagleBone Black - Massimiliano D'Ambrosiofirenze-gtug
 
Arduino - Massimiliano D'Ambrosio
Arduino - Massimiliano D'AmbrosioArduino - Massimiliano D'Ambrosio
Arduino - Massimiliano D'Ambrosiofirenze-gtug
 
Introduzione a GAE - Alessandro Aglietti e Lorenzo Bugiani
Introduzione a GAE - Alessandro Aglietti e Lorenzo BugianiIntroduzione a GAE - Alessandro Aglietti e Lorenzo Bugiani
Introduzione a GAE - Alessandro Aglietti e Lorenzo Bugianifirenze-gtug
 
RFID: What & Why - Stefano Coluccini
RFID: What & Why - Stefano ColucciniRFID: What & Why - Stefano Coluccini
RFID: What & Why - Stefano Coluccinifirenze-gtug
 
GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)firenze-gtug
 
Presentazione Google App Engine
Presentazione Google App EnginePresentazione Google App Engine
Presentazione Google App Enginefirenze-gtug
 
Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloudfirenze-gtug
 
Clean android code
Clean android codeClean android code
Clean android codefirenze-gtug
 
Intel ndk - a few Benchmarks
Intel ndk - a few BenchmarksIntel ndk - a few Benchmarks
Intel ndk - a few Benchmarksfirenze-gtug
 
EE Incremental Store
EE Incremental StoreEE Incremental Store
EE Incremental Storefirenze-gtug
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with androidfirenze-gtug
 
Apertura "Mobile & Embedded" - 13 febbraio 2014
Apertura "Mobile & Embedded" - 13 febbraio 2014Apertura "Mobile & Embedded" - 13 febbraio 2014
Apertura "Mobile & Embedded" - 13 febbraio 2014firenze-gtug
 
Maven from dummies
Maven from dummiesMaven from dummies
Maven from dummiesfirenze-gtug
 
Dev fest android application case study
Dev fest android application   case studyDev fest android application   case study
Dev fest android application case studyfirenze-gtug
 

More from firenze-gtug (20)

Html5 apps - GWT oriented
Html5 apps - GWT orientedHtml5 apps - GWT oriented
Html5 apps - GWT oriented
 
Android ndk - ottimizzazione su dispositivi Intel
Android ndk - ottimizzazione su dispositivi IntelAndroid ndk - ottimizzazione su dispositivi Intel
Android ndk - ottimizzazione su dispositivi Intel
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca TosiGwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca Tosi
 
Youtube broadcast live - Massimiliano D'Ambrosio
Youtube broadcast live - Massimiliano D'AmbrosioYoutube broadcast live - Massimiliano D'Ambrosio
Youtube broadcast live - Massimiliano D'Ambrosio
 
Intro BeagleBone Black - Massimiliano D'Ambrosio
Intro BeagleBone Black - Massimiliano D'AmbrosioIntro BeagleBone Black - Massimiliano D'Ambrosio
Intro BeagleBone Black - Massimiliano D'Ambrosio
 
Arduino - Massimiliano D'Ambrosio
Arduino - Massimiliano D'AmbrosioArduino - Massimiliano D'Ambrosio
Arduino - Massimiliano D'Ambrosio
 
Introduzione a GAE - Alessandro Aglietti e Lorenzo Bugiani
Introduzione a GAE - Alessandro Aglietti e Lorenzo BugianiIntroduzione a GAE - Alessandro Aglietti e Lorenzo Bugiani
Introduzione a GAE - Alessandro Aglietti e Lorenzo Bugiani
 
RFID: What & Why - Stefano Coluccini
RFID: What & Why - Stefano ColucciniRFID: What & Why - Stefano Coluccini
RFID: What & Why - Stefano Coluccini
 
GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)
 
Presentazione Google App Engine
Presentazione Google App EnginePresentazione Google App Engine
Presentazione Google App Engine
 
Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloud
 
Clean android code
Clean android codeClean android code
Clean android code
 
#Html2Native
#Html2Native#Html2Native
#Html2Native
 
Intel ndk - a few Benchmarks
Intel ndk - a few BenchmarksIntel ndk - a few Benchmarks
Intel ndk - a few Benchmarks
 
EE Incremental Store
EE Incremental StoreEE Incremental Store
EE Incremental Store
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with android
 
Apertura "Mobile & Embedded" - 13 febbraio 2014
Apertura "Mobile & Embedded" - 13 febbraio 2014Apertura "Mobile & Embedded" - 13 febbraio 2014
Apertura "Mobile & Embedded" - 13 febbraio 2014
 
Maven from dummies
Maven from dummiesMaven from dummies
Maven from dummies
 
Apps fuel oct2012
Apps fuel oct2012Apps fuel oct2012
Apps fuel oct2012
 
Dev fest android application case study
Dev fest android application   case studyDev fest android application   case study
Dev fest android application case study
 

Recently uploaded

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Unconventional webapps with GWT/Elemental, WebRTC & WebGL

  • 1. Unconventional webapps with GWT/Elemental, WebRTC & WebGL Alberto Mancini alberto@jooink.com Blog: http://jooink.blogspot.com Online Demo: http://www.jooink.com/experiments/DevFest2012
  • 2. GWT 2.5 Elemental Elemental is a new library for fast, lightweight, and "to the metal" web programming in GWT. Elemental includes every HTML5 feature, ... DOM access ... WebGL, WebAudio, WebSockets, WebRTC, Web Intents, Shadow DOM, the File API, and more. ... we generate Java code directly from the WebIDL files used by JavaScript engines. (like DART)
  • 3. Unconventional ... insomma qualcosa che non ci sembrava possibile fare con il solo browser, tipo accedere a devices attaccati al 'client', una webcam per esempio. L'idea e' farsi una foto ...
  • 4. WebRTC WebRTC (Web Real-Time Communication) is an API definition being drafted by W3C and IETF. The goal of WebRTC is to enable applications such as voice calling, video chat and P2P file sharing without plugins. Specification & Up to date info: http://www.webrtc.org Support: Chrome 22+, ... well work-in-progress at least for firefox. what we need: getUserMedia (chrome !!)
  • 5. WebRTC (with Elemental) Video in a canvas final VideoElement videoElement = Browser.getDocument().createVideoElement(); final CanvasElement canvas = Browser.getDocument().createCanvasElement(); final CanvasRenderingContext2D ctx2d = (CanvasRenderingContext2D)canvas.getContext("2d"); ... //repeatedly, e.g. in a Timer or RepeatingCommand ctx2d.drawImage(videoElement, 0, 0); Take snapshot as easy as: Image img = new Image(canvas.toDataURL("png"));
  • 6. WebRTC (with Elemental) binding <video/> to userMedia (search for facelogin on googlecode) public void bindVideoToUserMedia(final VideoElement video, final EventListener l) { final Mappable map = (Mappable) JsMappable.createObject(); map.setAt("video", true); Browser.getWindow().getNavigator().webkitGetUserMedia(map, new NavigatorUserMediaSuccessCallback() { public boolean onNavigatorUserMediaSuccessCallback (LocalMediaStream stream) { setVideoSrc(video, stream); video.play(); ... }, new NavigatorUserMediaErrorCallback() {...}); } private static native void setVideoSrc( VideoElement v, LocalMediaStream s) /*-{ v.src = window.webkitURL.createObjectURL(s); }-*/;
  • 7. WebGL WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 3D graphics and 2D graphics within any compatible web browser without the use of plug-ins. Specification: http://www.khronos.org/webgl/ Support: http://caniuse.com/webgl Chrome 22+, FireFox 15+, Safari 6+, Opera 12+ (partial)
  • 8. WebGL (with Elemental) Video in a canvas (3d rendering context) ... WebGLRenderingContext ctx3d = (WebGLRenderingContext)canvas.getContext("experimental-webgl"); Drawing is a bit harder: create a texture, create a background rectangle, use the video as a texture ctx3d.texImage2D(WebGLRenderingContext.TEXTURE_2D, 0, WebGLRenderingContext.RGBA, WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, videoElement);
  • 9. WebGL (with Elemental) shaders Vertex Shader Fragment Shader precision mediump float; precision mediump float; attribute vec2 a_position; uniform sampler2D u_image; attribute vec2 a_texCoord; varying vec2 v_texCoord; uniform vec2 u_resolution; varying vec2 v_texCoord; void main() { void main() { gl_FragColor = vec2 zeroToOne = a_position / u_resolution; texture2D(u_image, v_texCoord); vec2 zeroToTwo = zeroToOne * 2.0; } vec2 clipSpace = zeroToTwo - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 1, 1); v_texCoord = a_texCoord; } from html5rocks.com's WebGL Fundamentals ... probably :o
  • 10. WebGL (with Elemental) shaders Fragment Shader Fragment Shader ... // Sepia tone precision mediump float; // Convert to greyscale using NTSC weightings uniform sampler2D u_image; float grey = dot(texture2D(u_image, uniform sampler2D SECOND_u_image; v_texCoord).rgb, vec3(0.299, 0.587, 0.114)); uniform float alpha; gl_FragColor = varying vec2 v_texCoord; vec4(grey * vec3(1.2, 1.0, 0.8), 1.0); void main(void) { ... vec4 prev = texture2D(SECOND_u_image, // Negative vec2(v_texCoord.s,1.0-v_texCoord.t)); vec4 texColour = vec4 cur = texture2D(u_image, v_texCoord); texture2D(u_image, v_texCoord); gl_FragColor = alpha*prev + (1.0-alpha)*cur; gl_FragColor = vec4(1.0 - texColour.rgb, 1.0); } from http://r3dux.org/2011/06/glsl-image-processing/
  • 11. WebGL (with Elemental) 3D WebGL e' una libreria 2D !! Trasformazioni prospettiche (proiezioni), frustum, modelview vanno implementate. VertexShader: applichera' le trasformazioni (matrici) che noi gli forniremo, vertice per vertice FragmentShader: usera', pixel-per-pixel, le informazioni calcolate vertice-per-vertice (ed interpolate dal 'sistema') per assegnare il colore
  • 12. WebGL (with Elemental) 3D double a = (right + left) / (right - left); double b = (top + bottom) / (top - bottom); double c = (farPlane + nearPlane) / (farPlane - nearPlane); double d = (2 * farPlane * nearPlane) / (farPlane - nearPlane); double x = (2 * nearPlane) / (right - left); double y = (2 * nearPlane) / (top - bottom); double[] perspectiveMatrix = new double[]{ x, 0, a, 0, 0, y, b, 0, 0, 0, c, d, 0, 0, -1, 0 }; .... ctx3d.uniformMatrix4fv(pMatrixUniform, false, Utilities.createArrayOfFloat32(perspectiveMatrix)); ... private native static Float32Array createFloat32Array(JsArrayOfNumber a) /*-{ return new Float32Array(a); }-*/;
  • 13. WebGL (with Elemental) 3D/Wavefront-OBJ Loading Wavefront-obj files ... parser in java facile da trovare in rete ClientBundle DataResource perfetto per il loading asincrono dei modelli Javascript per calcolare le normali se non sono nel modello
  • 14. Unconventional Tutto quello che abbiamo visto fino ad ora si poteva fare, probabilmente con lo stesso sforzo, direttamente in javascript. Ma usare GWT ci da o no una marcia in piu' ? Nota: non stiamo dicendo che quello che segue non si potesse fare in javascript, ndr: Turing completeness, se ce ne fosse bisogno !
  • 15. GWT Compiler: Java -> Javascript Javascript as a target language
  • 16. NyARToolkit ARToolKit is a computer tracking library for creation of strong augmented reality applications that overlay virtual imagery on the real world. NyARToolKit is an ARToolkit class library released for virtual machines, particularly those that host Java, C# and Android. Up to date info http://nyatla.jp/nyartoolkit/wp/?page_id=198 Support: Java ... "Write once, run anywhere" (WORA), or sometimes write once, run everywhere (WORE) ... in my browser ?!?!?!
  • 17. NyARToolkit con GWT http://jooink.blogpsot.com super-source tag per InputStream & altre parti della JRE non disponibili in GWT byte[] raster; UInt8ClampedArray image = ImageData.getData(); private static native byte[] toArrayOfBytes(Uint8ClampedArray a) /*-{ return a; }-*/; Documented in JAPANESE !!!
  • 18. How It Works cam WebRTC <video/> canvas ImageData Elemental/jsni WebGL + model video GWT(NyARToolkit) byte[] mv matrix