Jitter bug report: exportattrs

Dec 18, 2006 at 5:06pm

Jitter bug report: exportattrs

When sending the ‘exportattrs’ message to a jitter gl object max crashes
The ‘exportsummary’ doesn’t work either, with gl objects, but doesn’t crash the application.

Jitter version 1.6.3b2
Platform: Mac 10.4.8, powerbook ppc 1.5Ghz

I’ve tried on a number of different gl objects each time resulting in a crash. No other object or patch needs to be open.

pelado

#29284
Dec 18, 2006 at 5:12pm

Thanks for the report.

But why are you sending the “exportattrs” message to a Jitter GL
object? The “getattributes” and “getstate” messages are intended for
end users. The “export…” variety aren’t (and aren’t documented for
this reason).

jb

Am 18.12.2006 um 18:06 schrieb pelado:

>
> When sending the ‘exportattrs’ message to a jitter gl object max
> crashes
> The ‘exportsummary’ doesn’t work either, with gl objects, but
> doesn’t crash the application.
>
> Jitter version 1.6.3b2
> Platform: Mac 10.4.8, powerbook ppc 1.5Ghz
>
> I’ve tried on a number of different gl objects each time resulting
> in a crash. No other object or patch needs to be open.
>
> pelado

#91093
Dec 18, 2006 at 5:21pm

>When sending the ‘exportattrs’ message to a jitter gl object max crashes
>The ‘exportsummary’ doesn’t work either, with gl objects, but
>doesn’t crash the application.

a quick look at the online manuals would suggest that there’s not
listing for the exportattrs message, nor for exportsummary. You’re
supposed to be using getattributes and gestate to do this. In general
if a message or attribute isn’t listed in the reference manual, it’s not
meant to be used by you [i.e., it serves an internal purpose rather than
an end-user one].

That’s a general truism, I think.

gregory

on the floor there’s a long wooden table/on the table there’s an open book/
on the page there’s a detailed drawing/and on the drawing is the name I took
Gregory Taylor http://www.rtqe.net

#91094
Dec 18, 2006 at 11:38pm

Many of the Jitter GL attributes are not documented and are presumably meant for end users (something I find frustrating and hope can be corrected for the next full release). The exportattrs message actually is in the Jitter Reference documents that I have, presumably installed by the installer for the latest beta version. It states that an xml file containing the values for all attributes of an object will be exported to disk. I thought it might be a way of saving current state either for retrieving later or even importing into a different patch. Just trying things out!

Actually, I’ve been working on a generic patch that enables simple and quick access to all the attributes and messages of GL objects. With the hundreds that are available and my desire to fathom out what each one does it seemed like a good idea. exportattrs is one of the responses to the query ‘summary’

Anyway I won’t touch them again!

pelado

http://www.pelado.co.uk

#91095
Dec 18, 2006 at 11:43pm

> Many of the Jitter GL attributes are not documented and are presumably meant for end users (something I find frustrating and hope can be corrected for the next full release).

This is not exactly true. Have you looked at this file:
patches/JitterReference/group-GL.html? This is where the majority of
the OpenGL object attributes are documented. The jit.gl.* objects
share alot of functionality by nature, so to avoid redundant
documentation, this can all be found in the group-GL.html file.

wes

#91096
Dec 19, 2006 at 12:29am

Yes of course, you’re right. There are a few not covered, but I also think there are a few which leave me wanting a bit more detail, like the one you attempted to cover recently, transform_reset. My frustration lies more in the messages for glsketch which I know is getting out of the remit of Jitter reference coverage.

By the way, I got the detail about exportattrs from the file patches/JitterReference/group-all.html

pelado

#91097
Dec 19, 2006 at 12:45am

On Dec 18, 2006, at 3:38 PM, pelado wrote:

> The exportattrs message actually is in the Jitter Reference
> documents that I have, presumably installed by the installer for
> the latest beta version. It states that an xml file containing the
> values for all attributes of an object will be exported to disk. I
> thought it might be a way of saving current state either for
> retrieving later or even importing into a different patch. Just
> trying things out!

This is true, and thanks for your report. We’ll try to fix the crash
for this underused functionality in a future version (probably won’t
make it into 1.6.3).

Glad to hear you got what you needed working using the summary message.

-Joshua

#91098
Dec 19, 2006 at 12:48am

On Dec 18, 2006, at 4:29 PM, pelado wrote:

> My frustration lies more in the messages for glsketch which I know
> is getting out of the remit of Jitter reference coverage.

