Re: adding tex_map into gl_commands routine


    Oct 24 2006 | 6:48 pm
    On Oct 23, 2006, at 5:43 AM, yair reshef wrote:
    > hi, i am trying to specify tex_map and tex_map_plane for a
    > gl_commands command.
    > my current command: reset, glenable texture, glbindtexture
    > echo_tex, shapeslice 40, cylinder $1 $2 0. $3 $4, gldisable
    > texture, gldisable
    >
    > i want to add to this:
    > tex_map 1, tex_plane_s 0.5 0. 0. 0.5, tex_plane_t 0. -0.6 0. 0.5
    You can't intermix standard jitter object attributes with opengl
    commands inside a jit.gl.sketch command list, unless you're using
    "immediate" mode (which should probably only be used from JS/Java/C).
    I would recommend using the corresponding OpenGL calls to accomplish
    this.
    In OpenGL, these attributes correspond to the following C code. Of
    course, you'll want to convert to appropriate jit.gl.sketch syntax
    (convert everything to lower case, remove GL_ from the beginning of
    symbolic constants, etc.).
    // texture mapping modes
    switch (ob3d->tex_map)
    {
    case 1:
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
    glTexGenfv(GL_S, GL_OBJECT_PLANE, ob3d->tex_plane_s);
    glTexGenfv(GL_T, GL_OBJECT_PLANE, ob3d->tex_plane_t);
    break;
    case 2:
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    break;
    case 3:
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
    glTexGenfv(GL_S, GL_EYE_PLANE, ob3d->tex_plane_s);
    glTexGenfv(GL_T, GL_EYE_PLANE, ob3d->tex_plane_t);
    break;
    default:
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);
    break;
    }
    Hope this helps.
    -Joshua

    • Aug 29 2011 | 4:29 pm
      Hi
      Very old post I know. Trying to do something similar in gl I think (outside of gl it's the same as Wesleys patch here: http://cycling74.com/forums/topic.php?id=8353#post-45095 with tex_map 3 instead of 1).
      So is it this one I should be using?
      glenable texture_gen_s,
      glenable texture_gen_t,
      gltexgeni s, texture_gen_mode, eye_linear,
      gltexgeni t, texture_gen_mode, eye_linear,
      gltexgenfv s, eye_plane, ob3d->tex_plane_s,
      gltexgenfv t, eye_plane, ob3d->tex_plane_t,
      Shouldn't there be numbers somewhere to do the mapping? Thanks in advance.
      Garrett
      Wesleys patch with that tiny change to illustrate what I mean.