[Fluxus] drawing instances

Dave Griffiths dave at pawfal.org
Thu Jan 22 06:00:33 PST 2009


On Thu, 2009-01-22 at 14:38 +0100, gabor papp wrote:
> > I can define an object instance with a scale, transform, and texture 
> > attached to it, but when I try to draw it, the instance is drawn 
> > un-textured, although scale and shape are both set properly.  I think
> >  this is a bug?
> as far as i can tell, scale is not set properly either. this is because
> the instance is drawn with the current state.
> 
> try to set the texture globally as a workaround.
> (define texture (load-texture "temple.png"))

It's not exactly a bug - the instance should use the current state, as
it's supposed to behave like draw-cube and friends.

I'd do something like this:

(define master-sphere (build-sphere 30 30))

; you might also want to do
(with-primitive master-sphere 
    (hide 1))

(define (draw-my-sphere)
    (with-state
        (texture (load-texture "temple.png")) ; not really any slower than storing tex0
        (scale 2)
        (draw-instance master-sphere)))

(define (render)
    (with-state
        (translate (vector 0 2 0))
        (draw-my-sphere)
        (translate (vector 0 2 0))
        (draw-my-sphere)))

(every-frame (render))





More information about the Fluxus mailing list