Page 1 of 1
Native ZScript line drawing function
Posted: Thu Jun 08, 2017 9:39 am
by Gutawer
Would be nice to have a native line drawing algorithm for the Screen struct and the BaseStatusBar class - line drawing algorithms can be implemented in ZScript by the user, but will be slow as the function couldn't be native. A native function DrawLine function like this would be a real help for, for example, drawing the map to the screen as an in-hud automap.
Re: Native ZScript line drawing function
Posted: Thu Jun 08, 2017 9:59 am
by Nash
Seconded! I had the cheeky idea to make some homegrown solution for drawing GUI panels and stuff using screen fill as the pixel-blitting API (like what the save/load menu is currently doing with the blue selector) but I quickly stopped when I realized it's pointless and will probably be damn slow...
Re: Native ZScript line drawing function
Posted: Mon Jun 26, 2017 12:58 pm
by DrPyspy
Thirded. A native function would make the process of drawing lines to the screen much more accessible with ZScript.
Re: Native ZScript line drawing function
Posted: Mon Jun 26, 2017 2:51 pm
by Major Cooke
Fourthed. Using something like this would allow special effects, arrows, etc to be used by the hud system and grant an undeniable amount of custom rendering. I can already see holographic effects happening with this.
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 5:09 pm
by DrPyspy
Seeing as there hasn't been a response to this, I'd like to propose a case in which this function would be useful.
This minimap currently works by printing a 4096-character string to the screen. However, printing 4096 characters to the screen at once tends to hurt performance. My plan to optimize it involves grabbing nearby linedefs and printing them to the screen using a line drawing function. However, without a native method of doing this, it cannot be done properly. Attempts to use Gutawer's line drawing function actually brought the performance down slightly more than the original method.
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 5:13 pm
by Major Cooke
Where is his version?
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 5:14 pm
by DrPyspy
I don't have it on hand due to the code being on PasteBin, but if you ask him on Discord he might lend it.
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 5:26 pm
by Major Cooke
Damn. There's a version for each renderer and I don't know how to call those. Otherwise I'd make a PR.
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 6:31 pm
by Gutawer
Decided to do this myself, since this got no attention:
https://github.com/coelckers/gzdoom/pull/355
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 6:57 pm
by Rachael
Can you post your test example please, for easier review, that you showed pictures of on Discord?
Re: Native ZScript line drawing function
Posted: Wed Aug 02, 2017 7:25 pm
by Gutawer
Sure -
Code: Select all
class LineHandler : StaticEventHandler {
override void RenderOverlay(RenderEvent e) {
Screen.DrawLine(0, 0, Screen.GetWidth(), Screen.GetHeight(), Color(0xFF, 0xFF, 0x00, 0xFF));
Screen.DrawLine(0, Screen.GetHeight(), Screen.GetWidth(), 0, Screen.PaletteColor(200));
}
}
Draws two diagonal lines, one from RGBA and one from the palette.