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

Re: [Public WebGL] Explicit unboxing for object identifiers



Another note: uniforms in OpenGL don't have handles. The values returned by glGetUniformLocation aren't unique across programs; if I remember correctly, they're typically just indexes within the particular linked program.

On Sun, Jan 8, 2012 at 8:06 PM, Rehno Lindeque <rehno.lindeque@gmail.com> wrote:
I believe [program,location].toString() will result in the string
"[object WebGLProgram],[object WebGLUniformLocation]", as far as I
know. So you won't be able to use [program,location] as a unique key
in an object.

Yeah. _javascript_ has a long way to go to put a dent in Python.


I'm currently using a trick like this to index by shader program...

 ÂshaderProgram._glquery_id = shaderProgramCounter;
 Â++shaderProgramCounter;
 locations[shaderProgram._glquery_id] = { uniforms: [...],
vertexAttributes: [...] };

...which works because you can only ever get a single instance of a
WebGLProgram by calling createProgram - there's no other way to
enumerate programs using the WebGL API.

There's getParameter(CURRENT_PROGRAM), which returns the same object. There's a one-to-one relationship between WebGLObjects and actual resources, so this should be guaranteed by any API returning a previously-existing program object.

--
Glenn Maynard