Minor Update - ImGui Render Tweak

[FEAT] :

~ Modification de la chaine de rendu dans la method Frame()

~ Modification de l'interface de lights
This commit is contained in:
CatChow0 2024-04-21 21:57:11 +02:00
parent 25f05fe217
commit 7ef81b9c91
5 changed files with 60 additions and 18 deletions

View File

@ -189,6 +189,8 @@ void SystemClass::Run()
bool SystemClass::Frame()
{
// Clear the buffers to begin the scene.
m_Application->GetDirect3D()->BeginScene(0.0f, 0.0f, 0.0f, 1.0f);
std::lock_guard<std::mutex> guard(renderMutex);
bool result;
@ -201,6 +203,14 @@ bool SystemClass::Frame()
return false;
}
// Do the frame processing for the application class object.
result = m_Application->Frame(m_Input);
if (!result)
{
Logger::Get().Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Render ImGui
result = m_imguiManager->ImGuiWidgetRenderer(m_Application);
if (!result)
@ -209,13 +219,7 @@ bool SystemClass::Frame()
return false;
}
// Do the frame processing for the application class object.
result = m_Application->Frame(m_Input);
if (!result)
{
Logger::Get().Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
m_Application->GetDirect3D()->EndScene();
return true;
}

View File

@ -691,9 +691,6 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
// Set the blending amount to 10%.
blendAmount = 0.1f;
// Clear the buffers to begin the scene.
m_Direct3D->BeginScene(0.0f, 0.0f, 0.0f, 1.0f);
// Generate the view matrix based on the camera's position.
m_Camera->Render();
@ -1141,9 +1138,6 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
m_Direct3D->TurnZBufferOn();
m_Direct3D->DisableAlphaBlending();
// Present the rendered scene to the screen.
m_Direct3D->EndScene();
return true;
}
@ -1497,4 +1491,43 @@ void ApplicationClass::DeleteLight(int index)
// Remove the light from the vector
m_Lights.erase(m_Lights.begin() + index);
// Decrement the number of lights
m_numLights--;
// Update the light position and color
for (int i = 0; i < m_numLights; i++)
{
m_Lights[i]->SetPosition(i * 10.0f, 10.0f, -10.0f);
m_Lights[i]->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
void ApplicationClass::AddLight()
{
Logger::Get().Log("Adding light", __FILE__, __LINE__);
// Create a new light object
LightClass* newLight = new LightClass();
// Set the light position
newLight->SetPosition(m_numLights * 10.0f, 10.0f, -10.0f);
// Set the light color
newLight->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
// Set the light direction
newLight->SetDirection(0.0f, 0.0f, 1.0f);
// Set the light specular color
newLight->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
// Set the light specular power
newLight->SetSpecularPower(16.0f);
// Add the light to the vector
m_Lights.push_back(newLight);
// Increment the number of lights
m_numLights++;
}

View File

@ -79,6 +79,7 @@ public:
void SetLightPosition(int index, XMVECTOR color);
void SetLightColor(int index, XMVECTOR color);
void DeleteLight(int index);
void AddLight();
std::vector<LightClass*> GetLights() const { return m_Lights; };
bool GetShouldQuit() const { return m_ShouldQuit; };

View File

@ -3,7 +3,7 @@ Pos=60,60
Size=400,400
[Window][Khaotic Engine]
Pos=429,57
Pos=30,173
Size=392,218
[Window][Objects]
@ -11,10 +11,10 @@ Pos=39,222
Size=379,299
[Window][Terrain]
Pos=60,60
Pos=397,130
Size=342,82
[Window][Light]
Pos=62,180
Pos=34,172
Size=345,230

View File

@ -254,8 +254,6 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
//render imgui
Render();
app->GetDirect3D()->m_swapChain->Present(0, NULL);
return true;
}
@ -263,6 +261,12 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
{
ImGui::Begin("Light", &showLightWindow);
int index = 0;
// add light button
if (ImGui::Button("Add Light"))
{
app->AddLight();
}
for(auto& light : app->GetLights())
{
std::string headerName = "Light " + std::to_string(index);