Skip to content

Commit

Permalink
Imgui initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
RiverHillbug committed Mar 9, 2024
1 parent f7fdd6d commit aca3d84
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Minigin/InputManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include <SDL.h>
#include "InputManager.h"
#include "backends/imgui_impl_sdl2.h"
//#include "xinput.h"
//#include "winbase.h"
//#include "winnt.h"

bool dae::InputManager::ProcessInput()
{
//ZeroMemory(&m_CurrentState, sizeof(XINPUT_STATE));
//XInputGetState(0, &m_CurrentState);

SDL_Event e;
while (SDL_PollEvent(&e))
{
Expand All @@ -19,6 +26,8 @@ bool dae::InputManager::ProcessInput()

}
// etc...

ImGui_ImplSDL2_ProcessEvent(&e);
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions Minigin/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace dae
{
public:
bool ProcessInput();

private:

};

}
18 changes: 18 additions & 0 deletions Minigin/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "Renderer.h"
#include "SceneManager.h"
#include "Texture2D.h"
#include "backends/imgui_impl_opengl3.h"
#include "backends/imgui_impl_sdl2.h"

int GetOpenGLDriverIndex()
{
Expand All @@ -25,6 +27,11 @@ void Renderer::Init(SDL_Window* window)
{
throw std::runtime_error(std::string("SDL_CreateRenderer Error: ") + SDL_GetError());
}

IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui_ImplSDL2_InitForOpenGL(window, SDL_GL_GetCurrentContext());
ImGui_ImplOpenGL3_Init();
}

void Renderer::Render() const
Expand All @@ -35,11 +42,22 @@ void Renderer::Render() const

SceneManager::GetInstance().Render();

ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
ImGui::ShowDemoWindow();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

SDL_RenderPresent(m_pRenderer);
}

void Renderer::Destroy()
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();

if (m_pRenderer != nullptr)
{
SDL_DestroyRenderer(m_pRenderer);
Expand Down

0 comments on commit aca3d84

Please sign in to comment.