Added IMGUI

Feature/BasicRenderer
Nigel Barink 2022-05-04 14:39:27 +02:00
parent 9c92cc05b7
commit af4a114fad
7 changed files with 90 additions and 8 deletions

3
.gitmodules vendored
View File

@ -13,3 +13,6 @@
[submodule "GorrillaAudio"]
path = libs/GorillaAudio
url = https://github.com/mewspring/gorilla-audio.git
[submodule "ImGui"]
path = libs/ImGui
url = https://github.com/ocornut/imgui.git

View File

@ -18,9 +18,12 @@ class BarinkWindow{
BarinkWindow(const int width, const int height);
~BarinkWindow();
GLFWwindow* windowptr();
bool WindowShouldClose();
void Poll();
void SwapBuffers();
};

View File

@ -50,6 +50,11 @@ Width(width), Height(height), FullScreen(false){
BarinkWindow::~BarinkWindow(){
glfwTerminate();
}
GLFWwindow* BarinkWindow::windowptr()
{
return window;
}
bool BarinkWindow::WindowShouldClose(){
@ -58,6 +63,11 @@ bool BarinkWindow::WindowShouldClose(){
void BarinkWindow::Poll()
{
glfwSwapBuffers(window);
glfwPollEvents();
}
void BarinkWindow::SwapBuffers()
{
glfwSwapBuffers(window);
}

View File

@ -4,6 +4,10 @@
#include <MyGraphicsEngine/Mesh.h>
#include <string>
#include "imgui.h"
#include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h"
/*
* extern "C"
{
@ -11,11 +15,12 @@
#include "lua.h"
#include "lualib.h"
}
*/
//#include <include/AssetManager/ModelImporter.h>
#include <include/AssetManager/ModelImporter.h>
#include <gorilla/gau.h>
#include <gorilla/ga.h>
*/
int main(int argc, char* argv[]) {
@ -44,6 +49,16 @@ int main(int argc, char* argv[]) {
BarinkWindow GameWindow(800, 600);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(GameWindow.windowptr(), true);
ImGui_ImplOpenGL3_Init("#version 440");
std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
Shader shader (vertexShaderSource, fragmentShaderSource);
@ -95,7 +110,8 @@ int main(int argc, char* argv[]) {
glm::mat4 projection = glm::perspective(cam.Zoom, (800.0f / 600.0f), 0.001f, 100.0f);
gau_Manager* mgr;
/*
* gau_Manager* mgr;
ga_Mixer* mixer;
ga_Sound sound;
ga_Handle handle;
@ -108,13 +124,19 @@ int main(int argc, char* argv[]) {
gc_initialize(0);
mgr = gau_manager_create();
mixer = gau_manager_mixer(mgr);
*/
while (!GameWindow.WindowShouldClose()) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) ;
GameWindow.Poll();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
shader.Use();
shader.setUniformMat4("P", projection);
shader.setUniformMat4("M", model);
@ -124,11 +146,34 @@ int main(int argc, char* argv[]) {
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
glBindVertexArray(0);
GameWindow.Poll();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Test");
ImGui::Text("Hello world!");
bool isChecked = false;
ImGui::Checkbox("Yellow!", &isChecked);
float v = 5;
ImGui::SliderFloat("Something to slide on..", &v, 1, 10 );
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
GameWindow.SwapBuffers();
}
// Cleanup
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &EBO);

15
imgui.ini Normal file
View File

@ -0,0 +1,15 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Test]
Pos=268,47
Size=201,94
Collapsed=0
[Window][Dear ImGui Demo]
Pos=650,20
Size=550,680
Collapsed=0

1
libs/ImGui Submodule

@ -0,0 +1 @@
Subproject commit 6d27fecce1ea2cb10ca956cd67b8179cb76b35c3

View File

@ -20,12 +20,14 @@ workspace "BarinkEngine"
"./libs/GorillaAudio/include",
"./libs/lua/include",
"./libs/glfw/include",
"./libs/ImGui"
}
libdirs{
"./libs/spdlog/build/Release",
"./libs/glfw/build/src/Debug",
"./libs/lua"
"./libs/lua",
"./libs/ImGui"
}
links{
@ -36,6 +38,9 @@ workspace "BarinkEngine"
}
files {
"./libs/ImGui/*.cpp",
"./libs/ImGui/backends/imgui_impl_glfw.cpp",
"./libs/ImGui/backends/imgui_impl_Opengl3.cpp",
"SandboxApplication/*.cpp"
}