How do groundSquare work?

How do groundSquare work?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

How do groundSquare work?

Post by Google_Frog »

https://github.com/spring/spring/commit ... 63e57f3aca

It's great that some form of texture changing was added, but how does it work?

Code: Select all

function widget:Initialize()
    Spring.Echo(Spring.SetMapSquareTexture(800,800,'LuaUI/Images/test.png'))
end
Echos false.

Code: Select all

function widget:DrawWorldPreUnit()
    gl.Texture('LuaUI/Images/test.png' )
    gl.DrawGroundQuad(0,0,300,300)
end
Confirms that the texture is loaded and found.

test.png is an 8x8 white square.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How do groundSquare work?

Post by FLOZi »

Try calling gl.Texture before you call SetMap... ?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How do groundSquare work?

Post by Google_Frog »

From the content of the commits it looks like the function isn't suppose to be used in DrawWorld.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How do groundSquare work?

Post by FLOZi »

Did I suggest that it was?

All of this is mere conjecture of course. 8)

I am become Argh, destroyer of dev threads
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: How do groundSquare work?

Post by smoth »

Nooooooo!


So all joking aside what does this do
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: How do groundSquare work?

Post by Kloot »

1) "How do groundSquare work?" ?
2) learn from example: http://pastebin.com/EUHyzZLE
3) there is a third way to use these callouts, but it requires advanced knowledge of (Lua)OpenGL
Last edited by Kloot on 22 Jul 2011, 13:47, edited 1 time in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How do groundSquare work?

Post by FLOZi »

smoth wrote:Nooooooo!


So all joking aside what does this do
Screenshot of kloots example widget:

Image
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How do groundSquare work?

Post by FLOZi »

<snip>
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How do groundSquare work?

Post by Google_Frog »

Thanks, the example widget is good. One more question; is there a significant performance difference between creating lots of little groundSquares instead of a few big ones?

(Also, groundSquares, I think I'm allowed the occasional typo)
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: How do groundSquare work?

Post by Kloot »

The widget doesn't create ground squares, it re-textures existing ones. They have a fixed size (1024x1024 elmos) because of how the map format and renderer are designed, so performance is not a factor you can control or should be concerned about.
Last edited by Kloot on 22 Jul 2011, 19:47, edited 1 time in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How do groundSquare work?

Post by FLOZi »

Is it possible to do the following in lua:

Get the original map ground square texture
replace a subsection of that square texture with your own texture
apply new texture to the ground square

Also, is it possible have 1 bit transparency on these textures?


Even without being able to do the former; This should allow to make a single heightfield with multiple texture/feature climates. :-)
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: How do groundSquare work?

Post by Kloot »

1) yes, but falls under the "advanced knowledge" category
2) nope, no transparency without setting voidwater (yet)
Post Reply

Return to “Engine”