Native ZScript line drawing function

Moderator: GZDoom Developers

Post Reply
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Native ZScript line drawing function

Post 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.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Native ZScript line drawing function

Post 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...
User avatar
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

Post by DrPyspy »

Thirded. A native function would make the process of drawing lines to the screen much more accessible with ZScript.
User avatar
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

Post 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.
User avatar
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

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

Image

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.
User avatar
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

Post by Major Cooke »

Where is his version?
User avatar
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

Post 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.
User avatar
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

Post 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.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Native ZScript line drawing function

Post by Gutawer »

Decided to do this myself, since this got no attention: https://github.com/coelckers/gzdoom/pull/355
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Native ZScript line drawing function

Post by Rachael »

Can you post your test example please, for easier review, that you showed pictures of on Discord?
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Native ZScript line drawing function

Post 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.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”