Spring.DrawToPOV
Posted: 10 Apr 2008, 23:55
Basically, I think that there should be a simpler Lua call-in for drawing stuff that we want displayed in front of the camera, for UI elements. Having spent the last few hours reading over how this is apparently getting done, I'm of the opinion that we should just have a standardized call-in for this:
Spring.DrawToPOV(string mode, location x, location y,[options])
"Mode" should be 'text' or 'image'.
Location x/y are relative positions on the screen, to keep things simpler.
[options] depend on Mode:
If mode == 'text', then options should include:
Color. in RGBA values, 1.0 --> 0.0
Font. Self-explanatory, should use the VFS (I saw notes indicating that this isn't currently true).
Size. Self-explanatory, should use the same sizes as current gl.Text.
imageAlpha(nameoftexture, basically turns on gl.Blend, uses the texture to apply an alpha).
imageColor(nameoftexture, uses an image to color the resulting text).
So, an example would be Spring.DrawToPOV('text',0.5,0.5,options.font='LucidaSansSerif',options.size = 30,options.color = 1.0,1.0,1.0)
Which would draw some text in the center of the screen, size 30, in white.
If mode == 'image', then options should include:
Color. in RGBA values, 1.0 --> 0.0
imageAlpha(nameoftexture, basically turns on gl.Blend, uses the texture to apply an alpha blend to the rectangle).
imageColor(nameoftexture, uses an image to color the resulting rectangle).
sizex, sizey(size of rectangle, in pixels xy).
Spring.DrawToPOV('texture',0.5,0.5,options.color = 1.0,1.0,1.0,options.sizex = 30, options.sizey = 30, options.imageColor = 'mybitmap.png',options.imageAlpha = 'mybitmap_alpha.png')
Which is a 30 by 30 pixel white rectangle using mybitmap.png to provide color information (via GL_ADDITIVE, I'm thinking).
Putting something like this into Spring would make building and deploying GUI elements a lot more straightforward, and would mean that there would be a lot less Lua code running, to do these things. It'd be a win-win for developers wanting to do more GUI stuff, imo.
Spring.DrawToPOV(string mode, location x, location y,[options])
"Mode" should be 'text' or 'image'.
Location x/y are relative positions on the screen, to keep things simpler.
[options] depend on Mode:
If mode == 'text', then options should include:
Color. in RGBA values, 1.0 --> 0.0
Font. Self-explanatory, should use the VFS (I saw notes indicating that this isn't currently true).
Size. Self-explanatory, should use the same sizes as current gl.Text.
imageAlpha(nameoftexture, basically turns on gl.Blend, uses the texture to apply an alpha).
imageColor(nameoftexture, uses an image to color the resulting text).
So, an example would be Spring.DrawToPOV('text',0.5,0.5,options.font='LucidaSansSerif',options.size = 30,options.color = 1.0,1.0,1.0)
Which would draw some text in the center of the screen, size 30, in white.
If mode == 'image', then options should include:
Color. in RGBA values, 1.0 --> 0.0
imageAlpha(nameoftexture, basically turns on gl.Blend, uses the texture to apply an alpha blend to the rectangle).
imageColor(nameoftexture, uses an image to color the resulting rectangle).
sizex, sizey(size of rectangle, in pixels xy).
Spring.DrawToPOV('texture',0.5,0.5,options.color = 1.0,1.0,1.0,options.sizex = 30, options.sizey = 30, options.imageColor = 'mybitmap.png',options.imageAlpha = 'mybitmap_alpha.png')
Which is a 30 by 30 pixel white rectangle using mybitmap.png to provide color information (via GL_ADDITIVE, I'm thinking).
Putting something like this into Spring would make building and deploying GUI elements a lot more straightforward, and would mean that there would be a lot less Lua code running, to do these things. It'd be a win-win for developers wanting to do more GUI stuff, imo.