Skip to content

Commit

Permalink
added fix, updated toPNG function
Browse files Browse the repository at this point in the history
  • Loading branch information
Andor committed Aug 21, 2010
1 parent fc5ec42 commit f0411b2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions psapi.js
Expand Up @@ -6,11 +6,13 @@
function PointStream(){

try{
WebGLFloatArray;
Float32Array;
}catch(ex){
WebGLFloatArray = Float32Array;
Float32Array = WebGLFloatArray;
Uint8Array = WebGLUnsignedByteArray;
}
const TYPED_ARRAY_FLOAT = WebGLFloatArray;
const TYPED_ARRAY_FLOAT = Float32Array;
const TYPED_ARRAY_BYTE = Uint8Array;

const VERSION = "0.4.5";
const XHR_DONE = 4;
Expand Down Expand Up @@ -1105,21 +1107,20 @@ function PointStream(){
/**
*/
getPNG: function(){
// Minefield throws and exception
var arr;
try{
var arr = ctx.readPixels(0, 0, xb.width, xb.height, ctx.RGBA, ctx.UNSIGNED_BYTE);
arr = ctx.readPixels(0, 0, xb.width, xb.height, ctx.RGBA, ctx.UNSIGNED_BYTE);

// Chrome posts an error
if(ctx.getError()){
arr = new WebGLUnsignedByteArray(xb.width * xb.height * 4);
arr = new TYPED_ARRAY_BYTE(xb.width * xb.height * 4);
ctx.readPixels(0, 0, xb.width, xb.height, ctx.RGBA, ctx.UNSIGNED_BYTE, arr);
}
}
catch(e){
if(!arr){
arr = new WebGLUnsignedByteArray(xb.width * xb.height * 4);
ctx.readPixels(0, 0, xb.width, xb.height, ctx.RGBA, ctx.UNSIGNED_BYTE, arr);
}
// Minefield throws and exception
arr = new TYPED_ARRAY_BYTE(xb.width * xb.height * 4);
ctx.readPixels(0, 0, xb.width, xb.height, ctx.RGBA, ctx.UNSIGNED_BYTE, arr);
}

var cvs = document.createElement('canvas');
Expand Down

0 comments on commit f0411b2

Please sign in to comment.