Expose canvas texture creation to ZScript

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
AFADoomer
Posts: 1341
Joined: Tue Jul 15, 2003 4:18 pm

Expose canvas texture creation to ZScript

Post by AFADoomer »

Requesting the ability to define canvas textures via ZScript instead of being limited to ANIMDEFS-defined values.

Maybe a new function under the Canvas class and lifting the code from ParseCameraTexture?
native static Canvas Create(String canvasname, int width, int height, int offsetx = 0, int offsety = 0, int usetype = TexMan.Type_Wall);
dpJudas
 
 
Posts: 3160
Joined: Sat May 28, 2016 1:01 pm

Re: Expose canvas texture creation to ZScript

Post by dpJudas »

It was a deliberate design decision to not give a function like that. The canvas texture is allocated on the GPU and for that reason need strict resource control. Allowing zscript to create arbitrary textures with unknown lifetimes will create tons of problems for the engine. On top of that ZScript is garbage collected, making it even more tricky to know when such a canvas is no longer in use.
User avatar
AFADoomer
Posts: 1341
Joined: Tue Jul 15, 2003 4:18 pm

Re: Expose canvas texture creation to ZScript

Post by AFADoomer »

I am not as familiar with the engine internals as others are... But I don't understand the difference between a mod author defining 5000 (or whatever random large-ish number) ANIMDEFS entries and using those versus creating the texture via code.

How do those two approaches (that call the same underlying engine functions to create the textures) affect the engine differently?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49215
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expose canvas texture creation to ZScript

Post by Graf Zahl »

If they fail, one will crash the game in the middle of a level, the other won't even start up.

The far bigger risk is something else: Badly written code constantly creating new textures without stopping.
All things considered, it's not a good idea to give modders control over limited hardware resources. These can result in nasty performance regressions and other things and are very hard to diagnose.

Return to “Feature Suggestions [GZDoom]”