Is jit.gl.slab functionality within Java possible?
I want to make a java wrapper for the jit.gl.slab object to make some slab thingies easier to do.
But I immediately run into a fundamental problem: I can’t get the input and output of a jit.gl.slab object work.
I basically did this:
1. I instantiated a JitterObject with ‘ new JitterObject("jit.gl.slab") ‘.
2. I made the ‘anything’ method forward all incoming data to this JitterObject via the ‘call’ method.
3. I set up a JitterListener to listen to outcoming textures when the slab is done processing them.
The JitterListener however doesn’t seem to register the out coming ‘jit_gl_texture’ messages.
Also, when I use the ‘call’ method, no Atom array is returned, in stead I get only null.
So much for the straightforward solution.
So I tried sending out the resulting textures (with their names defined in the ‘capture’ attribute) simply after receiving incoming jit.matrices. That only gives me a black window.
So I tried sending out the resulting textures after any of the messages that the JitterListener dóes register. Still no luck.
As you can see in the java file (attached) and the max patch (I tried to comment it all quite clearly), I’ve tried basically every point that I could think of to send out the resulting texture. Without success.
Can anybody tell me how to make a shader / slab work within Java code?
Thank you to anyone pointing me in the right direction!
----------begin_max5_patcher---------- 1182.3oc0YtsiahCFG+5jmBKTkxtZSivFHgLRqT2mg8h8hUUib.Ofy.1TrYR 5V0280GHmZmPHDBclaffwf+7O++6fIea7HmU7sDgC3Av+BFM5aiGMxzjtgQ0 WOxIGuMJCKLcyIhmmSXRmo16IIakl1koTAfWIKpjfLN+YA.mkURSRkSAqqDR fLk.jzbJKAHHjbAPxAqHfMkbVxt2VFkQh3ULyqDU23SbljgyIlg4uJo3Lmit if9el6.QybqalUoFkLhzXvvCMprtcstqqEXYTpxjdrjDIsXXwb8aB3EFpOAC matxelK3y0ODM1XJ7Uq+HZtitsuOdr9vzajgvG1QPMrlDgKjUkjI.cGT+.rI kv.YTgjvHk.kISnuPDfIpegyhl7VhhAV7E5qOhVD1HDC5SHhtJHpjhJkXJtt 20cZB.KkkzUURU+wBPNOl9DkD+FjvP3h1fX+9Dw4DYJOV7.32T93.FWB1vKe VYd+tyuTV3Y7bgAtFh3dFT30mnv8RpMpJvHydSL6q5KRl.r.DfeRpjf56Ixv q.oJkVsScro00TotC4XkVb6aPsW.rERO3x9j2d2h289d+9w61e4rfKi3E8Ih 8uEDiqjbkdkF8dBxgdsQG2orT4Dg.mP9IHqbseLI6wcLsB4F355hf9WNBpct I+ZAwNKbb1atsgRnWkRvFnzRuiKHJXokYmI5JpKTRYKqHkcXpS05WfyJrpFx 8lSAtT8zpHmORX3UYjiUAcWGgtnNB4ax+bgzOt8oLpNQxGfuAkM0PYooDv4K ZR0.C6y.XRdRRFAvYf+TGDhjWHAEk7HEC069PlVxqRRsYXwufMIe2ThKJNHA OI5j2ulnSHqmVnsnFjAf9mCfcZeHLxF0C+S7Kiii0BNf6cWUAuVUExy.E+.8 wEnl7zf98HS9C.rigmtudY07nNzip.3fF.Rmp705M0toXSQd6k0cn2hcK4ML OQ83BeBVU.CpKNBS6mPrnKu3uv3M362DT5Smg7sqA+sJn4+nBZNHjoqYj8r6 HLLnwLx8HYTk0MKIalY6b5CeLRtE7omnpzQx3YOiyHzX9r0aEc.amVxXCPzq ekW0PDgrmfmwoqKTbkYTOj18Umy0a+c+ftGWwjb9KzXBel5kpdSNu1r18Ziz 3gfGGowy0l9M30m1d8u3wLkJxvLxQRHYIlIdhWlqrTAQ1oHRGAyqV7.6p3ot JPaHpyIdl2yTbCkEy2rGecfUlcTb+ozb3wasBF1nGla+q0JIrX8l3em.pZYT cwvmCTK6QNIAq.jRrfbCnw97CBerkAN2qI7D99sJv4vVWD3hdTD7E0rojqRD B9DNRRegzoMCb5Gon6YruHeP1+R.nGrIYvIeNKSGL658G9y.MCht8SolfWUF sahYEUSAGFlXhPRYXIkyNpOKOoOoz3XB6XsQLUnkKFSz8UW8tFqAdiVSNMtf qz00.AB8seIVW8I6QyEGFldy7WzBXFLXvLnEVS3fYM9sXoEMnVykXCbvrFuV XMmxu6o0fbaCbFNkCpEly72TVCBMXKVv1D.e37qfsxwZ.sm15ZMPlSaTO+fM eWsm6nqE3yi+93+GJ1Gr0 -----------end_max5_patcher-----------
There’s a get-only attribute called out_name that will give you the name of the jit.gl.texture that is the slab’s output. You can use its value to chain together slabs and texture other jit.gl objects. You can use the relevant attr getting java methods to get its value, but here’s a patcher version:
----------begin_max5_patcher---------- 363.3ocuS10SCBCEF9Z3WQSudtzxDb5c96vrPJvQVWJEBsLmtr+61OnYxbFW lKxEPNev6487TXebDtncGnvnmPufhh1GGE4RYSDMFGgaX6JELkqMbCnTrZ.O yWSC6zt7sC5bIqAPCOtjXtnKngddsUpU7O.aezj4jwzxgFtT.ZmtIiI6X5x0 bYcdOTp89Jgdu4cPIKRsOnYtH5x4DzpiJYFePJ5XVdk2XEatiNwKVa5J8bOm IBU7JneuC7iEiQqrUNDGauM6OxmZPGPzMhKzThiDoNfrjdEXg7ugEI7lYhei Ja3540h4JAq3V80B4AOHxrORcAIjejJImgJWATL6QdsH2tWC8lC3Swja5XAW d5OatMvleJ6TsC8kAwCGUniKQEnzbISyakesoI8rlWUAtxAFVwUrBA3VUxYO DuX6XlD82byzltb63gEqqaKzqF0z4DymTaZ6sgYybgboOzoHtG1xC8mEaU6P 7mPDKOxq -----------end_max5_patcher-----------
Thanks! But the ‘out_name’ attribute gives the exact same name as the ‘capture’ attribute that I send out through the mxj outlet. So the outcoming textures are named correctly I believe. Only, for some reason, they are empty at the moment that I send them. (btw, just to be sure, I just now tested the use of the out_name attribute in my Java file, which as expected gave the same results).
I think there might be a timing problem: I might be sending out the texture while its being created, or right before or something.
I believe I would be helped a lot if a JitterListener could actually see when the jit.gl.slab object sends out the resulting texture. But for some reason it seems to ignore this.
Oh wow, I found the staggeringly simple answer:
In ‘normal’ max, sending a jit.gl.slab object a matrix or a texture will make it automatically process a texture.
Within Java however, this does NOT happen automatically. The texture does not get drawn until you explicity give it the "draw" command.
A subtle inconsistency which got me thinking in waaay too complex ways.