XML Feeds

.

[jitter] lua questions

yair reshef yair99 at gmail.com
Wed Jan 2 04:18:15 MST 2008


thanks wes, lua is so flexible

i'm still having difficulties with the placement of
  gl.Enable("BLEND")
  gl.BlendFunc(1,6)
  gl.ClearColor(0,0,0,0.5)
my intuition tells me it should be in the init function, but no go.

On Jan 2, 2008 5:26 AM, Wesley Smith <wesley.hoke at gmail.com> wrote:

> Sorry, there was a slight typo in my script in the last post.  Here's
> a fixed version:
>
>
> autowatch = 1
> print("compiled")
> render_context = this.drawto
> angle=0
> mouseXY={0,0}
> dir=1
>
>
>
> function BuildLists()
>
>    box = gl.GenLists(2)
>    gl.NewList(box    ,"COMPILE");
>        gl.Begin("QUADS")
>            gl.Vertex (-0.5 , 0.5 , 0. )                -- Top Left
>            gl.Vertex ( 0.5 , 0.5 , 0. )                -- Top Right
>            gl.Vertex ( 0.5 ,-0.5 , 0. )            -- Bottom Right
>            gl.Vertex (-0.5 ,-0.5 , 0. )
>        gl.End();
>    gl.EndList()
> end
> function init()
> --initialize the dispaly list
>        if(this.context ~= 0) then
>            BuildLists()
>        end
> end
>
>
> -- functions as variables!
> function setOnReloadOrDestChanged(func)
>        script_load = func
>        dest_changed = func
> end
> setOnReloadOrDestChanged(init)
>
> --[[
> This section is equivalent to the above
>
> function script_load()
>        init()
> end
>
> function dest_changed()
>        init()
> end
> --]]
>
> function draw()
>    gl.Clear("COLOR_BUFFER_BIT" , "DEPTH_BUFFER_BIT")
>    --gl.LoadIdentity()
>    --gl.Enable("BLEND")
>    --gl.BlendFunc(1,6)
>    --gl.ClearColor(1,1,0,1)
>    rot()
>    for i=0,1000 do
>    gl.Translate(mouseXY[1],mouseXY[2],(i/1000)-1);
>    gl.Rotate (angle,0,0,1)
>    gl.Color(i/1000, math.random(), 1, i/1000)
>    gl.CallList(box)
>    end
>
> end
>
> function rot()
>    angle = angle+dir
>    if angle==15 then dir= -0.5
>    elseif angle==0 then dir= 0.5
>    end
> end
>
> --create the listener callback function
> function callback(event)
>    if(event.eventname == "mouseidle") then
>        local _glXmouse = event.args[1]
>        local _glYmouse = event.args[2]
>        --need to transform mouse ccordinates to world domain
>        --dono why, but 0.95 needed
>        mouseXY=jit.gl.screentoworld({_glXmouse,_glYmouse, 0.95})
>    end
> end
>
> --create a listener object
> listener = jit.listener(render_context, "callback")
> _______________________________________________
> jitter mailing list
> jitter at cycling74.com
> http://www.cycling74.com/mailman/listinfo/jitter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cycling74.com/pipermail/jitter/attachments/20080102/d9e45325/attachment.htm


More information about the jitter mailing list