javascript jit.gl.sketch opengl texture parameters


    Mar 19 2006 | 2:51 am
    Hi
    I'm trying to get the various gltexture parameters to work in a Javascript jit.gl.sketch object. Some stuff seems to work, some doesn't.
    Any help and advice would be appreciated; I'm not sure that all my syntax is correct. I'm trying to follow OpenGL commands, but it's not always clear how they translate into jitter/javascript/jit.gl.sketch/glcommand-speak; the documentation of this area remains a bit spotty.
    //this works: mySketch.glbindtexture(myImage.texture);
    //this works: mySketch.glenable("texture_gen_s"); mySketch.glenable("texture_gen_t");
    //this doesn't seem to do anything: mySketch.glenable("texture_gen_r");
    //this reduces texture to 2 x 2 grid, can't get anything to affect it: mySketch.glenable("texture_gen_q");
    //these lines have no effect, texture remains clamped: mySketch.gltexparameter("wrap_s","repeat"); mySketch.gltexparameter("wrap_t","repeat");
    //this makes the texture negative; however, 'modulate', 'decal' and 'replace' have no effect: mySketch.gltexenv("mode","blend");
    //in this mode, the texture remains a small image in the middle of the object, with edge pixels blurred rest of way (clamped); other settings (such as wrap/repeat) have no effect: mySketch.gltexgen("s","texture_gen_mode","object_linear "); mySketch.gltexgen("t","texture_gen_mode","object_linear ");
    //works: mySketch.gltexgen("s","texture_gen_mode","sphere_map"); mySketch.gltexgen("t","texture_gen_mode","sphere_map");
    //exactly the same as 'object linear': mySketch.gltexgen("s","texture_gen_mode","eye_linear"); mySketch.gltexgen("t","texture_gen_mode","eye_linear");
    //draw plane: mySketch.glbegin("polygon"); mySketch.gltexcoord(1,0,0,1);mySketch.glvertex(-1,-1,0); mySketch.gltexcoord(0,0,0,1); mySketch.glvertex(1,-1,0); mySketch.gltexcoord(0,1,0,1); mySketch.glvertex(1,1,0); mySketch.gltexcoord(1,1,0,1); mySketch.glvertex(-1,1,0); mySketch.glend();
    Running on a 1mHz Powerbook G4 OS X 10.4.5. Latest Max + Jitter.
    Also, if there happen to be any additional javascript/jit.gl.sketch/opengl texture commands/parameters that aren't documented, I'd love to know about them.
    pH

    • Mar 19 2006 | 11:40 pm
      On Mar 18, 2006, at 6:51 PM, Perry Hoberman wrote:
      > //this doesn't seem to do anything: > mySketch.glenable("texture_gen_r"); > > //this reduces texture to 2 x 2 grid, can't get anything to affect it: > mySketch.glenable("texture_gen_q");
      r and q texture coordinate generation is not currently supported in jitter. What do you need them for?
      > //these lines have no effect, texture remains clamped: > mySketch.gltexparameter("wrap_s","repeat"); > mySketch.gltexparameter("wrap_t","repeat");
      Most likely you are using a rectangular texture which does not support the other wrap modes on certain HW/Drivers. Use poer of two textures by jit.gl.texture @rectangle 0. This is not a jitter limitation.
      > //this makes the texture negative; however, 'modulate', 'decal' and > 'replace' have no effect: > mySketch.gltexenv("mode","blend");
      This is for multi-texturing. Please see the RedBook chapters or recent mailing list discussions on multitexturing for more info (it is somewhat complicated, and out of the scope of our documentation to cover). A fix for the combine blend mode is forthcoming. In sketch you can provide a second argument for the . Also note you can bind shaders with glbindprogram/glunbindprogram(), if you want to use a shader program for determining texture blending. You can also use a shader program to overcome texture clamping limitations of rectangular textures FWIW, by doing your own texture coordinate math in the shader to wrap within the unclamped range.
      See archives for an example of shader use from within sketch.
      > //in this mode, the texture remains a small image in the middle of > the object, with edge pixels blurred rest of way (clamped); other > settings (such as wrap/repeat) have no effect: > mySketch.gltexgen("s","texture_gen_mode","object_linear "); > mySketch.gltexgen("t","texture_gen_mode","object_linear ");
      This is to be expected if the texture type does not support repeat wrap modes. Note that you can zoom in/out using the texture matrix transform (glmatrixmode).
      Hope this helps. For the most part everything in sketch just maps clearly to the documentation from the Red Book, provided that you understand HW/Driver limitations.
      -Joshua