GL viewports weirdness in Max5

Apr 23, 2008 at 6:44pm

GL viewports weirdness in Max5

Hi everyone,

I’ve noticed that many of my patches using multiple viewports with jit.gl.sketch don’t work as expected in Max 5. Here’s a simple example below. It seems like somehow the glscale command functions differently. Open the patch in Max 4 and 5 to compare. Can anyone explain this? My use of GL commands with jit.gl.sketch has always been a bit weak – need to spend some time on it. I might be missing something…

{
“patcher” : {
“fileversion” : 1,
“rect” : [ 639.0, 101.0, 699.0, 647.0 ],
“bglocked” : 0,
“defrect” : [ 639.0, 101.0, 699.0, 647.0 ],
“openrect” : [ 0.0, 0.0, 0.0, 0.0 ],
“openinpresentation” : 0,
“default_fontsize” : 12.0,
“default_fontface” : 0,
“default_fontname” : “Arial”,
“gridonopen” : 0,
“gridsize” : [ 15.0, 15.0 ],
“gridsnaponopen” : 0,
“toolbarvisible” : 1,
“boxanimatetime” : 200,
“imprint” : 0,
“metadata” : [ ],
“boxes” : [ {
"box" : {
"maxclass" : "comment",
"text" : "can someone explain why this works differently in Max 4 and 5?",
"linecount" : 2,
"numinlets" : 1,
"fontname" : "Arial",
"id" : "obj-42",
"numoutlets" : 0,
"presentation_rect" : [ 280.0, 363.0, 0.0, 0.0 ],
“fontsize” : 18.0,
“patching_rect” : [ 302.0, 312.0, 278.0, 48.0 ]
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “this works as expected in Max 4.6, skews the right cube in Max 5.”,
“numinlets” : 1,
“fontname” : “Arial”,
“id” : “obj-37″,
“numoutlets” : 0,
“presentation_rect” : [ 317.0, 26.0, 0.0, 0.0 ],
“fontsize” : 12.0,
“patching_rect” : [ 313.0, 27.0, 366.0, 20.0 ]
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “change the second glscale to 1. 1. 1., and it works in Max 5…”,
“numinlets” : 1,
“fontname” : “Arial”,
“id” : “obj-36″,
“numoutlets” : 0,
“fontsize” : 12.0,
“patching_rect” : [ 280.0, 213.0, 340.0, 20.0 ]
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “reset, glenable scissor_test, glmatrixmode modelview, glviewport 0 0 200 200, glscissor 0 0 200 200, glloadidentity, glscale 1. 0.5 1., glrotate 0. 0. 0. 0., moveto 0 0 -5, glclear GL_COLOR_BUFFER_BIT, drawobject object 0, glviewport 200 0 200 200, glscissor 200 0 200 200, glloadidentity, glscale 1. 1. 1., moveto 0 0 -5, glrotate 0. 0. 0. 0., glclear GL_COLOR_BUFFER_BIT, drawobject object 0, glflush”,
“linecount” : 5,
“numinlets” : 2,
“fontname” : “Geneva”,
“id” : “obj-34″,
“numoutlets” : 1,
“presentation_rect” : [ 266.0, 288.0, 0.0, 0.0 ],
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 239.0, 236.0, 429.0, 65.0 ]
}

}
, {
“box” : {
“maxclass” : “flonum”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-1″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "float", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 121.0, 212.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “flonum”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-2″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "float", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 85.0, 212.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “flonum”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-3″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "float", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 49.0, 212.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “pak position 0. 0. 0.”,
“numinlets” : 4,
“fontname” : “Geneva”,
“id” : “obj-4″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 13.0, 233.0, 120.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “rotate 0. 0. 0. 0.”,
“linecount” : 2,
“numinlets” : 2,
“fontname” : “Geneva”,
“id” : “obj-5″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 144.0, 430.0, 75.0, 29.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “prepend set”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-6″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 144.0, 406.0, 61.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “number”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-7″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "int", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 198.0, 293.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “number”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-8″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "int", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 133.0, 294.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “pak 0 0 0″,
“numinlets” : 3,
“fontname” : “Geneva”,
“id” : “obj-9″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 320.0, 141.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “number”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-10″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "int", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 294.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “prepend rotatexyz”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-11″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 344.0, 92.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.gl.handle @fake”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-12″,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 367.0, 92.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r to_box”,
“numinlets” : 0,
“fontname” : “Geneva”,
“id” : “obj-13″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 69.0, 433.0, 48.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.gl.gridshape fake @shape cube @color 1. 0. 0. 1. @automatic 0 @name object @lighting_enable 1 @position 0. 0. -2. @scale 1.”,
“linecount” : 2,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-14″,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 69.0, 462.0, 301.0, 31.0 ]
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “getcmdlist”,
“numinlets” : 2,
“fontname” : “Geneva”,
“id” : “obj-15″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 350.0, 133.0, 55.0, 17.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.window context @floating 1 @depthbuffer 1 @size 400 200″,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-16″,
“numoutlets” : 2,
“outlettype” : [ "bang", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 566.0, 292.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “loadbang”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-17″,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“fontsize” : 9.0,
“patching_rect” : [ 263.0, 28.0, 48.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “s to_box”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-18″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 153.0, 117.0, 48.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r to_sketch”,
“numinlets” : 0,
“fontname” : “Geneva”,
“id” : “obj-19″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 282.0, 133.0, 61.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “print”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-20″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 409.0, 189.0, 31.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “reset, glenable scissor_test, glmatrixmode modelview, glviewport 0 0 200 200, glscissor 0 0 200 200, glloadidentity, glscale 1. 0.5 1., glrotate 0. 0. 0. 0., moveto 0 0 -5, glclear GL_COLOR_BUFFER_BIT, drawobject object 0, glviewport 200 0 200 200, glscissor 200 0 200 200, glloadidentity, glscale 1. 0.5 1., moveto 0 0 -5, glrotate 0. 0. 0. 0., glclear GL_COLOR_BUFFER_BIT, drawobject object 0, glflush”,
“linecount” : 5,
“numinlets” : 2,
“fontname” : “Geneva”,
“id” : “obj-21″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 263.0, 53.0, 391.0, 65.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.gl.sketch context @automatic 0″,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-22″,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 263.0, 165.0, 165.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “s to_render”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-23″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 182.0, 95.0, 62.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “s to_render”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-24″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 95.0, 161.0, 62.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “s to_sketch”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-25″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 124.0, 139.0, 61.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “number”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-26″,
“numoutlets” : 2,
“triscale” : 0.9,
“outlettype” : [ "int", "bang" ],
“bgcolor” : [ 0.866667, 0.866667, 0.866667, 1.0 ],
“fontsize” : 9.0,
“patching_rect” : [ 82.0, 30.0, 35.0, 19.0 ],
“htextcolor” : [ 0.870588, 0.870588, 0.870588, 1.0 ]
}

}
, {
“box” : {
“maxclass” : “jit.fpsgui”,
“numinlets” : 1,
“fontname” : “Arial”,
“id” : “obj-27″,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 37.0, 150.0, 46.0, 31.682453 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r to_render”,
“numinlets” : 0,
“fontname” : “Geneva”,
“id” : “obj-28″,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 9.0,
“patching_rect” : [ 69.0, 503.0, 62.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “t b b b b b erase”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-29″,
“numoutlets” : 6,
“outlettype” : [ "bang", "bang", "bang", "bang", "bang", "erase" ],
“fontsize” : 9.0,
“patching_rect” : [ 37.0, 72.0, 156.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “toggle”,
“numinlets” : 1,
“id” : “obj-30″,
“numoutlets” : 1,
“outlettype” : [ "int" ],
“patching_rect” : [ 37.0, 29.0, 15.0, 15.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “qmetro 50″,
“numinlets” : 2,
“fontname” : “Geneva”,
“id” : “obj-31″,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“fontsize” : 9.0,
“patching_rect” : [ 37.0, 49.0, 55.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.gl.render context”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-32″,
“numoutlets” : 2,
“outlettype” : [ "bang", "" ],
“fontsize” : 9.0,
“patching_rect” : [ 69.0, 534.0, 212.0, 19.0 ]
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “red box rotation”,
“numinlets” : 1,
“fontname” : “Geneva”,
“id” : “obj-33″,
“numoutlets” : 0,
“fontsize” : 9.0,
“patching_rect” : [ 68.0, 265.0, 100.0, 19.0 ]
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-34", 0 ],
“destination” : [ "obj-22", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-22", 1 ],
“destination” : [ "obj-20", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-19", 0 ],
“destination” : [ "obj-22", 0 ],
“hidden” : 0,
“midpoints” : [ 291.5, 154.0, 272.5, 154.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-21", 0 ],
“destination” : [ "obj-22", 0 ],
“hidden” : 0,
“midpoints” : [ 272.5, 155.0, 272.5, 155.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-15", 0 ],
“destination” : [ "obj-22", 0 ],
“hidden” : 0,
“midpoints” : [ 359.5, 159.0, 272.5, 159.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-17", 0 ],
“destination” : [ "obj-21", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-7", 0 ],
“destination” : [ "obj-9", 2 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-29", 5 ],
“destination” : [ "obj-23", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-29", 4 ],
“destination” : [ "obj-18", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-6", 0 ],
“destination” : [ "obj-5", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-12", 0 ],
“destination” : [ "obj-6", 0 ],
“hidden” : 0,
“midpoints” : [ 77.5, 391.0, 153.5, 391.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-8", 0 ],
“destination” : [ "obj-9", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-29", 3 ],
“destination” : [ "obj-25", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-4", 3 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-29", 2 ],
“destination” : [ "obj-24", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-4", 2 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-26", 0 ],
“destination” : [ "obj-31", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-28", 0 ],
“destination” : [ "obj-32", 0 ],
“hidden” : 0,
“midpoints” : [ 78.5, 525.0, 78.5, 525.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-4", 0 ],
“destination” : [ "obj-14", 0 ],
“hidden” : 0,
“midpoints” : [ 22.5, 455.0, 78.5, 455.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-13", 0 ],
“destination” : [ "obj-14", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-12", 0 ],
“destination” : [ "obj-14", 0 ],
“hidden” : 0,
“midpoints” : [ 77.5, 399.0, 130.0, 399.0, 130.0, 454.0, 78.5, 454.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-11", 0 ],
“destination” : [ "obj-12", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-11", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-9", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-3", 0 ],
“destination” : [ "obj-4", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-29", 0 ],
“destination” : [ "obj-27", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-31", 0 ],
“destination” : [ "obj-29", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-30", 0 ],
“destination” : [ "obj-31", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}

}

#37129
Apr 23, 2008 at 9:25pm

i can confirm this.

mac powerbook 1.5Mhz, Mac OSx 10.9.11

pelado

#127929
Apr 23, 2008 at 9:39pm

Thanks Pelado, for confirming. Any ideas what’s going on? I’m aware of your jit.gl.sketch proficiency. ;)

best,
Zachary

#127930
Apr 23, 2008 at 10:57pm

thanks for your vote on my proficiency, i wish i felt as confident!

it looks to me as though the modelling transformations are not being cleared from the modelview matrix stack when you reload the identity matrix. this would mean that the scale commands you issue have action on each other and upon subsequent drawing commands. hence the cube appears smaller.

i could be totally off track though.

pelado

#127931
Apr 24, 2008 at 1:53am

On Apr 23, 2008, at 3:57 PM, pelado wrote:
>
> it looks to me as though the modelling transformations are not being
> cleared from the modelview matrix stack when you reload the identity
> matrix. this would mean that the scale commands you issue have
> action on each other and upon subsequent drawing commands. hence the
> cube appears smaller.

Precisely. Any command without arguments (e.g. glloadidentity, glend,
etc.) are not getting executed. You can hack this for the time being
by adding a bogus argument which will be ignored (e.g. “glend 0″), but
it will be fixed in the next incremental (probably Friday).

Thanks for spotting this, fellas!

-Joshua

#127932

You must be logged in to reply to this topic.