hi, all (err... wesly)<br>i have been doing some lua coding on an xp machine.<br><br>i have a few questions,<br>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?<br>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.<br>3. when i enter fullscreen i lose the drawing.
<br><br>thanks , it's fun coding in lua. and i feel can tackle some of nehe's opengl tutorial with it.<br>posting on the list so i hope it will not break in the forum.<br><br><br><br>autowatch = 1<br>print("compiled")
<br>render_context = this.drawto<br>angle=0<br>mouseXY={0,0}<br>dir=1<br> <br>function BuildLists()<br><br> box = gl.GenLists(2) <br> gl.NewList(box ,"COMPILE");<br> gl.Begin("QUADS")
<br> gl.Vertex (-0.5 , 0.5 , 0. ) -- Top Left<br> gl.Vertex ( 0.5 , 0.5 , 0. ) -- Top Right<br> gl.Vertex ( 0.5 ,-0.5 , 0. ) -- Bottom Right<br>
gl.Vertex (-0.5 ,-0.5 , 0. ) <br> gl.End();<br> gl.EndList()<br>end<br>function init()<br>--initialize the dispaly list<br> BuildLists()<br>end<br>init()<br><br>function draw() <br> gl.Clear("COLOR_BUFFER_BIT" , "DEPTH_BUFFER_BIT")
<br> --gl.LoadIdentity() <br> --gl.Enable("BLEND")<br> --gl.BlendFunc(1,6)<br> --gl.ClearColor(1,1,0,1)<br> rot()<br> for i=0,1000 do<br> gl.Translate(mouseXY[1],mouseXY[2],(i/1000)-1);<br>
gl.Rotate(angle,0,0,1)<br> gl.Color(i/1000, math.random(), 1, i/1000)<br> gl.CallList(box)<br> end<br><br>end<br><br>function rot()<br> angle = angle+dir<br> if angle==15 then dir= -0.5<br> elseif angle==0 then dir=
0.5<br> end<br>end <br> <br>--create the listener callback function<br>function callback(event)<br> if(event.eventname == "mouseidle") then<br> local _glXmouse = event.args[1]<br> local _glYmouse =
event.args[2]<br> --need to transform mouse ccordinates to world domain<br> --dono why, but 0.95 needed<br> mouseXY=jit.gl.screentoworld({_glXmouse,_glYmouse, 0.95})<br> end<br>end<br><br>--create a listener object
<br>listener = jit.listener(render_context, "callback")<br><br>++++++++++++++++++<br>patch<br>++++++++++++++++<br>#P window setfont "Sans Serif" 9.;<br>#P window linecount 1;<br>#P newex 22 154 311 9109513
jit.gl.lua nehe @file nehe1_displaylist.lua @autogarbage 1 @autowatch 1;<br>#P toggle 123 71 15 0;<br>#P message 123 91 68 9109513 fullscreen \$1;<br>#N vpatcher 30 89 166 253;<br>#P window setfont "Sans Serif" 9.;
<br>#P newex 50 71 35 9109513 sel 27;<br>#P newex 50 50 40 9109513 key;<br>#P outlet 50 93 15 0;<br>#P connect 1 0 2 0;<br>#P connect 2 0 0 0;<br>#P pop;<br>#P newobj 123 51 33 9109513 p Esc;<br>#P newex 123 109 70 9109513
jit.window nehe;<br>#P toggle 21 45 15 0;<br>#P newex 21 64 57 9109513 qmetro 30;<br>#P newex 21 85 50 9109513 t b erase;<br>#P newex 21 111 77 9109513 jit.gl.render nehe;<br>#P connect 6 0 4 0;<br>#P connect 7 0 6 0;<br>
#P connect 5 0 7 0;<br>#P fasten 1 0 0 0 26 106 26 106;<br>#P fasten 1 1 0 0 66 106 26 106;<br>#P connect 2 0 1 0;<br>#P connect 3 0 2 0;<br>#P window clipboard copycount 9;<br><br><br>