Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


tomlee

Member Since 14 Nov 2011
Offline Last Active Nov 24 2012 08:04 PM

Posts I've Made

In Topic: OpenGL for Linux and MacOSX?

22 November 2012 - 03:43 PM

On CentOS/RHEL, you're probably after the mesa-libGL-devel package. :)

http://rpm.pbone.net/index.php3/stat/4/idpl/17834939/dir/centos_5/com/mesa-libGL-devel-6.5.1-7.10.el5.i386.rpm.html

In Topic: load external text file (shader) in javascript (WebGL)

14 November 2011 - 10:39 PM

Hi,

this will be exotic :)
I'm trying to load an external text file from javascript, so that I can load it as a shader later. The file is loaded successfully, however when I try to access its contents I can't.
I checked with firebug if it is loaded properly, and it was. When I try to access its content by using this:

function load_external_script(filename, type)
{
  var script = document.createElement('script');
  script.type = type;
  script.src = filename;
  script.setAttribute('id', filename);
  head.appendChild(script);
}

function getShader(gl, id)
{
  var shaderScript = document.getElementById(id);
  if (!shaderScript)
  {
	return null;
  }

  var str = shaderScript.text;
...
}

load_external_script('vertex.vs', 'text/plain');
var fragmentShader = getShader(gl, "vertex.vs");

the str = ... line triggers an unexpected EOF error, and I checked: both text and innerHTML properties are empty despite the content is there... any ideas how can I get it?

or is there another way of loading shaders from external source?

I took the basic source from http://learningwebgl.com/blog/?p=28

here's the uploaded file:
link

Best regards,
Yours3!f


Easy: use AJAX! :)

XMLHttpRequest.responseText will give you direct access to the source of a shader. (Alternatively you can use the nicer JQuery or Prototype equivalents).

Problem is you'll want to process the response asynchronously, which may complicate your initialization a little.

PARTNERS