Export level.info->pixelstretch to ZScript
Moderator: GZDoom Developers
Export level.info->pixelstretch to ZScript
As the title says, I need this exported to ZScript so that I can finish off a HUDMessageOnActor-like function (for ZScript) using a perspective projection matrix. It's working mostly perfectly, but I need it to react to the pixel ratio dynamically and right now I don't think that's exported. A LevelLocals.pixelstretch field would be nice for this.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Export level.info->pixelstretch to ZScript
One question: why was it done with a function while others are fields a.k.a. member variables?
Re: Export level.info->pixelstretch to ZScript
I wondered this too and here's a comment from base.txt:
Perhaps now is a good time to export this type.
On top of this, the function returns information from level.info rather than from the info given by the instance itself, was that intended?
Code: Select all
// level_info_t *info cannot be done yet.
On top of this, the function returns information from level.info rather than from the info given by the instance itself, was that intended?
Re: Export level.info->pixelstretch to ZScript
I originally wanted this as a member variable on the ZScript LevelLocals struct, but since info wasn't exported, I wasn't sure how that could be done. I'm happy with using it as a function, though it taking from level.info is probably a problem, yeah. If info could be exported, that'd be cool too - whatever works.
Re: Export level.info->pixelstretch to ZScript
This should be done in a uniform way with other members.
Read-only field is more than enough here. Function is needed to do a lazy evaluation or calculate the value on the fly.
Read-only field is more than enough here. Function is needed to do a lazy evaluation or calculate the value on the fly.
Re: Export level.info->pixelstretch to ZScript
Mental's implementation looks better, IMO (no offense to Cooke!)
Re: Export level.info->pixelstretch to ZScript
I still think the info type should be exported, anything else would just be a temporary kludge anyways.
Re: Export level.info->pixelstretch to ZScript
Sure, please do it if you have ability to implement and test it.Leonard2 wrote:I still think the info type should be exported, anything else would just be a temporary kludge anyways.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Export level.info->pixelstretch to ZScript
I had no idea on how to do it that way instead of a function, honestly. By all means, do show how it's done. I'd love to learn how. 

Re: Export level.info->pixelstretch to ZScript
I thought that the mentioned commit is self-explanatory. You had to search similar members in code, outsidefogdensity for example, and do the same.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Export level.info->pixelstretch to ZScript
I didn't see you expose that until now.
Also I saw this and I thought that to be true.
Also also, that float in zscript should be a double, right?
Also I saw this and I thought that to be true.
Also also, that float in zscript should be a double, right?
Re: Export level.info->pixelstretch to ZScript
No, C++ float and double both are fine to be exported as native member variables with ZScript's float type.Major Cooke wrote:Also also, that float in zscript should be a double, right?
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Export level.info->pixelstretch to ZScript
Hmm... Well, I mainly say that because Rachael says don't use floats for zscript.
EDIT: Added link to where I quoted her from.Rachael wrote:Remember to use doubles (I think ZScript supports them, right?) to store the final values. As you no doubt know, fractionals in ACS are fixed precision and are simply (xxxx.xxxx * 65536) when stored as its final value.
Don't use float because you will lose some precision. Floats can no doubt store the value, yes, but they do a terrible job of it.
Re: Export level.info->pixelstretch to ZScript
And how is this applicable to our topic? You need more than 6 significant digits for pixelstretch, right? I think two or three "ought to be enough for anybody".
Although if you plan to do lots of calculations with values of various range then it makes sense. But not if you are about to store one read-only value then it's not.
Generic suggestion like "do not use floats, use doubles" is the same as suggestions to "do not use 32-bit integers as they overflow quicker than 64-bit". Out of context this is plainly ridiculous.
Although if you plan to do lots of calculations with values of various range then it makes sense. But not if you are about to store one read-only value then it's not.
Generic suggestion like "do not use floats, use doubles" is the same as suggestions to "do not use 32-bit integers as they overflow quicker than 64-bit". Out of context this is plainly ridiculous.