Elevate Engine 1
Loading...
Searching...
No Matches
Elevate::ImGuiLayer Class Reference

#include <ImGuiLayer.h>

Inheritance diagram for Elevate::ImGuiLayer:
Elevate::Layer

Public Member Functions

 ImGuiLayer ()
 
 ~ImGuiLayer ()
 
virtual void OnAttach () override
 
virtual void OnDetach () override
 
virtual void OnImGuiRender () override
 
void PreRender ()
 
void Begin ()
 
void Render ()
 
void End ()
 
void Cleanup ()
 
- Public Member Functions inherited from Elevate::Layer
 Layer (const std::string &name="Layer")
 
virtual ~Layer ()
 
virtual void OnUpdate ()
 
virtual void OnRender ()
 
virtual void OnEvent (Event &event)
 
const std::string & GetName () const
 

Additional Inherited Members

- Protected Attributes inherited from Elevate::Layer
std::string m_DebugName
 

Detailed Description

Definition at line 11 of file ImGuiLayer.h.

Constructor & Destructor Documentation

◆ ImGuiLayer()

Elevate::ImGuiLayer::ImGuiLayer ( )

Definition at line 15 of file ImGuiLayer.cpp.

16 : Layer("ImGuiLayer") { }
Layer(const std::string &name="Layer")
Definition Layer.cpp:5

◆ ~ImGuiLayer()

Elevate::ImGuiLayer::~ImGuiLayer ( )

Definition at line 18 of file ImGuiLayer.cpp.

19{
20}

Member Function Documentation

◆ Begin()

void Elevate::ImGuiLayer::Begin ( )

Definition at line 70 of file ImGuiLayer.cpp.

71{
72 // ImGui
73 ImGui::NewFrame();
74 // ImGuizmo
75 ImGuizmo::BeginFrame();
76}

◆ Cleanup()

void Elevate::ImGuiLayer::Cleanup ( )

Definition at line 100 of file ImGuiLayer.cpp.

101{
102 ImGui_ImplOpenGL3_Shutdown();
103 ImGui_ImplGlfw_Shutdown();
104 ImGui::DestroyContext();
105}

◆ End()

void Elevate::ImGuiLayer::End ( )

Definition at line 83 of file ImGuiLayer.cpp.

84{
85 ImGuiIO& io = ImGui::GetIO();
86 Application& app = Application::Get();
87 io.DisplaySize = ImVec2((float)app.GetWindow().GetWidth(), (float)app.GetWindow().GetHeight());
88
89 // Rendering
90 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
91 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
92 {
93 GLFWwindow* backup_current_context = glfwGetCurrentContext();
94 ImGui::UpdatePlatformWindows();
95 ImGui::RenderPlatformWindowsDefault();
96 glfwMakeContextCurrent(backup_current_context);
97 }
98}
static Application & Get()
Definition Application.h:62

◆ OnAttach()

void Elevate::ImGuiLayer::OnAttach ( )
overridevirtual

Reimplemented from Elevate::Layer.

Definition at line 22 of file ImGuiLayer.cpp.

23{
24 // Setup Dear ImGui context
25 IMGUI_CHECKVERSION();
26 ImGui::CreateContext();
27 ImGuiIO& io = ImGui::GetIO(); (void)io;
28 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
29 io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
30 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
31 io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
32
33 //io.ConfigViewportsNoAutoMerge = true;
34 //io.ConfigViewportsNoTaskBarIcon = true;
36
37 // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
38 ImGuiStyle& style = ImGui::GetStyle();
39 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
40 {
41 style.WindowRounding = 0.0f;
42 style.Colors[ImGuiCol_WindowBg].w = 1.0f;
43 }
44
45 Application& app = Application::Get();
46 GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());
47
48 // Setup Platform/Renderer bindings#
49 ImGui_ImplGlfw_InitForOpenGL(window, true);
50 ImGui_ImplOpenGL3_Init(EE_SHADER_VERSION_HEADER);
51}
#define EE_SHADER_VERSION_HEADER
Definition Core.h:31
void SetDarkTheme()

◆ OnDetach()

void Elevate::ImGuiLayer::OnDetach ( )
overridevirtual

Reimplemented from Elevate::Layer.

Definition at line 53 of file ImGuiLayer.cpp.

54{
55 ImGui_ImplOpenGL3_Shutdown();
56 ImGui_ImplGlfw_Shutdown();
57 ImGui::DestroyContext();
58}

◆ OnImGuiRender()

void Elevate::ImGuiLayer::OnImGuiRender ( )
overridevirtual

Reimplemented from Elevate::Layer.

Definition at line 60 of file ImGuiLayer.cpp.

61{
62}

◆ PreRender()

void Elevate::ImGuiLayer::PreRender ( )

Definition at line 64 of file ImGuiLayer.cpp.

65{
66 ImGui_ImplOpenGL3_NewFrame();
67 ImGui_ImplGlfw_NewFrame();
68}

◆ Render()

void Elevate::ImGuiLayer::Render ( )

Definition at line 78 of file ImGuiLayer.cpp.

79{
80 ImGui::Render();
81}

The documentation for this class was generated from the following files: