FosterFramework / Foster

A small C# game framework
MIT License
422 stars 37 forks source link

Framework and Platform improvements (App, Math, Graphical, Storage) #60

Closed Techiesplash closed 6 months ago

Techiesplash commented 6 months ago

Changes:

Additions

API change/addition examples:

Ease:

// Generates Out and InOut automatically
Ease autoEase = new (t => t * t);
// Generates only InOut automatically
Ease partialAutoEase = new (t => t * t, t => t * t);
// Generates nothing automatically
Ease manual = new (t => t * t, t => t * t, t => t * t);

// And to access the Easers it creates
var i = autoEase.In(t);
var o = autoEase.Out(t);
var x = autoEase.InOut(t);

// Ease also includes an Apply function that invokes InOut, and clamps the input to 0-1
x = autoEase.Apply(t);

// Easers can still be defined and used the same
Ease.Easer linear = (float t) => t;

Content:

// The Content class by default uses the default C# File/Directory API
// Assign to custom content class if desired
Content content = new Content(); 
Stream read = content.OpenRead();

// Uses the default WritableContent at directory App.UserPath
// Can be changed at UserStorage.Provider
UserStorage.WriteAllText("My Text!"); 

Effect on draw calls:

Benchmark details:

As current (0.1.16a) With fixes
Count: 276 Count: 166
FPS: ~13 FPS: ~13
Issues: 100 Issues: 2
NoelFB commented 6 months ago

Hey, this looks quite good, thank you! Few small thoughts:

Techiesplash commented 6 months ago

I put in obsolete-marked redirects for Easers. Indenting seems to be fixed... There's shenanigans going on with the IDE when it comes to indents.

NoelFB commented 6 months ago

Awesome, this looks really great, thanks for all the fixes and additions! :)

NoelFB commented 6 months ago

Hmm I'm getting a GL (ERROR:HIGH) GL_INVALID_OPERATION error generated. <texture> is not the name of an existing texture. sometimes when I try to create a Target (Framebuffer) now in a side project of mine. Investigating, not sure if it was from these changes or something else.

NoelFB commented 6 months ago

Yeah the error seems to occur if I create a Target, dispose it immediately, and then create another one. It re-uses the GL ID and something bad happens in fgl.glFramebufferTexture2D(GL_FRAMEBUFFER, tex->glAttachment, GL_TEXTURE_2D, tex->id, 0);. Looking into it.

NoelFB commented 6 months ago

Fixed this - it was an issue with deleting a texture while it was bound to a slot, and now that the slot stuff is actually caching properly, it broke. Pushing a fix!