Jit.gl.lua: how to bind a texture?
Feb 11 2007 | 9:52 pm
Hello List,
I am new here, reading quite a few years the list and taking big advantage of it, great resource, hope you can help me with the following.
Last week I started to discover jit.gl.lua. I read the reference, opened and editted some of the examples and I think I will rewrite some of my patches using Lua to get rid of some JS and jit.gl.sketch-spagetti. There is only one basic issue that I can't understand, and that is how to simply bind a texture to a rectangle.
With jit.gl.sketch I used to do it like this, assuming that i have a jit.gl.texture object called 'mytexture' in my patch.
glenable texture,
glbindtexture mytexture,
plane 0.5,
glunbindtexture
Easy, works like a charm.
After reading the Lua-manual and the LuaGL-reference I would think it should be something like this in Lua:
gl.Enable("TEXTURE");
gl.BindTexture("TEXTURE", mytexture); -- or should i use jit.gl.bindtexture instead?
gl.Rect(0., -0.5, 0.5, 0.)
gl.Disable("TEXTURE")
This gives me all kinds of errors (Enumeration, nil values) , i tried many different ways to write the code down, all just gave me a rectangle without a texture.
After taking a look at the red and bluebook I found out that the second argument in gl.bindtexture has to be an imageArray and thats were I get lost, because I suppose there's an easier way to accomplish this. I dont know where to find the answer, is it the Lua-syntax which is a bit different than openGL, is it openGL I should dive into or am I missing something very obvious here? Your help is very welcome, if you need a sample-patch I will submit it.
Best regards,
Erik