C'est init mais marche pas.... ALED

This commit is contained in:
CatChow0 2024-03-21 11:00:48 +01:00
parent db2c357472
commit b8724d7f28
6 changed files with 61 additions and 0 deletions

@ -1,4 +1,6 @@
#include "systemclass.h"
#include <iostream>
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
SystemClass::SystemClass()
{
@ -36,12 +38,22 @@ bool SystemClass::Initialize()
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
m_Application = new ApplicationClass;
// Initialize the application object.
result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd);
if (!result)
{
return false;
}
// Initialize imgui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplWin32_Init(m_hwnd);
ImGui_ImplDX11_Init(m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
return true;
}
@ -62,6 +74,11 @@ void SystemClass::Shutdown()
m_Input = 0;
}
// Shutdown imgui
ImGui_ImplDX11_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
// Shutdown the window.
ShutdownWindows();
@ -111,6 +128,7 @@ void SystemClass::Run()
bool SystemClass::Frame()
{
bool result;
float value = 0.0f;
// Check if the user pressed escape and wants to exit the application.
@ -119,6 +137,19 @@ bool SystemClass::Frame()
return false;
}
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
//ImGui Widget
ImGui::Begin("Khaotic Engine", NULL);
ImGui::Text("Salam");
ImGui::SliderFloat("Slider", &value, 0.0f, 1.0f);
ImGui::End();
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
// Do the frame processing for the application class object.
result = m_Application->Frame();
if (!result)
@ -131,6 +162,12 @@ bool SystemClass::Frame()
LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
if (ImGui_ImplWin32_WndProcHandler(hwnd, umsg, wparam, lparam))
{
return true;
}
switch (umsg)
{
// Check if a key has been pressed on the keyboard.

@ -152,4 +152,9 @@ bool ApplicationClass::Render()
m_Direct3D->EndScene();
return true;
}
D3DClass* ApplicationClass::GetDirect3D()
{
return m_Direct3D;
}

@ -25,6 +25,7 @@ public:
ApplicationClass();
ApplicationClass(const ApplicationClass&);
~ApplicationClass();
D3DClass* GetDirect3D();
bool Initialize(int, int, HWND);
void Shutdown();

@ -24,6 +24,12 @@
<ClCompile Include="Cameraclass.cpp" />
<ClCompile Include="Colorshaderclass.cpp" />
<ClCompile Include="d3dclass.cpp" />
<ClCompile Include="include\backends\imgui_impl_dx11.cpp" />
<ClCompile Include="include\backends\imgui_impl_win32.cpp" />
<ClCompile Include="include\imgui.cpp" />
<ClCompile Include="include\imgui_draw.cpp" />
<ClCompile Include="include\imgui_tables.cpp" />
<ClCompile Include="include\imgui_widgets.cpp" />
<ClCompile Include="inputclass.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="modelclass.cpp" />
@ -145,6 +151,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

8
enginecustom/imgui.ini Normal file

@ -0,0 +1,8 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
[Window][Khaotic Engine]
Pos=60,60
Size=51,48

@ -5,6 +5,9 @@
#include <windows.h>
#include "inputclass.h"
#include "applicationclass.h"
#include "imgui.h"
#include "imgui_impl_win32.h"
#include "imgui_impl_dx11.h"
class SystemClass
{