jit.gl.lua + multiple textures using jit.gl.gridshape
Hi all,
so, I have been playing around with jit.gl.lua and so far it has been great. Anyone have any ideas as to how i could iterate a series of textures on 'n' jit.gl.gridshapes?
I have got the jit.gl.lua ListenerVecmath example to work with planes and the same texture over each but not so far as iterating different textures onto each planes.
Outside of lua i was using jit.matrixset to iterate textures on different planes but in lua i am not clear as to the best way to go about this
below is some of the code i have added to the ListenerVecmath example patch i am building from.
I guess the question is where to put the jit.gl.bindtexture and jit.gl.unbindtexture and how to reference the relative textures.
Any help or directions where i can find more about this would be great!
Best,
Tim
objects = {}
objects.textures = {}
for i=1, num_objects do
objects.textures[i] = jit.new("jit.gl.texture", render_context)
end
for i=1, num_objects do
objects[i] = jit.new("jit.gl.gridshape", render_context)
objects[i].automatic = 0
objects[i].shape = "plane"
objects[i].position = {(i-1)/(num_objects-1)*6. - 3., 0., 0.}
objects[i].color = gray
objects[i].scale = {0.5, 0.5, 0.5}
objects[i].lighting_enable = 1
objects[i].texture = objects.textures[i]
end
function draw()
if(hitobj) then
hitobj.position = handle.position
hitobj.rotate = handle.rotate
end
for i in ipairs(objects) do
jit.gl.bindtexture(render_context, 0)
objects[i]:draw()
jit.gl.unbindtexture(render_context, 0)
end
end