Hi Pieter,

As far as I understand, draw_handles is called constantly for different
rendering events (draw_lines, draw_solid, etc) in a certain ViewerContext.
There's different strategies you can take to reduce the number of times your
own stuff is calculated / drawn.

- Limit any drawing to happen only when the viewer is in 2D or 3D mode.

Ex.
  // Don't draw anything unless viewer is in 3d mode:
  if (ctx->transform_mode() == VIEWER_2D) return;

- Restrict any drawing to happen only during a specific drawing pass:

Ex.

if (!ctx->draw_unpickable_lines()) return;
// Continue here. The following will only be executed when draw_handles() is
called for a line drawing pass.

- If the stuff you're trying to draw is rather heavy to calculate, build and
compile a glList in build_handles(), and then call the list in
draw_handles() to render it.

- If you want to make sure you're only re-calculating your list (or whatever
drawing routine) after certain things change (like a frame change, or a knob
change), create a Hash instance, fill it up with all the variables whose
change should trigger an update, and avoid re-calculation until the hash
changes.

Ex.
  Hash oldHash;
  Hash newHash;
  ...
  ...
// in build_handles()

  oldHash.append(var1) // var1 being the variable one of your knobs is
changing
  oldHash.append(var2) // etc
  oldHash.append(OutputContext().frame()) // to append the frame number

  // or just add the hash from the inputs if your drawing should also update
if an incoming Iop changes
  oldHash.append(input0()->hash())


Hopefully that will give you a few ideas. I've gathered those over time
following very useful advice from people in this list, and found them to be
very useful when trying to have a bit more control over when exactly things
should be drawn, and when to do any heavy lifting.

Cheers,
Ivan


On Fri, May 20, 2011 at 1:05 PM, PieterVanHouten <
nuke-dev-re...@thefoundry.co.uk> wrote:

>  hello
>
> so i have a small question about that. is draw_handles() the only place
> where i can safely call and render my own opengl shaders and such into my
> own render context?
>
> i found out that i can't rely on _open doing my gl rendering calls
> (sometimes it works, sometimes it doesn't because of the render context that
> seems to be locked)
>
> how often is draw_handles() updated? can't look into my code until
> monday...
>
> i am looking for a function that gets updated every frame and after every
> knob change.
>
> thank you
> pieter
>
> _______________________________________________
> Nuke-dev mailing list
> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>
>
_______________________________________________
Nuke-dev mailing list
Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to