Page 1 of 1

gl display lists

Posted: 16 Mar 2012, 06:55
by kfriars
So there isnt too much information on this on the web, however I did some research and what I have I think should work, however im not sure if I should be pushing and popping the stack. So what I am trying to do is create a list of display lists and then loop through them in DrawWorldPreUnit()

Here is an example of the display list I am creating. No errors are generated, however nothing is drawn. Any help is appreciated.

Code: Select all

displayLists[source] = gl.CreateList( function()
		gl.PushAttrib(GL.ALL_ATTRIB_BITS)
		gl.Translate(x1 - 100*scale/2, 0, z1)
		gl.Rotate(theta,0,0,0)
		gl.Scale(scale,1,scale)
		gl.Texture("LuaUI/Images/OrderTextures/MTO_"..source[1]..".png")
		gl.TexRect(0,height,0,100,height,100)
		gl.PushAttrib(GL.ALL_ATTRIB_BITS)
		gl.PopAttrib()
		end)
And here is where I call them:

Code: Select all

function widget:DrawWorldPreUnit()
	for t, o in pairs(displayLists) do
		gl.CallList(o)
	end
end

Re: gl display lists

Posted: 16 Mar 2012, 07:22
by kfriars
Shoulda looked harder... Ther post from user in the thread, http://springrts.com/phpbb/viewtopic.php?f=23&t=14033 has been enlightening.

Re: gl display lists

Posted: 16 Mar 2012, 08:15
by kfriars
So, still stumped actually. Found a couple things that were clearly wrong, so this is what i have now.

Code: Select all

	displayLists[source[3]] = gl.CreateList( function()
		gl.PushMatrix()
		gl.Translate(x1 - 100*scale/2, 0, z1)
		gl.Rotate(theta,0,0,0)
		gl.Scale(scale,1,scale)
		gl.Texture("LuaUI/Images/OrderTextures/MTO_"..source[1]..".png")
		gl.TexRect(0,height,0,100,height,100)
		gl.PopMatrix()
		end)

Re: gl display lists

Posted: 16 Mar 2012, 08:25
by jK
recheck your gl.TexRect syntax, and you should have gotten an error in your infolog.txt

Re: gl display lists

Posted: 16 Mar 2012, 08:51
by kfriars
Good catch jK, thank you. No error message in infolog though.

Edit: I was rotating improperly before

Thanks for your help :)

Re: gl display lists

Posted: 16 Mar 2012, 08:54
by jK
kfriars wrote:On a potentially related note, when I had it hard coded, a different Lua scripts drawing functions were no longer showing up. Is there a way to get them not to compete with each other?
Each push needs a pop. Or better reset the state yourself (and you have to disable texture once your drawing is done).