JSUI Issues: The glpushmatrix() and glpopmatrix() methods
I'm diving further into JSUI and upon revisiting it I realize how it's more or less like Processing which makes sense from a technical perspective.
With that said I am getting what may be inconsistent results with the methods glpushmatrix() and glpopmatrix(). I am basing this off of my my understanding of the similar methods in Processing and my reading on the topic.
When I initially render the JSUI object, a rectangle is rotate/transformed but the circle is not. THIS is the expected result.
When I send a bang to the object in order to re-render it, all shapes are transformed. This is NOT the expected result. This suggests that it's no longer obeying the glpushmatrix().
Any thoughts and insight into this? Thanks.
You can see the javascript here:
sketch.default2d();
// Helper Object mimicking Processing.org functions
var p = {
circle : function(x,y,r) {
moveto(x,y);
circle(r);
},
rect : function(x, y, w, h) {
moveto(x, y);
plane(w, h, w, h);
},
fill : function(r,g,b,a) {
var r = r/255.;
var g = g/255.;
var b = b/255.;
var a = a/255.;
glcolor(r, g, b, a);
},
background : function(r,g,b,a) {
r = r/255.;
g = g/255.;
b = b/255.;
a = a/255.;
glclearcolor(r, g, b, a);
}
}
function draw() {
with(sketch) {
refresh();
glmatrixmode("modelview");
p.background(46, 48, 51, 0);
glpushmatrix();
p.fill(255, 255, 255, 255);
p.circle(0,0.03, 0.8);
glpopmatrix();
glpushmatrix();
shapeorient(100.7, 40, 0);
p.rect(0.2, 0.2, 0.2, 0.2);
glpopmatrix();
}
}
function bang() {
notifyclients();
draw();
refresh();
outlet(0,val);
}
draw();
Screenshots are provided. Before and after reloading.


please attach a script and patch and I'll take a look.
Thanks @Rob Ramirez
I did some more testing to pinpoint the issue and it may be related to shapeorient(). I will share that when I get a chance soon.
So I removed the shapeorient() method because I believe I was misusing it. However, I am curious about how the glpushmatrix and pop methods should work. To my understanding, they create different matrices that allows for different visual attributes. I attempted to create a matrix with a blue square and another separate matrix that should ignore the blue glcolor but it does not.
Javascript
Max Patch

Those methods only work on projection matrices (orthographic/2d or perspective/3d), not on generic styles.