gl display lists

gl display lists

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderators: Moderators, Moderators

Post Reply
kfriars
Posts: 36
Joined: 28 Sep 2011, 01:00

gl display lists

Post 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
0 x

kfriars
Posts: 36
Joined: 28 Sep 2011, 01:00

Re: gl display lists

Post 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.
0 x

kfriars
Posts: 36
Joined: 28 Sep 2011, 01:00

Re: gl display lists

Post 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)
0 x

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: gl display lists

Post by jK »

recheck your gl.TexRect syntax, and you should have gotten an error in your infolog.txt
0 x

kfriars
Posts: 36
Joined: 28 Sep 2011, 01:00

Re: gl display lists

Post by kfriars »

Good catch jK, thank you. No error message in infolog though.

Edit: I was rotating improperly before

Thanks for your help :)
Last edited by kfriars on 16 Mar 2012, 08:56, edited 1 time in total.
0 x

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: gl display lists

Post 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).
0 x

Post Reply

Return to “Lua Scripts”

cron