Yes. There’s a lot of functionality exposed there, which we
unfortunately don’t have the resources to document fully. As
mentioned a bajilliion times. Check out the Sketch tutorial in the
Jitter tutorials, OpenGL RedBook, NeHE’s tutorials, and other online
OpenGL resources.

-Joshua

#91099
Dec 19, 2006 at 2:35am

To help you out with this OpenGL business, Here is what is actually
called when certain jit.gl.* attributes are set. When an object gets
the draw() commands, this is what happens

ob3d_draw_begin()
ob3d_draw_preamble()
————–Object does its thing
ob3d_draw_end()

Hopefully this will shed some light on the subject for you.

wes

t_jit_err ob3d_draw_begin(void *v, long setup)
{
long i, flags, do_setup=0;
t_jit_ob3d * ob3d = (t_jit_ob3d *)v;
t_symbol *s[1];

// get class ob3d flags.
flags = ob3d->class3d->flags;

if (!ob3d->renderer) {
//post(“warning attempting to draw with invalid renderer pointer”);
return JIT_ERR_GENERIC;
}

for(i = 0; i < ob3d->capturecount; i++)
{
jit_gl_dobegincapture(ob3d,ob3d->capture[i],i);
jit_gl_report_error(“ob3d_draw_begin capture”);
}

if (!jit_gl_get_context())
{
error(“ob3d_draw_begin: no context”);
return JIT_ERR_GENERIC;
}

glNormal3f(0., 1., 0.); // prevent old normals from “leaking through”

if (_jit_glattribpush) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
jit_gl_report_error(“ob3d_draw_begin push attr”);
}

if (!ob3d->inherit_transform)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
jit_gl_report_error(“ob3d_draw_begin pushmatrix”);
}

ob3d_draw_preamble(ob3d);
jit_gl_report_error(“ob3d_draw_begin preamble”);

return JIT_ERR_NONE;
}

long ob3d_draw_end(void *v, long setup)
{
long flags;
int i;
t_jit_ob3d * ob3d = (t_jit_ob3d *)v;
t_jit_gl_context ctx=NULL;

// get class ob3d flags.
flags = ob3d->class3d->flags;

if (!(ctx=jit_gl_get_context())) {
error(“ob3d_draw_end: no context”);
return JIT_ERR_GENERIC;
}

// multi texturing support via gl.texture
for(i = 0; i < ob3d->texturecount; i++)
{
jit_gl_dounbindtexture(ob3d, ob3d->texture[i], i);
jit_gl_report_error(“ob3d_draw_end texture”);
}
// force texture 0 as active
if (ctx->support->multitexture)
glActiveTextureARB(GL_TEXTURE0_ARB);

if (ob3d->shader!=_jit_sym_nothing)
{
t_atom a;
t_jit_object *o = NULL;

// find registered gl.shader object with given name
o = jit_object_findregistered(ob3d->shader);
if (o && jit_object_classname(o) == ps_jit_gl_shader)
{
// pass ob3d to shader
jit_atom_setobj(&a, ob3d->jitob);
jit_object_method(o, ps_unbind, ps_unbind, 1, &a);
}
}

if (ob3d->tex_map)
{
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}

if (ob3d->axes)
{
// RGB axes utility
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
// x
glBegin(GL_LINES);
glColor3f(4., 0., 0.);
glVertex3f(0., 0., 0.);
glVertex3f(4., 0., 0.);
glEnd();
for (i=1;i<5;i++)
{
glBegin(GL_LINE_LOOP);
glVertex3f(i*1., 0.01, 0.01);
glVertex3f(i*1., 0.01, -0.01);
glVertex3f(i*1., -0.01, -0.01);
glVertex3f(i*1., -0.01, 0.01);
glEnd();
}
// y
glBegin(GL_LINES);
glColor3f(0., 4., 0.);
glVertex3f(0., 0., 0.);
glVertex3f(0., 4., 0.);
glEnd();
for (i=1;i<5;i++)
{
glBegin(GL_LINE_LOOP);
glVertex3f(0.01, i*1., 0.01);
glVertex3f(0.01, i*1., -0.01);
glVertex3f(-0.01, i*1., -0.01);
glVertex3f(-0.01, i*1., 0.01);
glEnd();
}
// z
glBegin(GL_LINES);
glColor3f(0., 0., 4.);
glVertex3f(0., 0., 0.);
glVertex3f(0., 0., 4.);
glEnd();
for (i=1;i<5;i++)
{
glBegin(GL_LINE_LOOP);
glVertex3f(0.01, 0.01, i*1.);
glVertex3f(0.01, -0.01, i*1.);
glVertex3f(-0.01, -0.01, i*1.);
glVertex3f(-0.01, 0.01, i*1.);
glEnd();
}
jit_gl_report_error(“ob3d_draw_end axes”);
}

if (!ob3d->inherit_transform)
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
jit_gl_report_error(“ob3d_draw_end popmatrix”);
}

