strange flipping about xaxis on texture readback – bug?

Mar 1, 2007 at 5:14pm

strange flipping about xaxis on texture readback – bug?

hi,

Using the jit.gl.sketch-based (js at the bottom) and this patch to generate some graphics, the jittermatrix output from the texture readback in jit.gl.render flips about the x-axis on everyother bang to jit.gl.texture. I have an undesireable workaround in the patch, too.
On my macbookpro w/ x1600 256 card.

Anyone know why?

Peter.

#P window setfont Arial 9.;
#P window linecount 3;
#P comment 465 455 234 131137545 then , try moving the “gate” to the left of the gl.texture , so it draws to the optional matrix SECOND. Things freak out then!;
#P window linecount 4;
#P comment 465 409 234 131137545 on my macbookpro w/ x1600 256 card , the above will flip around the xaxis on every other bang to jit.gl.texture. If I open the gate and send the texture to another matrix first , the flipping stops.;
#P toggle 465 389 15 0;
#P window setfont Arial 10.;
#P window linecount 1;
#P newex 489 227 31 131137546 gate;
#P user jit.pwindow 580 254 82 62 0 1 0 0 1 0;
#P newex 580 234 121 131137546 jit.matrix 4 char 320 240;
#P window setfont Arial 9.;
#P newex 466 178 35 131137545 sel 27;
#P newex 465 156 40 131137545 key;
#P window setfont Arial 10.;
#P newex 450 259 73 131137546 jit.gl.slab clips;
#P button 97 96 15 0;
#P button 446 156 15 0;
#P user jit.pwindow 465 325 82 62 0 1 0 0 1 0;
#P newex 444 201 286 131137546 jit.gl.texture clips @name clipbank @dim 400 300 @adapt 1;
#P newex 451 283 121 131137546 jit.matrix 4 char 320 240;
#P window setfont Arial 9.;
#P newex 8 432 58 131137545 jit.gl.sketch;
#P user jit.pwindow 7 119 402 302 0 1 1 1 0 0;
#X name clips;
#P button 37 70 15 0;
#P newex 36 94 59 131137545 js testout.js;
#P comment 479 391 137 131137545 open gate to stop the “flipping”;
#P connect 1 0 3 0;
#P connect 2 0 1 0;
#P connect 3 1 1 0;
#P connect 1 1 9 0;
#P connect 1 1 6 0;
#P connect 12 0 6 0;
#P connect 8 0 6 0;
#P connect 6 0 10 0;
#P connect 10 0 5 0;
#P connect 11 0 12 0;
#P connect 5 0 7 0;
#P hidden connect 16 0 15 0;
#P connect 6 0 15 1;
#P connect 15 0 13 0;
#P connect 13 0 14 0;
#P window clipboard copycount 19;

/*——BEGIN testout.js—————-*/
autowatch =1;
inlets=2;
outlets=2;
setoutletassist(0,”size”);
setoutletassist(1,”bang for matrix”);
var v=new Array();
var rendername=”clips”;
var sk=new JitterObject(“jit.gl.sketch”,rendername);
sk.camera=[0,0,1];
var render=new JitterObject(“jit.gl.render”,rendername);
render.ortho=2;
render.fsaa=1;
//totex = new JitterObject(“jit.gl.texture”,rendername);
//totex.name = “clipmatrix”;
//var window = new JitterObject(“jit.window”,rendername);
var wsize = [400,300];
var aspect = wsize[0]/wsize[1];
sk.reset();
var grid = [6,6];
var griddivx = aspect/grid[0];
var griddivy = 1/grid[1];
var gx01 = -1;
var gy01 = -1;
var hlite01 = [-1,-1];

function bang(){
sk.reset();
if(hlite01[0]>=0 && hlite01[1]>=0) {
sk.moveto(-aspect-(griddivx)+(2*hlite01[0]*griddivx),1+(griddivy)-(2*hlite01[1]*griddivy),0);
sk.glcolor(.7,0,0);
sk.plane(griddivx+(aspect*0.015),griddivy+0.015);
sk.glcolor(0,0,0);
sk.plane(griddivx-(aspect*0.01),griddivy-0.01);
//post(“01n”);
}
sk.glcolor(1,1,1);
sk.tri(-.1,0,0,0,.2,0,.1,0,0);
sk.tri(0,-.1,0, .2,0,0, 0,.1,0);
render.erase();
render.drawswap();
render.usetexture(“clipbank”);
render.to_texture();
outlet(1,”bang”);
}
function hilite01(x,y){
hlite01 = [x,y];
}
function hilite02(x,y){
hlite02 = [x,y];
}

function mouseidle(){
var l = arrayfromargs(messagename,arguments);
var x=arguments[0];
var y=arguments[1];
var gx = Math.floor(x/(wsize[0]/grid[0]));
var gy = Math.floor(y/(wsize[1]/grid[1]));
if (gx!=gx01||gy!=gy01){
hilite01(gx+1,gy+1);
bang();
}
gx01 = gx;
gy01 = gy;
}
function mouseidleout(){
//nothing
}
function mouse(){
//nothing
}
/*——end testout.js——–*/

#30571
Mar 1, 2007 at 7:40pm

hm…seem to have figured something out…
I made the jit.matrix that connects to slab the same dim as the texture and renderwindow. this stopped the flipping. I then found i was a frame behind on what I saw in the bitmap version vs. the rendered version, no matter what order I had this stuff in:
render.erase();
render.drawswap();
render.usetexture(“clipbank”);
render.to_texture();
outlet(1,”bang”);
this was solved by repeating the line “render.to_texture();” twice:
render.erase();
render.drawswap();
render.usetexture(“clipbank”);
render.to_texture();
render.to_texture();
outlet(1,”bang”);
now it’s in sync. I don’t understand why I would need to do that, but it does work the way I would expect.

Peter.

#97922

You must be logged in to reply to this topic.