Jump to content

CORS images with WebGL


mariogarranz
 Share

Recommended Posts

Some of our games images need to be loaded from an external server. The game may be played on different sites, but these images need to remain always on the same default site.


It's an Amazon AWS S3 server, where we declared the images to be public, which apparently enables CORS loading. It works just fine with CANVAS mode, but when we use WebGL mode we get this error:

 

 

Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at ---- may not be loaded. 

 

 

I have read about some other people having this problem with PIXI, but the problem seems to be with CORS not being enabled (which is not our problem, because these images are being loaded correctly for CANVAS drawing).

Is this normal? Shall we use any special headers when loading these images? Amazon S3 servers don't seem to have many other options to configure CORS other than making files public.

Link to comment
Share on other sites

Thanks for answering bryanbait.

I solved this by setting the crossOrigin you mentioned. Also some configuration was missing on the S3 side. The biggest problem was that some images were loaded previously as non-Phaser (for CSS layers) elements, and because these were loaded before Phaser.Loader started doing its stuff, their configuration prevailed, which took me quite some time to notice.

It's now all working just fine.

 

Thanks for your help, I hope this may help anyone else as well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...