simple openGL optimizations


    Aug 24 2006 | 3:26 am
    There are some abstractions missing from your text patch. Off the top
    of my head, you will probably want to use the gridshape attribute
    @displaylist 1. This caches the vertices on the graphics card. Also,
    if each gridshape is vertex-wise the same. You can use just 1
    gridshape with @automatic 0 set and give it the draw method along with
    any attrs you want to change for however many times you want to draw
    it. You can also use jit.gl.sketch's ability to draw named ob3d
    objects and use its ability to modify the OpenGL state machine to
    handle how your object looks and drawing it with the draw_raw method.
    HTH,
    wes

    • Aug 26 2006 | 9:43 pm
      Hey Wes,
      Sorry I'm slow on the response. Question: I see in another post you
      mention that there is a way to draw multiple objects by calling draw
      repeatedly--you say there was a javascript-dev thread about it recently
      (http://www.cycling74.com/forums/index.php?t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multiple+opengl#msg_64241).
      Is this something that can only be done with javascript? I'm a bit
      confused as to whether or not I can do this without using javascript,
      and how I would go about it--would you mind elaborating a bit on this,
      or pointing me in the direction of docs to tell me how I might do this?
      Many thanks!
      Dave
      Wesley Smith wrote:
      > There are some abstractions missing from your text patch. Off the top
      > of my head, you will probably want to use the gridshape attribute
      > @displaylist 1. This caches the vertices on the graphics card. Also,
      > if each gridshape is vertex-wise the same. You can use just 1
      > gridshape with @automatic 0 set and give it the draw method along with
      > any attrs you want to change for however many times you want to draw
      > it. You can also use jit.gl.sketch's ability to draw named ob3d
      > objects and use its ability to modify the OpenGL state machine to
      > handle how your object looks and drawing it with the draw_raw method.
      >
      > HTH,
      > wes
    • Aug 26 2006 | 9:50 pm
      if you set an ob3D with the attribute @automatic 0, you can bang once
      to draw, send a position -1 -1 -1, then bang again to draw again
      (assuming you havent banged jit.gl.render in the meantime).
      this way you can bang one object more than once to draw it more than
      once.
      something akin to:
      v a d e //
      www.vade.info
      abstrakt.vade.info
      On Aug 26, 2006, at 5:43 PM, Dave Della Costa wrote:
      > Hey Wes,
      >
      > Sorry I'm slow on the response. Question: I see in another post you
      > mention that there is a way to draw multiple objects by calling draw
      > repeatedly--you say there was a javascript-dev thread about it
      > recently
      > (http://www.cycling74.com/forums/index.php?
      > t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multipl
      > e+opengl#msg_64241).
      > Is this something that can only be done with javascript? I'm a bit
      > confused as to whether or not I can do this without using javascript,
      > and how I would go about it--would you mind elaborating a bit on this,
      > or pointing me in the direction of docs to tell me how I might do
      > this?
      >
      > Many thanks!
      >
      > Dave
      >
      >
      > Wesley Smith wrote:
      >> There are some abstractions missing from your text patch. Off the
      >> top
      >> of my head, you will probably want to use the gridshape attribute
      >> @displaylist 1. This caches the vertices on the graphics card.
      >> Also,
      >> if each gridshape is vertex-wise the same. You can use just 1
      >> gridshape with @automatic 0 set and give it the draw method along
      >> with
      >> any attrs you want to change for however many times you want to draw
      >> it. You can also use jit.gl.sketch's ability to draw named ob3d
      >> objects and use its ability to modify the OpenGL state machine to
      >> handle how your object looks and drawing it with the draw_raw method.
      >>
      >> HTH,
      >> wes
    • Aug 26 2006 | 9:53 pm
      You can do this without javascript, it's jsut going to be a pain in
      the arse. Is there are reason you don't want to use javascript? In
      any case, there are several options for drawing geometry multiple
      times:
      1) use jit.gl.multiple in jitter 1.6
      2) use javascript to manage drawing your objects in multiple ways
      3) use sketch to manage the opengl state machine and draw your object
      (JS or in a patch)
      4) use a ton of messages to control your object and how it is drawn
      If you opt to not use jit.gl.multiple, the most flexible way to do
      this is via JS. You can do some object oriented type stuff in JS to
      build a framework for drawing your geometry. This will be easy to
      manage as you add complexity. If you did this with message boxes in a
      patch, you would probably go insane. This was the point of the JS-dev
      post. Take a look at the script I posted and I think you will come to
      the same conclusion. If you don't know JS, it's not hard and it lets
      you do things that would otherwise be very tedious to do in a patch.
      best,
      wes
      On 8/26/06, Dave Della Costa wrote:
      > Hey Wes,
      >
      > Sorry I'm slow on the response. Question: I see in another post you
      > mention that there is a way to draw multiple objects by calling draw
      > repeatedly--you say there was a javascript-dev thread about it recently
      > (http://www.cycling74.com/forums/index.php?t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multiple+opengl#msg_64241).
      > Is this something that can only be done with javascript? I'm a bit
      > confused as to whether or not I can do this without using javascript,
      > and how I would go about it--would you mind elaborating a bit on this,
      > or pointing me in the direction of docs to tell me how I might do this?
      >
      > Many thanks!
      >
      > Dave
      >
      >
      > Wesley Smith wrote:
      > > There are some abstractions missing from your text patch. Off the top
      > > of my head, you will probably want to use the gridshape attribute
      > > @displaylist 1. This caches the vertices on the graphics card. Also,
      > > if each gridshape is vertex-wise the same. You can use just 1
      > > gridshape with @automatic 0 set and give it the draw method along with
      > > any attrs you want to change for however many times you want to draw
      > > it. You can also use jit.gl.sketch's ability to draw named ob3d
      > > objects and use its ability to modify the OpenGL state machine to
      > > handle how your object looks and drawing it with the draw_raw method.
      > >
      > > HTH,
      > > wes
      >
    • Aug 26 2006 | 10:10 pm
      Hey Wes,
      I don't really have any objection to using JS, in fact I like it, but
      I'm just trying to get a handle on what's going on in Max-world before I
      do that--this message explains that to my satisfaction though, thank
      you. I'm gonna mess around with it and check out your post (I think I
      found it here:
      http://www.cycling74.com/forums/index.php?t=msg&goto=62747&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=opengl#msg_62747)
      and see what I can get.
      Thanks again!
      Dave
      Wesley Smith wrote:
      > You can do this without javascript, it's jsut going to be a pain in
      > the arse. Is there are reason you don't want to use javascript? In
      > any case, there are several options for drawing geometry multiple
      > times:
      >
      > 1) use jit.gl.multiple in jitter 1.6
      > 2) use javascript to manage drawing your objects in multiple ways
      > 3) use sketch to manage the opengl state machine and draw your object
      > (JS or in a patch)
      > 4) use a ton of messages to control your object and how it is drawn
      >
      > If you opt to not use jit.gl.multiple, the most flexible way to do
      > this is via JS. You can do some object oriented type stuff in JS to
      > build a framework for drawing your geometry. This will be easy to
      > manage as you add complexity. If you did this with message boxes in a
      > patch, you would probably go insane. This was the point of the JS-dev
      > post. Take a look at the script I posted and I think you will come to
      > the same conclusion. If you don't know JS, it's not hard and it lets
      > you do things that would otherwise be very tedious to do in a patch.
      >
      > best,
      > wes
      >
      > On 8/26/06, Dave Della Costa wrote:
      >> Hey Wes,
      >>
      >> Sorry I'm slow on the response. Question: I see in another post you
      >> mention that there is a way to draw multiple objects by calling draw
      >> repeatedly--you say there was a javascript-dev thread about it recently
      >> (http://www.cycling74.com/forums/index.php?t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multiple+opengl#msg_64241).
      >>
      >> Is this something that can only be done with javascript? I'm a bit
      >> confused as to whether or not I can do this without using javascript,
      >> and how I would go about it--would you mind elaborating a bit on this,
      >> or pointing me in the direction of docs to tell me how I might do this?
      >>
      >> Many thanks!
      >>
      >> Dave
      >>
      >>
      >> Wesley Smith wrote:
      >> > There are some abstractions missing from your text patch. Off the top
      >> > of my head, you will probably want to use the gridshape attribute
      >> > @displaylist 1. This caches the vertices on the graphics card. Also,
      >> > if each gridshape is vertex-wise the same. You can use just 1
      >> > gridshape with @automatic 0 set and give it the draw method along with
      >> > any attrs you want to change for however many times you want to draw
      >> > it. You can also use jit.gl.sketch's ability to draw named ob3d
      >> > objects and use its ability to modify the OpenGL state machine to
      >> > handle how your object looks and drawing it with the draw_raw method.
      >> >
      >> > HTH,
      >> > wes
      >>
    • Aug 26 2006 | 10:15 pm
      Ah, this is helpful...thanks Anton. So, I'm presuming the same thing
      works if I add 'texture' to that as well? I need different textures for
      each one, and what's more, I need to be able to swap them out.
      Can I use this technique if I need to go back and move each one
      independently later on (I'm displaying three rows of six circles each,
      like a grid, and they each need to be able to rotate independently based
      on user interaction--motion detection). I apologize, I'm dense with
      this OpenGL stuff: I didn't pay close enough attention in class when you
      and Josh were going over it, I guess. ;)
      Thanks,
      Dave
      vade wrote:
      > if you set an ob3D with the attribute @automatic 0, you can bang once to
      > draw, send a position -1 -1 -1, then bang again to draw again (assuming
      > you havent banged jit.gl.render in the meantime).
      >
      > this way you can bang one object more than once to draw it more than once.
      >
      > something akin to:
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P message 14 304 122 196617 position 0.5 -0.5 0 , bang;
      > #P message 30 282 127 196617 position -0.5 -0.5 0 , bang;
      > #P message 42 252 122 196617 position -0.5 0.5 0 , bang;
      > #P message 59 222 117 196617 position 0.5 0.5 0 , bang;
      > #P newex 14 201 53 196617 t b b b b;
      > #P window linecount 2;
      > #P hidden newex 177 354 389 196617 jit.gl.videoplane v001 @scale 1. 1.
      > 1. @depth_enable 0 @blend_enable 1 @automatic 0 @dim 2 2 @texture
      > v001.GPUFXOut @scale 0.5 0.5 0.5 @depth_enable 0;
      > #P connect 5 0 0 0;
      > #P connect 4 0 0 0;
      > #P connect 2 0 0 0;
      > #P connect 3 0 0 0;
      > #P connect 1 3 2 0;
      > #P connect 1 2 3 0;
      > #P connect 1 1 4 0;
      > #P connect 1 0 5 0;
      > #P window clipboard copycount 6;
      >
      > *
      > *
      > *
      > *
      > *v a d e //*
      > *
      > *
      > *www.vade.info*
      > *abstrakt.vade.info*
      >
      >
      > On Aug 26, 2006, at 5:43 PM, Dave Della Costa wrote:
      >
      >> Hey Wes,
      >>
      >> Sorry I'm slow on the response. Question: I see in another post you
      >> mention that there is a way to draw multiple objects by calling draw
      >> repeatedly--you say there was a javascript-dev thread about it recently
      >> (http://www.cycling74.com/forums/index.php?t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multiple+opengl#msg_64241
      >>).
      >> Is this something that can only be done with javascript? I'm a bit
      >> confused as to whether or not I can do this without using javascript,
      >> and how I would go about it--would you mind elaborating a bit on this,
      >> or pointing me in the direction of docs to tell me how I might do this?
      >>
      >> Many thanks!
      >>
      >> Dave
      >>
      >>
      >> Wesley Smith wrote:
      >>> There are some abstractions missing from your text patch. Off the top
      >>> of my head, you will probably want to use the gridshape attribute
      >>> @displaylist 1. This caches the vertices on the graphics card. Also,
      >>> if each gridshape is vertex-wise the same. You can use just 1
      >>> gridshape with @automatic 0 set and give it the draw method along with
      >>> any attrs you want to change for however many times you want to draw
      >>> it. You can also use jit.gl.sketch's ability to draw named ob3d
      >>> objects and use its ability to modify the OpenGL state machine to
      >>> handle how your object looks and drawing it with the draw_raw method.
      >>>
      >>> HTH,
      >>> wes
      >>> jitter@cycling74.com
      >> jitter@cycling74.com
      >
      >
      > ------------------------------------------------------------------------
      >
    • Aug 26 2006 | 10:27 pm
      On 8/26/06, Dave Della Costa wrote:
      > Ah, this is helpful...thanks Anton. So, I'm presuming the same thing
      > works if I add 'texture' to that as well? I need different textures for
      > each one, and what's more, I need to be able to swap them out.
      >
      Of course you can do that.
      > Can I use this technique if I need to go back and move each one
      > independently later on (I'm displaying three rows of six circles each,
      > like a grid, and they each need to be able to rotate independently based
      > on user interaction--motion detection). I apologize, I'm dense with
      > this OpenGL stuff: I didn't pay close enough attention in class when you
      > and Josh were going over it, I guess. ;)
      You just need to keep track of 6 sets of data and apply them
      appropriately. In JS, you could create 6 data structures to manage it
      all and then use that data to draw the geometry 6 different ways.
      Give it a shot. Try some things out to see what's possible.
      wes
    • Aug 26 2006 | 10:29 pm
      no worries :) After seeing Wes's response I was wondering If I was
      missing something.
      You could def use this technique to swap textures for the object.
      Assuming the textures are created before hand with a [jit.gl.texture
      context @name tex1] ( & tex2, tex3 etc))
      it would be something like this (simplistic),
      You could do something like use coll to manage the drawing commands/
      messages you send to one object, so youd update the coll which would
      contain the list of your drawing commands, and then 'dump' it to the
      gl object in question.
      it'd probably be better to use jit.gl.sketch, as you wouldnt need to
      dump the coll every frame you loaded, but only when you needed a change.
      you can use jit.gl.sketch's 'drawobject' command to manage this for
      you. check the help file, and if you want, I can make a patch that
      does some of that.
      v a d e //
      www.vade.info
      abstrakt.vade.info
      On Aug 26, 2006, at 6:15 PM, Dave Della Costa wrote:
      > Ah, this is helpful...thanks Anton. So, I'm presuming the same thing
      > works if I add 'texture' to that as well? I need different
      > textures for
      > each one, and what's more, I need to be able to swap them out.
      >
      > Can I use this technique if I need to go back and move each one
      > independently later on (I'm displaying three rows of six circles each,
      > like a grid, and they each need to be able to rotate independently
      > based
      > on user interaction--motion detection). I apologize, I'm dense with
      > this OpenGL stuff: I didn't pay close enough attention in class
      > when you
      > and Josh were going over it, I guess. ;)
      >
      > Thanks,
      > Dave
      >
      >
      > vade wrote:
      >> if you set an ob3D with the attribute @automatic 0, you can bang
      >> once to
      >> draw, send a position -1 -1 -1, then bang again to draw again
      >> (assuming
      >> you havent banged jit.gl.render in the meantime).
      >>
      >> this way you can bang one object more than once to draw it more
      >> than once.
      >>
      >> something akin to:
      >>
      >> #P window setfont "Sans Serif" 9.;
      >> #P window linecount 1;
      >> #P message 14 304 122 196617 position 0.5 -0.5 0 , bang;
      >> #P message 30 282 127 196617 position -0.5 -0.5 0 , bang;
      >> #P message 42 252 122 196617 position -0.5 0.5 0 , bang;
      >> #P message 59 222 117 196617 position 0.5 0.5 0 , bang;
      >> #P newex 14 201 53 196617 t b b b b;
      >> #P window linecount 2;
      >> #P hidden newex 177 354 389 196617 jit.gl.videoplane v001 @scale
      >> 1. 1.
      >> 1. @depth_enable 0 @blend_enable 1 @automatic 0 @dim 2 2 @texture
      >> v001.GPUFXOut @scale 0.5 0.5 0.5 @depth_enable 0;
      >> #P connect 5 0 0 0;
      >> #P connect 4 0 0 0;
      >> #P connect 2 0 0 0;
      >> #P connect 3 0 0 0;
      >> #P connect 1 3 2 0;
      >> #P connect 1 2 3 0;
      >> #P connect 1 1 4 0;
      >> #P connect 1 0 5 0;
      >> #P window clipboard copycount 6;
      >>
      >> *
      >> *
      >> *
      >> *
      >> *v a d e //*
      >> *
      >> *
      >> *www.vade.info*
      >> *abstrakt.vade.info*
      >>
      >>
      >> On Aug 26, 2006, at 5:43 PM, Dave Della Costa wrote:
      >>
      >>> Hey Wes,
      >>>
      >>> Sorry I'm slow on the response. Question: I see in another post
      >>> you
      >>> mention that there is a way to draw multiple objects by calling draw
      >>> repeatedly--you say there was a javascript-dev thread about it
      >>> recently
      >>> (http://www.cycling74.com/forums/index.php?
      >>> t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multi
      >>> ple+opengl#msg_64241
      >>> >>> t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multi
      >>> ple+opengl#msg_64241>).
      >>> Is this something that can only be done with javascript? I'm a bit
      >>> confused as to whether or not I can do this without using
      >>> javascript,
      >>> and how I would go about it--would you mind elaborating a bit on
      >>> this,
      >>> or pointing me in the direction of docs to tell me how I might do
      >>> this?
      >>>
      >>> Many thanks!
      >>>
      >>> Dave
      >>>
      >>>
      >>> Wesley Smith wrote:
      >>>> There are some abstractions missing from your text patch. Off
      >>>> the top
      >>>> of my head, you will probably want to use the gridshape attribute
      >>>> @displaylist 1. This caches the vertices on the graphics card.
      >>>> Also,
      >>>> if each gridshape is vertex-wise the same. You can use just 1
      >>>> gridshape with @automatic 0 set and give it the draw method
      >>>> along with
      >>>> any attrs you want to change for however many times you want to
      >>>> draw
      >>>> it. You can also use jit.gl.sketch's ability to draw named ob3d
      >>>> objects and use its ability to modify the OpenGL state machine to
      >>>> handle how your object looks and drawing it with the draw_raw
      >>>> method.
      >>>>
      >>>> HTH,
      >>>> wes
      >>>> jitter@cycling74.com
      >>> jitter@cycling74.com
      >>
      >>
      >> ---------------------------------------------------------------------
      >> ---
      >>
    • Aug 26 2006 | 10:31 pm
      oops:
      v a d e //
      www.vade.info
      abstrakt.vade.info
      On Aug 26, 2006, at 6:15 PM, Dave Della Costa wrote:
      > Ah, this is helpful...thanks Anton. So, I'm presuming the same thing
      > works if I add 'texture' to that as well? I need different
      > textures for
      > each one, and what's more, I need to be able to swap them out.
      >
      > Can I use this technique if I need to go back and move each one
      > independently later on (I'm displaying three rows of six circles each,
      > like a grid, and they each need to be able to rotate independently
      > based
      > on user interaction--motion detection). I apologize, I'm dense with
      > this OpenGL stuff: I didn't pay close enough attention in class
      > when you
      > and Josh were going over it, I guess. ;)
      >
      > Thanks,
      > Dave
      >
      >
      > vade wrote:
      >> if you set an ob3D with the attribute @automatic 0, you can bang
      >> once to
      >> draw, send a position -1 -1 -1, then bang again to draw again
      >> (assuming
      >> you havent banged jit.gl.render in the meantime).
      >>
      >> this way you can bang one object more than once to draw it more
      >> than once.
      >>
      >> something akin to:
      >>
      >> #P window setfont "Sans Serif" 9.;
      >> #P window linecount 1;
      >> #P message 14 304 122 196617 position 0.5 -0.5 0 , bang;
      >> #P message 30 282 127 196617 position -0.5 -0.5 0 , bang;
      >> #P message 42 252 122 196617 position -0.5 0.5 0 , bang;
      >> #P message 59 222 117 196617 position 0.5 0.5 0 , bang;
      >> #P newex 14 201 53 196617 t b b b b;
      >> #P window linecount 2;
      >> #P hidden newex 177 354 389 196617 jit.gl.videoplane v001 @scale
      >> 1. 1.
      >> 1. @depth_enable 0 @blend_enable 1 @automatic 0 @dim 2 2 @texture
      >> v001.GPUFXOut @scale 0.5 0.5 0.5 @depth_enable 0;
      >> #P connect 5 0 0 0;
      >> #P connect 4 0 0 0;
      >> #P connect 2 0 0 0;
      >> #P connect 3 0 0 0;
      >> #P connect 1 3 2 0;
      >> #P connect 1 2 3 0;
      >> #P connect 1 1 4 0;
      >> #P connect 1 0 5 0;
      >> #P window clipboard copycount 6;
      >>
      >> *
      >> *
      >> *
      >> *
      >> *v a d e //*
      >> *
      >> *
      >> *www.vade.info*
      >> *abstrakt.vade.info*
      >>
      >>
      >> On Aug 26, 2006, at 5:43 PM, Dave Della Costa wrote:
      >>
      >>> Hey Wes,
      >>>
      >>> Sorry I'm slow on the response. Question: I see in another post
      >>> you
      >>> mention that there is a way to draw multiple objects by calling draw
      >>> repeatedly--you say there was a javascript-dev thread about it
      >>> recently
      >>> (http://www.cycling74.com/forums/index.php?
      >>> t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multi
      >>> ple+opengl#msg_64241
      >>> >>> t=msg&goto=64241&rid=0&S=1c80bf4ce3f43ad92103b2436169faa8&srch=multi
      >>> ple+opengl#msg_64241>).
      >>> Is this something that can only be done with javascript? I'm a bit
      >>> confused as to whether or not I can do this without using
      >>> javascript,
      >>> and how I would go about it--would you mind elaborating a bit on
      >>> this,
      >>> or pointing me in the direction of docs to tell me how I might do
      >>> this?
      >>>
      >>> Many thanks!
      >>>
      >>> Dave
      >>>
      >>>
      >>> Wesley Smith wrote:
      >>>> There are some abstractions missing from your text patch. Off
      >>>> the top
      >>>> of my head, you will probably want to use the gridshape attribute
      >>>> @displaylist 1. This caches the vertices on the graphics card.
      >>>> Also,
      >>>> if each gridshape is vertex-wise the same. You can use just 1
      >>>> gridshape with @automatic 0 set and give it the draw method
      >>>> along with
      >>>> any attrs you want to change for however many times you want to
      >>>> draw
      >>>> it. You can also use jit.gl.sketch's ability to draw named ob3d
      >>>> objects and use its ability to modify the OpenGL state machine to
      >>>> handle how your object looks and drawing it with the draw_raw
      >>>> method.
      >>>>
      >>>> HTH,
      >>>> wes
      >>>> jitter@cycling74.com
      >>> jitter@cycling74.com
      >>
      >>
      >> ---------------------------------------------------------------------
      >> ---
      >>