mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-25 16:18:56 +08:00
Module swapping works
This commit is contained in:
parent
d7aa6346e8
commit
ef5a886b3a
|
@ -29,9 +29,13 @@ namespace Strawberry
|
|||
|
||||
static public void LoadAll()
|
||||
{
|
||||
if (Textures != null)
|
||||
DeleteDictionaryAndKeysAndValues!(Textures);
|
||||
Textures = new .();
|
||||
Load<Texture>("textures", "*.png", Textures, (path) => PlatformLayer.LoadTexture(path));
|
||||
|
||||
if (Sprites != null)
|
||||
DeleteDictionaryAndKeysAndValues!(Sprites);
|
||||
Sprites = new .();
|
||||
Load<Sprite>("sprites", "*.ase", Sprites, (path) => { return new Sprite(new String(path)); });
|
||||
}
|
||||
|
@ -39,8 +43,9 @@ namespace Strawberry
|
|||
static public void DisposeAll()
|
||||
{
|
||||
DeleteDictionaryAndKeysAndValues!(Textures);
|
||||
Textures = null;
|
||||
DeleteDictionaryAndKeysAndValues!(Sprites);
|
||||
Sprite.[Friend]Dispose();
|
||||
Sprites = null;
|
||||
}
|
||||
|
||||
static private void Load<T>(String directory, String wildcard, Dictionary<String, T> putInto, function T(String) loader)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using ImGui;
|
||||
namespace Strawberry
|
||||
{
|
||||
public abstract class Editor : Module
|
||||
|
@ -10,8 +11,11 @@ namespace Strawberry
|
|||
|
||||
protected override void Render()
|
||||
{
|
||||
PlatformLayer.RenderBegin();
|
||||
PlatformLayer.ImGuiRenderBegin();
|
||||
ImGui.PushID("Editor");
|
||||
UI();
|
||||
ImGui.PopID();
|
||||
PlatformLayer.ImGuiRenderEnd();
|
||||
PlatformLayer.RenderEnd();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Strawberry
|
|||
private bool updating;
|
||||
|
||||
public Batcher Batcher { get; private set; }
|
||||
public Color ClearColor = .Black;
|
||||
public bool DebugOverlay = false;
|
||||
|
||||
private bool* keyboardState;
|
||||
|
@ -92,14 +91,20 @@ namespace Strawberry
|
|||
|
||||
protected override void Render()
|
||||
{
|
||||
PlatformLayer.RenderBegin();
|
||||
|
||||
// game
|
||||
PlatformLayer.GameRenderBegin();
|
||||
Draw();
|
||||
PlatformLayer.GameRenderEnd();
|
||||
|
||||
// debug overlay
|
||||
if (DebugOverlay)
|
||||
{
|
||||
PlatformLayer.ImGuiRenderBegin();
|
||||
ImGui.PushID("DebugOverlay");
|
||||
DebugOverlay();
|
||||
ImGui.PopID();
|
||||
PlatformLayer.ImGuiRenderEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Strawberry
|
|||
public abstract bool Closed(); // Returns whether the game window has been closed
|
||||
|
||||
//Rendering
|
||||
public abstract void RenderBegin();
|
||||
public abstract void GameRenderBegin();
|
||||
public abstract void GameRenderEnd();
|
||||
public abstract void ImGuiRenderBegin();
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Strawberry.SDL2
|
|||
public int TextureMatrixLocation { get; private set; }
|
||||
public Texture.Filters TextureFilter = .Nearest;
|
||||
public bool TextureClamping = false;
|
||||
public Color ClearColor = .Black;
|
||||
|
||||
private SDL.Window* window;
|
||||
private SDL.Surface* screen;
|
||||
|
@ -169,6 +170,24 @@ namespace Strawberry.SDL2
|
|||
|
||||
public override uint32 Ticks => SDL.GetTicks();
|
||||
|
||||
public override void RenderBegin()
|
||||
{
|
||||
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
|
||||
GL.glClearColor(ClearColor.Rf, ClearColor.Gf, ClearColor.Bf, ClearColor.Af);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
public override void GameRenderBegin()
|
||||
{
|
||||
GL.glUseProgram(glProgram);
|
||||
}
|
||||
|
||||
public override void GameRenderEnd()
|
||||
{
|
||||
GL.glUseProgram(0);
|
||||
GL.glFlush();
|
||||
}
|
||||
|
||||
public override void ImGuiRenderBegin()
|
||||
{
|
||||
ImGuiImplOpenGL3.NewFrame();
|
||||
|
@ -182,20 +201,6 @@ namespace Strawberry.SDL2
|
|||
ImGuiImplOpenGL3.RenderDrawData(ImGui.ImGui.GetDrawData());
|
||||
}
|
||||
|
||||
public override void GameRenderBegin()
|
||||
{
|
||||
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
|
||||
GL.glClearColor(Game.ClearColor.Rf, Game.ClearColor.Gf, Game.ClearColor.Bf, Game.ClearColor.Af);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
|
||||
GL.glUseProgram(glProgram);
|
||||
}
|
||||
|
||||
public override void GameRenderEnd()
|
||||
{
|
||||
GL.glUseProgram(0);
|
||||
GL.glFlush();
|
||||
}
|
||||
|
||||
public override void RenderEnd()
|
||||
{
|
||||
SDL.GL_SwapWindow(window);
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Strawberry
|
|||
static private void Shutdown()
|
||||
{
|
||||
Input.[Friend]Shutdown();
|
||||
Sprite.[Friend]Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user