WebGL & Textures

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

WebGL & Textures

Michael Cann
I know this isnt strictly HaXe, but im attempting to write some WebGL in haxe but im running into a problem so I thought I would write it in JS first.

Im just trying to get a simple 2D texture to render using WebGL: http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL

Works fine when its in a browser, but if you download that page it the texture doesnt show and if you inspect the console you get:

Uncaught Error: SECURITY_ERR: DOM Exception 18

When it is trying to set the texture:

gl.texImage2D(
<img src="chrome-devtools://devtools/Images/errorIcon.png" class="webkit-html-message-icon" style="box-sizing: border-box; -webkit-user-drag: none; position: relative; top: 2px; margin-top: 0px; margin-right: 4px; margin-bottom: 0px; margin-left: 4px; ">demo.js:210Uncaught Error: SECURITY_ERR: DOM Exception 18
gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);

Really odd! I googled it as it looked like a cross-domain security thing, couldnt find much on it. So I thought to myself, "surely I have seen webGL demos with textures working on my PC before" so I downloaded the three.js src (https://github.com/mrdoob/three.js/) and went through the examples.

Every single example that requires a texture to run keeps throwing the security error. 

Is this a new thing? Im pretty sure you could run webgl examples from your local drive before without security errors?

Im currently running Chrome 14 dev but I also tested it in Firefox 5 with the same results:

uncaught exception: [Exception... "Failure arg 5 [nsIDOMWebGLRenderingContext.texImage2D]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/MikeC/Desktop/JSTEST/Texture%20Test_files/demo.js :: <TOP_LEVEL> :: line 211" data: no]

Oddness, I have uploaded the simple example: mikecann.co.uk/DumpingGround/JSTest.zip

Thoughts?

--
Mike Cann
http://www.mikecann.co.uk/


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: WebGL & Textures

Michael Cann
Note, just read this:


Seems like an extremely drastic response. 

From a comment:

This broke loading a WebGL page with textures from a file: URL.
I think it should treat texture files in the same dir or any child dir as being in the same domain. It does not.

Apparently you can enable file:// urls in about:config however its not exactly intuitive to those of us trying to get started with WebGL!

Mike

On 31 July 2011 16:00, Michael Cann <[hidden email]> wrote:
I know this isnt strictly HaXe, but im attempting to write some WebGL in haxe but im running into a problem so I thought I would write it in JS first.

Im just trying to get a simple 2D texture to render using WebGL: http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL

Works fine when its in a browser, but if you download that page it the texture doesnt show and if you inspect the console you get:

Uncaught Error: SECURITY_ERR: DOM Exception 18

When it is trying to set the texture:

gl.texImage2D(
demo.js:210Uncaught Error: SECURITY_ERR: DOM Exception 18
gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);

Really odd! I googled it as it looked like a cross-domain security thing, couldnt find much on it. So I thought to myself, "surely I have seen webGL demos with textures working on my PC before" so I downloaded the three.js src (https://github.com/mrdoob/three.js/) and went through the examples.

Every single example that requires a texture to run keeps throwing the security error. 

Is this a new thing? Im pretty sure you could run webgl examples from your local drive before without security errors?

Im currently running Chrome 14 dev but I also tested it in Firefox 5 with the same results:

uncaught exception: [Exception... "Failure arg 5 [nsIDOMWebGLRenderingContext.texImage2D]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/MikeC/Desktop/JSTEST/Texture%20Test_files/demo.js :: <TOP_LEVEL> :: line 211" data: no]

Oddness, I have uploaded the simple example: mikecann.co.uk/DumpingGround/JSTest.zip

Thoughts?

--
Mike Cann
http://www.mikecann.co.uk/




--
Mike Cann
http://www.mikecann.co.uk/


--
haXe - an open source web programming language
http://haxe.org
Loading...