mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-28 16:58: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()
|
static public void LoadAll()
|
||||||
{
|
{
|
||||||
|
if (Textures != null)
|
||||||
|
DeleteDictionaryAndKeysAndValues!(Textures);
|
||||||
Textures = new .();
|
Textures = new .();
|
||||||
Load<Texture>("textures", "*.png", Textures, (path) => PlatformLayer.LoadTexture(path));
|
Load<Texture>("textures", "*.png", Textures, (path) => PlatformLayer.LoadTexture(path));
|
||||||
|
|
||||||
|
if (Sprites != null)
|
||||||
|
DeleteDictionaryAndKeysAndValues!(Sprites);
|
||||||
Sprites = new .();
|
Sprites = new .();
|
||||||
Load<Sprite>("sprites", "*.ase", Sprites, (path) => { return new Sprite(new String(path)); });
|
Load<Sprite>("sprites", "*.ase", Sprites, (path) => { return new Sprite(new String(path)); });
|
||||||
}
|
}
|
||||||
|
@ -39,8 +43,9 @@ namespace Strawberry
|
||||||
static public void DisposeAll()
|
static public void DisposeAll()
|
||||||
{
|
{
|
||||||
DeleteDictionaryAndKeysAndValues!(Textures);
|
DeleteDictionaryAndKeysAndValues!(Textures);
|
||||||
|
Textures = null;
|
||||||
DeleteDictionaryAndKeysAndValues!(Sprites);
|
DeleteDictionaryAndKeysAndValues!(Sprites);
|
||||||
Sprite.[Friend]Dispose();
|
Sprites = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void Load<T>(String directory, String wildcard, Dictionary<String, T> putInto, function T(String) loader)
|
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
|
namespace Strawberry
|
||||||
{
|
{
|
||||||
public abstract class Editor : Module
|
public abstract class Editor : Module
|
||||||
|
@ -10,8 +11,11 @@ namespace Strawberry
|
||||||
|
|
||||||
protected override void Render()
|
protected override void Render()
|
||||||
{
|
{
|
||||||
|
PlatformLayer.RenderBegin();
|
||||||
PlatformLayer.ImGuiRenderBegin();
|
PlatformLayer.ImGuiRenderBegin();
|
||||||
|
ImGui.PushID("Editor");
|
||||||
UI();
|
UI();
|
||||||
|
ImGui.PopID();
|
||||||
PlatformLayer.ImGuiRenderEnd();
|
PlatformLayer.ImGuiRenderEnd();
|
||||||
PlatformLayer.RenderEnd();
|
PlatformLayer.RenderEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Strawberry
|
||||||
private bool updating;
|
private bool updating;
|
||||||
|
|
||||||
public Batcher Batcher { get; private set; }
|
public Batcher Batcher { get; private set; }
|
||||||
public Color ClearColor = .Black;
|
|
||||||
public bool DebugOverlay = false;
|
public bool DebugOverlay = false;
|
||||||
|
|
||||||
private bool* keyboardState;
|
private bool* keyboardState;
|
||||||
|
@ -92,14 +91,20 @@ namespace Strawberry
|
||||||
|
|
||||||
protected override void Render()
|
protected override void Render()
|
||||||
{
|
{
|
||||||
|
PlatformLayer.RenderBegin();
|
||||||
|
|
||||||
|
// game
|
||||||
PlatformLayer.GameRenderBegin();
|
PlatformLayer.GameRenderBegin();
|
||||||
Draw();
|
Draw();
|
||||||
PlatformLayer.GameRenderEnd();
|
PlatformLayer.GameRenderEnd();
|
||||||
|
|
||||||
|
// debug overlay
|
||||||
if (DebugOverlay)
|
if (DebugOverlay)
|
||||||
{
|
{
|
||||||
PlatformLayer.ImGuiRenderBegin();
|
PlatformLayer.ImGuiRenderBegin();
|
||||||
|
ImGui.PushID("DebugOverlay");
|
||||||
DebugOverlay();
|
DebugOverlay();
|
||||||
|
ImGui.PopID();
|
||||||
PlatformLayer.ImGuiRenderEnd();
|
PlatformLayer.ImGuiRenderEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Strawberry
|
||||||
public abstract bool Closed(); // Returns whether the game window has been closed
|
public abstract bool Closed(); // Returns whether the game window has been closed
|
||||||
|
|
||||||
//Rendering
|
//Rendering
|
||||||
|
public abstract void RenderBegin();
|
||||||
public abstract void GameRenderBegin();
|
public abstract void GameRenderBegin();
|
||||||
public abstract void GameRenderEnd();
|
public abstract void GameRenderEnd();
|
||||||
public abstract void ImGuiRenderBegin();
|
public abstract void ImGuiRenderBegin();
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Strawberry.SDL2
|
||||||
public int TextureMatrixLocation { get; private set; }
|
public int TextureMatrixLocation { get; private set; }
|
||||||
public Texture.Filters TextureFilter = .Nearest;
|
public Texture.Filters TextureFilter = .Nearest;
|
||||||
public bool TextureClamping = false;
|
public bool TextureClamping = false;
|
||||||
|
public Color ClearColor = .Black;
|
||||||
|
|
||||||
private SDL.Window* window;
|
private SDL.Window* window;
|
||||||
private SDL.Surface* screen;
|
private SDL.Surface* screen;
|
||||||
|
@ -169,6 +170,24 @@ namespace Strawberry.SDL2
|
||||||
|
|
||||||
public override uint32 Ticks => SDL.GetTicks();
|
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()
|
public override void ImGuiRenderBegin()
|
||||||
{
|
{
|
||||||
ImGuiImplOpenGL3.NewFrame();
|
ImGuiImplOpenGL3.NewFrame();
|
||||||
|
@ -182,20 +201,6 @@ namespace Strawberry.SDL2
|
||||||
ImGuiImplOpenGL3.RenderDrawData(ImGui.ImGui.GetDrawData());
|
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()
|
public override void RenderEnd()
|
||||||
{
|
{
|
||||||
SDL.GL_SwapWindow(window);
|
SDL.GL_SwapWindow(window);
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Strawberry
|
||||||
static private void Shutdown()
|
static private void Shutdown()
|
||||||
{
|
{
|
||||||
Input.[Friend]Shutdown();
|
Input.[Friend]Shutdown();
|
||||||
|
Sprite.[Friend]Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user