// render to texture support via gl.texture
for(i = 0; i < ob3d->capturecount; i++)
{
jit_gl_doendcapture(ob3d,ob3d->capture[i],i);
jit_gl_report_error(“ob3d_draw_end capture”);
}

if (_jit_glattribpush) {
glPopAttrib();
jit_gl_report_error(“ob3d_draw_end popattrib”);
}

return JIT_ERR_NONE;
}

// set up OpenGL machine with ob3d instance info
long ob3d_draw_preamble(void *v)
{
long i;
long flags;
void * r;
GLdouble aspect;
float mat[16];
t_jit_ob3d * ob3d = (t_jit_ob3d *)v;
float angle;

if (!ob3d) return JIT_ERR_GENERIC;

// get class ob3d flags.
flags = ob3d->class3d->flags;

if (ob3d->inherit_all) return JIT_ERR_NONE;

jit_gl_report_error(“ob3d_draw_preamble initial”);

if (!ob3d->inherit_poly)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_POLY_VARS))
{
// poly mode
switch (ob3d->poly_mode[0]) {
case 2: glPolygonMode(GL_FRONT, GL_POINT); break;
case 1: glPolygonMode(GL_FRONT, GL_LINE); break;
default: glPolygonMode(GL_FRONT, GL_FILL); break;
}
switch (ob3d->poly_mode[1]) {
case 2: glPolygonMode(GL_BACK, GL_POINT); break;
case 1: glPolygonMode(GL_BACK, GL_LINE); break;
default: glPolygonMode(GL_BACK, GL_FILL); break;
}
jit_gl_report_error(“ob3d_draw_preamble poly_mode”);

// cull faces
if (ob3d->cull_face)
{
glEnable(GL_CULL_FACE);
glCullFace((ob3d->cull_face == 1) ? GL_BACK : GL_FRONT);
}
else
{
glDisable(GL_CULL_FACE);
}
jit_gl_report_error(“ob3d_draw_preamble cull_face”);

// points and lines
glPointSize(ob3d->point_size);
glLineWidth(ob3d->line_width);
jit_gl_report_error(“ob3d_draw_preamble point+line”);
}

if (!GET_FLAG(flags, JIT_OB3D_NO_ANTIALIAS))
{
// antialiasing
if (ob3d->antialias)
{
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
}
else
{
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_SMOOTH);
}
jit_gl_report_error(“ob3d_draw_preamble antialias”);
}
}

if (!ob3d->inherit_depth)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_DEPTH))
{
// depth
if (ob3d->depth_enable)
{
glEnable(GL_DEPTH_TEST);
}
else
{
glDisable(GL_DEPTH_TEST);
}
jit_gl_report_error(“ob3d_draw_preamble depth”);
if (ob3d->depth_clear)
{
glClear(GL_DEPTH_BUFFER_BIT);
jit_gl_report_error(“ob3d_draw_preamble depth_clear”);
}
}
}

if (!ob3d->inherit_fog)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_FOG))
{
// fog
if (ob3d->fog)
{
glEnable(GL_FOG);
glHint(GL_FOG_HINT, GL_NICEST);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, ob3d->fog_params);
glFogf(GL_FOG_DENSITY, ob3d->fog_params[4]);
glFogf(GL_FOG_START, ob3d->fog_params[5]);
glFogf(GL_FOG_END, ob3d->fog_params[6]);
}
else
{
glDisable(GL_FOG);
}
jit_gl_report_error(“ob3d_draw_preamble fog”);
}
}

if (!ob3d->inherit_color)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_COLOR))
{
// default draw color, alpha controls texture blending.
glColor4fv(ob3d->color);

// shade model
if (ob3d->smooth_shading)
{
glShadeModel(GL_SMOOTH);
}
else
{
glShadeModel(GL_FLAT);
}
jit_gl_report_error(“ob3d_draw_preamble smooth shading”);
}

if (!GET_FLAG(flags, JIT_OB3D_NO_BLEND))
{
// blend
if (ob3d->blend_enable)
{
int b0, b1;
b0 = jit_gl_get_blend_mode(ob3d->blend_mode[0]);
b1 = jit_gl_get_blend_mode(MIN(ob3d->blend_mode[1],9));
glEnable(GL_BLEND);
glBlendFunc(b0, b1);
}
else
{
glDisable(GL_BLEND);
}
jit_gl_report_error(“ob3d_draw_preamble blend”);
}
}

