XML Feeds

.

[jitter] lua questions

yair reshef yair99 at gmail.com
Tue Jan 1 15:58:23 MST 2008


hi, all (err... wesly)
i have been doing some lua coding on an xp machine.

i have a few questions,
1. something strange about the screentoworld routine, when z is set to 0. or
1. i get unusable results. when at 0.95 its almost there, why?
2. i use display lists, is that good? were do i plug the gl states in that
situation. i want blend effects. i commented the lines i think i need.
3. when i enter fullscreen i lose the drawing.

thanks , it's fun coding in lua. and i feel can tackle some of nehe's opengl
tutorial with it.
posting on the list so i hope it will not break in the forum.



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
    BuildLists()
end
init()

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")

++++++++++++++++++
patch
++++++++++++++++
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 22 154 311 9109513 jit.gl.lua nehe @file nehe1_displaylist.lua
@autogarbage 1 @autowatch 1;
#P toggle 123 71 15 0;
#P message 123 91 68 9109513 fullscreen \$1;
#N vpatcher 30 89 166 253;
#P window setfont "Sans Serif" 9.;
#P newex 50 71 35 9109513 sel 27;
#P newex 50 50 40 9109513 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 123 51 33 9109513 p Esc;
#P newex 123 109 70 9109513 jit.window nehe;
#P toggle 21 45 15 0;
#P newex 21 64 57 9109513 qmetro 30;
#P newex 21 85 50 9109513 t b erase;
#P newex 21 111 77 9109513 jit.gl.render nehe;
#P connect 6 0 4 0;
#P connect 7 0 6 0;
#P connect 5 0 7 0;
#P fasten 1 0 0 0 26 106 26 106;
#P fasten 1 1 0 0 66 106 26 106;
#P connect 2 0 1 0;
#P connect 3 0 2 0;
#P window clipboard copycount 9;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cycling74.com/pipermail/jitter/attachments/20080102/21b7ff5b/attachment.htm


More information about the jitter mailing list