diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-21 19:07:16 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-21 19:07:16 +0100 |
| commit | 2861f2db6f918c48019c1ac3f91bf6a407452493 (patch) | |
| tree | db451bde7a552ac6bd8369e6ff0279a96b125600 /src/main/kotlin/gui/WindowContainer.kt | |
| parent | 7fd114712c1921cb03748d42deeb655f6b225cce (diff) | |
| download | KGB-2861f2db6f918c48019c1ac3f91bf6a407452493.tar.xz KGB-2861f2db6f918c48019c1ac3f91bf6a407452493.zip | |
Add imgui based debug window container
Diffstat (limited to 'src/main/kotlin/gui/WindowContainer.kt')
| -rw-r--r-- | src/main/kotlin/gui/WindowContainer.kt | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/main/kotlin/gui/WindowContainer.kt b/src/main/kotlin/gui/WindowContainer.kt new file mode 100644 index 0000000..5e101b7 --- /dev/null +++ b/src/main/kotlin/gui/WindowContainer.kt @@ -0,0 +1,66 @@ +package gui + +import cpu.Cpu +import glm_.vec4.Vec4 +import gln.checkError +import imgui.Context +import imgui.ImGui +import imgui.destroy +import imgui.impl.LwjglGL3 +import org.lwjgl.opengl.GL11 +import uno.glfw.GlfwWindow +import uno.glfw.glfw + +class WindowContainer { + + var cpu: Cpu + + init { + glfw.init("3.2") + cpu = Cpu() + } + + val window = GlfwWindow(1280, 720, "KGB - KotlinGameBoy").apply { + init() + } + + + fun run() { + + // Enable vsync + glfw.swapInterval = 1 + + val ctx = Context() + LwjglGL3.init(window) + ImGui.styleColorsDark() + + window.loop(::mainLoop) + + LwjglGL3.shutdown() + ctx.destroy() + + window.destroy() + glfw.terminate() + + } + + private fun mainLoop() { + + LwjglGL3.newFrame() + + with(ImGui) { + paintDebugWindow() + paintEmulationOutputWindow() + paintCpuRegisterWindow(cpu.registers) + } + + gln.glViewport(window.framebufferSize) + gln.glClearColor(Vec4(0.45f, 0.55f, 0.6f, 1f)) + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT) + + ImGui.render() + LwjglGL3.renderDrawData(ImGui.drawData!!) + + checkError("mainLoop") + } +}
\ No newline at end of file |