evanw / glfx.js

An image effects library for JavaScript using WebGL
https://evanw.github.io/glfx.js/
MIT License
3.26k stars 402 forks source link

Native functions not working #28

Open cpBurn opened 9 years ago

cpBurn commented 9 years ago

By the description:

var canvas = fx.canvas(); Before you can apply any filters you will need a canvas, which stores the result of the filters you apply. Canvas creation is done through fx.canvas(), which creates and returns a new WebGL tag with additional methods specific to glfx.js. This call will throw an error message if the browser doesn't support WebGL.

But

var canvas = fx.canvas(); var ctx = canvas.getContext('2d'); //Returns null

Also drawImage, getImageData, putImageData throws "not a function" error.

I want to take advantage of some effects of Glfx and also do some work on my own. For example use Glitch effect (http://snorpey.github.io/jpg-glitch/).

fesor commented 9 years ago

You can't have two context on single canvas

var canvas1 = document.createElement('canvas'),
      cavas2 = document.createElement('canvas');

canvas1.getContext('2d'); //CanvasRenderingContext2D
canvas1.getContext('webgl'); // null
canvas2.getContext('webgl'); //WebGLRenderingContext
canvas2.getContext('2d'); // null