Forums > Jitter

sketch drawobject() efficiency

June 6, 2006 | 2:10 pm

Hi, I’m using sketch to draw a number of basic gridshapes and I’m having
problems with my cpu load rising really fast when I increase the number of
shapes. I can only render about 100 of them at 30fps. I tried to optimize
the code so that every "draw" command solely triggers the drawing and
nothing else. The code is listed below. Am I doing something stupid or is
drawobject just not the way to do this?

- thijs

using pentium m1.86 jitter 1.5.2 max 4.5.6 nvidia go6800

nPhotoContact.prototype.draw = function()
{
var tmp = new JitterObject("jit.hello"); // trigger garbage collection
to fix memory leak

with(mysketch)
{
reset();
glmatrixmode("modelview");
glloadidentity();
glulookat(0., 0., 5., 0., 0., 0., 0., 1., 0.);

this.draw_planes(); // draw objects
draw(); // draw sketch to context
}
}

nPhotoContact.prototype.draw_planes = function()
{
var N = this.m_screencount_x *this.m_screencount_y;
for(var i=0; i
{
mysketch.drawobject(this.m_context+".obj_"+i, 0); // draw
jit.gl.gridshapes
}
}


June 6, 2006 | 5:53 pm

On Jun 6, 2006, at 7:10 AM, Thijs Koerselman wrote:

> Hi, I’m using sketch to draw a number of basic gridshapes and I’m
> having problems with my cpu load rising really fast when I increase
> the number of shapes. I can only render about 100 of them at 30fps.
> I tried to optimize the code so that every "draw" command solely
> triggers the drawing and nothing else. The code is listed below. Am
> I doing something stupid or is drawobject just not the way to do this?

I would recommend setting the displaylist attribute for the target
object to draw, and then using the ignore object attributes flag for
draw object. This should speed things up a bit. Lastly, you might
want to decrease the number of vertices for each gridshape.

In Jitter 1.5.3/1.6 there are some faster ways coming to render
multiple objects, general improvements to jit.gl.sketch, and bug
fixes for multiple objects with displaylist attributes set to true.

-Joshua


June 8, 2006 | 6:52 pm

Thanks Joshua,

deceasing @dim improved the overall performance. I can’t use the ignore
attributes flag, because every plane has it’s own texture, and alpha. I’m
also changing textures, positions and rotation all the time. Sometimes for
every frame, so I guess displaylists are also out of the question.
I’m glad to hear that 1.5.3 will improve on some of this. Im very much
looking forward to the new updates. I guess it will also be worth porting my
code to Java.

best, -thijs

On 6/6/06, Joshua Kit Clayton wrote:
>
>
> On Jun 6, 2006, at 7:10 AM, Thijs Koerselman wrote:
>
> > Hi, I’m using sketch to draw a number of basic gridshapes and I’m
> > having problems with my cpu load rising really fast when I increase
> > the number of shapes. I can only render about 100 of them at 30fps.
> > I tried to optimize the code so that every "draw" command solely
> > triggers the drawing and nothing else. The code is listed below. Am
> > I doing something stupid or is drawobject just not the way to do this?
>
> I would recommend setting the displaylist attribute for the target
> object to draw, and then using the ignore object attributes flag for
> draw object. This should speed things up a bit. Lastly, you might
> want to decrease the number of vertices for each gridshape.
>
> In Jitter 1.5.3/1.6 there are some faster ways coming to render
> multiple objects, general improvements to jit.gl.sketch, and bug
> fixes for multiple objects with displaylist attributes set to true.
>
> -Joshua
>
>


June 8, 2006 | 7:03 pm

On Jun 8, 2006, at 11:52 AM, Thijs Koerselman wrote:

> deceasing @dim improved the overall performance. I can’t use the
> ignore attributes flag, because every plane has it’s own texture,
> and alpha. I’m also changing textures, positions and rotation all
> the time. Sometimes for every frame, so I guess displaylists are
> also out of the question.
> I’m glad to hear that 1.5.3 will improve on some of this. Im very
> much looking forward to the new updates. I guess it will also be
> worth porting my code to Java.

You can, FWIW, use displaylists which are only applicable to the
geometry. However there’s a bug in 1.5.2 for mulitple instances of
gridshape or nurbs with @displaylist 1. Here’s how I might do it: use
one instance of jit.gl.gridshape wiht @displaylist on, use ignore
attributes, and then update the gl state in sketch for each plane to
render.

In Jitter 1.5.3/sketch there is a jit.gl.multiple object which takes
incoming matrices for position, rotation, texture, etc. to draw many
instances of one object with much higher performance than doing this
in the patcher or JS.

-Joshua


June 8, 2006 | 10:33 pm

Thanks I’ll try that. jit.gl.multiple sounds really great!

-thijs

On 6/8/06, Joshua Kit Clayton wrote:
>
>
>
> You can, FWIW, use displaylists which are only applicable to the
> geometry. However there’s a bug in 1.5.2 for mulitple instances of
> gridshape or nurbs with @displaylist 1. Here’s how I might do it: use
> one instance of jit.gl.gridshape wiht @displaylist on, use ignore
> attributes, and then update the gl state in sketch for each plane to
> render.
>
> In Jitter 1.5.3/sketch there is a jit.gl.multiple object which takes
> incoming matrices for position, rotation, texture, etc. to draw many
> instances of one object with much higher performance than doing this
> in the patcher or JS.
>
> -Joshua
>


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