Native ZScript line drawing function
Moderator: GZDoom Developers
Native ZScript line drawing function
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
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...
- DrPyspy
- Posts: 278
- Joined: Sat Feb 21, 2015 7:35 pm
- Operating System Version (Optional): Windows XP Gangster Edition
- Location: Utah, USA
Re: Native ZScript line drawing function
Thirded. A native function would make the process of drawing lines to the screen much more accessible with ZScript.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Native ZScript line drawing function
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.
- DrPyspy
- Posts: 278
- Joined: Sat Feb 21, 2015 7:35 pm
- Operating System Version (Optional): Windows XP Gangster Edition
- Location: Utah, USA
Re: Native ZScript line drawing function
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.
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.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Native ZScript line drawing function
Where is his version?
- DrPyspy
- Posts: 278
- Joined: Sat Feb 21, 2015 7:35 pm
- Operating System Version (Optional): Windows XP Gangster Edition
- Location: Utah, USA
Re: Native ZScript line drawing function
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.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Native ZScript line drawing function
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
Decided to do this myself, since this got no attention: https://github.com/coelckers/gzdoom/pull/355
Re: Native ZScript line drawing function
Can you post your test example please, for easier review, that you showed pictures of on Discord?
Re: Native ZScript line drawing function
Sure -
Draws two diagonal lines, one from RGBA and one from the palette.
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));
}
}