if (!ob3d->inherit_texture)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_TEXTURE))
{
// multi texturing support via gl.texture
for(i = 0; i < ob3d->texturecount; i++)
{
jit_gl_dobindtexture(ob3d,ob3d->texture[i],i);
jit_gl_report_error(“ob3d_draw_preamble render multitexture”);
}

// 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;
}

jit_gl_report_error(“ob3d_draw_preamble texture mode”);

}
}

if (!ob3d->inherit_material)
{
if (!GET_FLAG(flags, JIT_OB3D_NO_LIGHTING_MATERIAL))
{
if (GET_FLAG(flags, JIT_OB3D_HAS_LIGHTS))
{
glLightfv(GL_LIGHT0, GL_AMBIENT, ob3d->light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, ob3d->light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, ob3d->light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, ob3d->light_position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ob3d->light_global_ambient);
}

if (ob3d->lighting_enable)
{
if (ob3d->two_sided) // default auto mode: set diffuse color
{
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
}
else
{
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
}
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
if (ob3d->auto_material) // default auto mode: set diffuse color
{
float mv[4] = {0.f,0.f,0.f,1.f};
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ob3d->color);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ob3d->color);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mv);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mv);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.);
}
else // complete material specification
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ob3d->mat_ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ob3d->mat_diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ob3d->mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, ob3d->mat_emission);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, ob3d->shininess);
}
}
else
{
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glDisable(GL_NORMALIZE);
}
jit_gl_report_error(“ob3d_draw_preamble render lights”);
} else {
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glDisable(GL_NORMALIZE);
}
}

// transformation
if (!ob3d->inherit_transform)
{
aspect = (GLdouble)ob3d->dest_dim[0] / (GLdouble)ob3d->dest_dim[1];

if (GET_FLAG(flags, JIT_OB3D_HAS_CAMERA))
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
switch (ob3d->ortho)
{
case 2:
glOrtho(-aspect, aspect, -1.0, 1.0, ob3d->near_clip, ob3d->far_clip);
break;
case 0:
gluPerspective(ob3d->lens_angle, aspect, ob3d->near_clip, ob3d->far_clip);
break;
default:
orthoView(ob3d->lens_angle, aspect, ob3d->near_clip, ob3d->far_clip);
}

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(ob3d->camera[0], ob3d->camera[1], ob3d->camera[2],
ob3d->lookat[0], ob3d->lookat[1], ob3d->lookat[2],
ob3d->up[0], ob3d->up[1], ob3d->up[2]);
jit_gl_report_error(“ob3d_draw_preamble camera”);
}

if (ob3d->transform_reset) {
float near_clip=-100.;
float far_clip=100.;
float lens_angle=45.;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
switch (ob3d->transform_reset)
{
case 1:
glOrtho(-aspect, aspect, -1.0, 1.0, near_clip, far_clip);
break;
case 2:
glOrtho(-1.0, 1.0, -1.0, 1.0, near_clip, far_clip);
break;
case 3:
gluPerspective(lens_angle, aspect, 0.001/*near_clip*/, far_clip);
break;
case 4:
gluPerspective(lens_angle, 1.0, 0.001/*near_clip*/, far_clip);
break;
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
jit_gl_report_error(“ob3d_draw_preamble transform_reset”);
}

glMatrixMode(GL_MODELVIEW);

// perform standard transformation
glTranslatef(ob3d->position[0], ob3d->position[1], ob3d->position[2]);
glRotatef(ob3d->rotation[0], ob3d->rotation[1], ob3d->rotation[2],
ob3d->rotation[3]);
glScalef(ob3d->scale[0], ob3d->scale[1], ob3d->scale[2]);

jit_gl_report_error(“ob3d_draw_preamble transform”);
}

if (ob3d->shader!=_jit_sym_nothing)
{
t_atom a;
t_jit_object *o = NULL;

// find registered gl.shader object with given name
o = jit_object_findregistered(ob3d->shader);
if (o && jit_object_classname(o) == ps_jit_gl_shader)
{
// pass ob3d to shader
jit_atom_setobj(&a, ob3d->jitob);
jit_object_method(o, ps_bind, ps_bind, 1, &a);
}
jit_gl_report_error(“ob3d_draw_preamble shader”);
}

return JIT_ERR_NONE;
}

#91100
Dec 19, 2006 at 3:53am

#91101
Dec 21, 2006 at 4:46pm

#91102

You must be logged in to reply to this topic.