Patch update - Scene window

This commit is contained in:
2025-01-16 21:02:17 +01:00
parent 06efdf6f6c
commit 15217a5df8
5 changed files with 95 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
m_Light = 0;
m_RefractionTexture = 0;
m_ReflectionTexture = 0;
m_SceneTexture = nullptr;
m_Physics = 0;
m_cubes.clear();
m_terrainChunk.clear();
@@ -123,6 +124,17 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
return false;
}
//ImVec2 availableSize = ImGui::GetContentRegionAvail();
// Create and initialize the scene render to texture object.
m_SceneTexture = new RenderTextureClass();
result = m_SceneTexture->Initialize(m_Direct3D->GetDevice(), 256, 256, SCREEN_DEPTH, SCREEN_NEAR, 1);
if (!result)
{
Logger::Get().Log("Could not initialize the render texture object", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the display plane object.
m_DisplayPlane = new DisplayPlaneClass;
@@ -635,6 +647,13 @@ void ApplicationClass::Shutdown()
Logger::Get().Log("Model object released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
if (m_SceneTexture)
{
m_SceneTexture->Shutdown();
delete m_SceneTexture;
m_SceneTexture = nullptr;
}
Logger::Get().Log("Application class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -935,6 +954,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
m_Camera->Render();
// Get the world, view, and projection matrices from the camera and d3d objects.
worldMatrix = m_Direct3D->GetWorldMatrix();
m_Camera->GetViewMatrix(viewMatrix);
@@ -954,6 +974,17 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
ambientColor[i] = m_Lights[i]->GetPosition();
}
// Redimensionner la texture de rendu si n<>cessaire
if (m_SceneTexture->GetTextureWidth() != windowSize.x || m_SceneTexture->GetTextureHeight() != windowSize.y)
{
m_SceneTexture->Shutdown();
m_SceneTexture->Initialize(m_Direct3D->GetDevice(), windowSize.x, windowSize.y, SCREEN_DEPTH, SCREEN_NEAR, 1);
}
m_SceneTexture->SetRenderTarget(m_Direct3D->GetDeviceContext());
m_SceneTexture->ClearRenderTarget(m_Direct3D->GetDeviceContext(), 0.0f, 0.0f, 0.0f, 1.0f);
//Add the 3 first value of the first light position to the TrueLightPosition XMFLOAT3
positionX = lightPosition[0].x;
positionY = lightPosition[0].y;
@@ -1295,6 +1326,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
}
// Enable the Z buffer and disable alpha blending now that 2D rendering is complete.
// R<>initialiser la cible de rendu au back buffer.
m_Direct3D->SetBackBufferRenderTarget();
m_Direct3D->TurnZBufferOn();
m_Direct3D->DisableAlphaBlending();