[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] WebGLSL Media Type Proposal



On Mon, May 21, 2012 at 4:36 PM, Jeff Gilbert <jgilbert@mozilla.com> wrote:
It is much more readable than the alternatives, and requires relatively little boilerplate functions to read in the contents of the script objects.
Let's inspect that "boilerplate" claim more precisely:

Mock <scripttag> kind of API:
  var script = document.createElement('script');
  script.>
    gl.shaderSource(shader, script.innerText);
  }
  script.defer = 'defer';  
  script.src = "">
  var head = document.head;
  head.appendChildElement(script);
  
XHRs in JS:
  var request = new XMLHttpRequest();
  request.open('GET', 'sometext.txt', true);
  request.>
    gl.shaderSource(shader, request.response);
  }
  request.send();

or, if you use any kind of library like jQuery:
  $.get('sometext.txt', function(response){
    gl.shaderSource(shader, response);
  });

Scripttag: 8 lines
XHR: 6 lines
some lib: 3 lines
 
The ideal syntax for me would be shaderSource() accepting either a string or an element ID, which it will then load the text from. I don't really know the correct terminology here, but basically formalizing this exceedingly sensible syntax would seem useful.

-Jeff

----- Original Message -----
From: "Florian Bösch" <pyalot@gmail.com>
To: "David Sheets" <kosmo.zb@gmail.com>
Cc: "public webgl" <public_webgl@khronos.org>
Sent: Sunday, May 20, 2012 4:01:30 AM
Subject: Re: [Public WebGL] WebGLSL Media Type Proposal

On Sun, May 20, 2012 at 7:07 AM, David Sheets < kosmo.zb@gmail.com > wrote:



I would like to propose the IANA registration of an official WebGLSL
media type by Khronos and the WebGL WG.

Sure, every file can have a mime-type. I call mine .shader, .glsl, .shaderlib, .shadertemplate, .foo and .bar.


WebGLSL is a new language for the Web and like the other Web languages
should have an associated media type for use in protocols like HTTP
and tags like <script>.

The purpose of <script> is to perform: 1) a text fetch from the server 2) execute the obtained source. This is what makes it a "script". Putting GLSL into <script> does not carry any of these conveniences, and would be in fact a poor mans XHR, since the scripttag cannot perform anything sensible on the obtained text other than making it available as text after you queried the scripptag from the DOM and looked up its innerText.


It is generally agreed that using scripptags to transport shader source is a bad practice, and this has nothing to do with the fact that you can't src them.