Translating gl texture slab chain to Javascript


    Dec 29 2021 | 1:05 pm
    I have a simple patch which Is overlaying 2 (possibly more) gl texture layers. Im trying to translate this into Javascript but Im not getting any output. Im guessing there is an issue with one of the inputs and outputs in the chain. Ive tried a number of combinations but I'm getting nothing out. (Note: I haven't implemented the second input texture yet Im just trying to get something working for the first texture) Any pointers to where Im going wrong gratefully received!
    This is the JS:
    var mycursor = new JitterObject("jit.gl.gridshape", "editor"); mycursor.shape = "plane"; mycursor.smooth_shading = 1; mycursor.lightning_enable = 1; scalex = 0.1; scaley = 0.1; mycursor.scale = [scalex,scaley]; mycursor.position = [0.2,0.2]; mycursor.color = [1,0,0,0.5]; mycursor.capture = "cursor";
    var cursorsel = new JitterObject("jit.gl.texture", "editor"); cursorsel.name = "cursor"; cursorsel.dim = [320, 240];
    var backdrop = new JitterObject("jit.gl.texture", "editor"); backdrop.name = "backdrop"; backdrop.dim = [320, 240];
    var mixer = new JitterObject("jit.gl.slab", "editor"); mixer.inputs = 4; mixer.file = "43j-fourwaymix.jxs"; mixer.activeinput = 0; //mixer.texture = ["cursor", "backdrop"]; mixer.jit_gl_texture("cursor"); mixer.param = 0.9; var displaycombined = new JitterObject("jit.gl.videoplane", "editor"); displaycombined.blend_enable = 1; displaycombined.transform_reset = 2; displaycombined.jit_gl_texture(mixer.out_name);
    function bang () { cursorsel.draw(); myrender.erase(); myrender.drawclients(); myrender.swap(); }
    This is the patch its based on: [ mod - removed uncompressed patch ]

    • Dec 29 2021 | 5:19 pm
      zip up the js and max patch and attach here and I'll take a look
    • Dec 29 2021 | 7:28 pm
      Hi Rob,
      Thanks a lot for taking a look. Ive attached the js, the js patch and the patch Im trying to translate in a zip.
      Many Thanks
      Paul
    • Jan 17 2022 | 7:45 pm
      Hi Rob, Did you get a chance to take a look at this?
    • Jan 18 2022 | 7:27 pm
      Hi Paul, the problem was that jit.gl.slab needs to draw in order to render the textures. Also the way you were sending the "param" was incorrect: "param" in this case is a function, not an attribute, and needs the name of the param you are modifying. I've added the function "notifydeleted" which is called everytime you delete the JS object. It's necessary to free the memory occupied by the GL objects you create in the script. Let me know if you have other problems! Federico
    • Jan 19 2022 | 7:03 pm
      Thanks so much Federico I really appreciate this! Im pretty new to JS in Jitter. I havent seen some of this stuff in the documentation unless Im missing something. Do you have a link to any good reference sources ?
    • Jan 19 2022 | 8:13 pm
      Very glad it works Paul! Honestly I could not say where to find specific documentation about this, I've just tried with the "draw" message and it worked. Sometimes you just have to try all the possibilities out : ) Regarding the "freepeer" thing, I think is highlighted in some examples, although I could not say at the moment which one.