Forums > Javascript

'immediate' attribute, drawobject & automatic 0

March 30, 2007 | 5:39 am

Hi -

I’m getting an odd result when using jit.gl.sketch with the ‘immediate’ attribute.

In the attached patch/javascript, I’ve got some jit.gl.gridshapes, which I’m drawing inside of a jit.gl.sketch object using the ‘drawobject’ command. This works as expected.

However, when I flip the toggle so that a second jit.gl.sketch object is drawn inside the first (also using ‘drawobject’), the lighting on the gridshapes goes away – and it doesn’t come back after the sketch object is toggled off.

In fact, the lighting stays off when the js is recompiled, and doesn’t come back until the patch is closed and reopened.

The automatic attribute (which I’ve set to 0 on the gridshapes and the nested sketch object as usual) doesn’t actually seem to have any effect in immediate mode.

Does ‘immediate 1′ override ‘automatic 0′?

And is there some reason I can’t use drawobject with a gridshape and a sketch object at the same time?


March 30, 2007 | 10:23 pm

On Mar 29, 2007, at 10:39 PM, Perry Hoberman wrote:

> However, when I flip the toggle so that a second jit.gl.sketch
> object is drawn inside the first (also using ‘drawobject’), the
> lighting on the gridshapes goes away – and it doesn’t come back
> after the sketch object is toggled off.
>
> In fact, the lighting stays off when the js is recompiled, and
> doesn’t come back until the patch is closed and reopened.

I think that this is the same issue as the other lighting state bleed
I need to solve for the next 1.6.3 beta. For now you should be able
to solve your problems with something like the following, though I
haven’t had the time to test explicitly. This pushes OpenGL attribute
stack and pops it so that there should be no state bleed through.

sketch.glpushattrib(); // no argument, always calls glPushAttrib
(GL_ALL_ATTRIB_BITS) inside

sketch.drawobject(othersketch.name,1);

sketch.glpopattrib();

> The automatic attribute (which I’ve set to 0 on the gridshapes and
> the nested sketch object as usual) doesn’t actually seem to have
> any effect in immediate mode.

Please clarify what you mean by "no effect". calling drawobject on an
object regardless of the context ignores automatic attribute.

> Does ‘immediate 1′ override ‘automatic 0′?

Not technically, but with immediate mode set to 1, no commands are
added to the commandlist. In theory, by toggling immediate on/off you
could use one instance of jit.gl.sketch for both immediate and cached
mode (automatic) rendering.

> And is there some reason I can’t use drawobject with a gridshape
> and a sketch object at the same time?

Nope. Let us know if it’s not related to the state bleed through.

-Joshua


March 31, 2007 | 12:46 am

yep, that does the trick. Now I can draw all kinds of globjects in immediate mode to my heart’s content.

>Please clarify what you mean by "no effect". calling drawobject on an
>object regardless of the context ignores automatic attribute.

Right. I’m just used to toggling ‘automatic’ and seeing the default instance of the globject appear/disappear, but of course that doesn’t happen in immediate mode. Still getting my brain around all this.

thanks yet again

- pH


Viewing 3 posts - 1 through 3 (of 3 total)