Patch update - Scene window
This commit is contained in:
parent
06efdf6f6c
commit
15217a5df8
@ -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();
|
||||
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
ApplicationClass();
|
||||
~ApplicationClass();
|
||||
D3DClass* GetDirect3D();
|
||||
RenderTextureClass* GetRenderTexture() const { return m_SceneTexture; };
|
||||
|
||||
bool Initialize(int, int, HWND);
|
||||
void Shutdown();
|
||||
@ -111,6 +112,9 @@ public:
|
||||
bool IsWindowed() const;
|
||||
void SetWindowed(bool windowed);
|
||||
|
||||
void SetWindowSize(ImVec2 size) { windowSize = size; };
|
||||
ImVec2 GetWindowSize() const { return windowSize; };
|
||||
|
||||
Physics* GetPhysics() const { return m_Physics; };
|
||||
|
||||
// ----------------------------------- //
|
||||
@ -159,7 +163,7 @@ private :
|
||||
// ------------------------------------- //
|
||||
|
||||
XMMATRIX m_baseViewMatrix;
|
||||
RenderTextureClass* m_RenderTexture, * m_RefractionTexture, * m_ReflectionTexture;
|
||||
RenderTextureClass* m_RenderTexture, * m_RefractionTexture, * m_ReflectionTexture, * m_SceneTexture;
|
||||
DisplayPlaneClass* m_DisplayPlane;
|
||||
int m_screenWidth, m_screenHeight;
|
||||
CameraClass* m_Camera;
|
||||
@ -227,6 +231,7 @@ private :
|
||||
Physics* m_Physics;
|
||||
float m_gravity;
|
||||
XMVECTOR m_previousPosition;
|
||||
ImVec2 windowSize;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- Culling --------------------- //
|
||||
|
@ -4,22 +4,22 @@ Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=1665,27
|
||||
Size=375,1094
|
||||
Pos=1201,27
|
||||
Size=375,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=8,27
|
||||
Size=331,1094
|
||||
Size=330,826
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
DockId=0x00000001,1
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=8,27
|
||||
Size=331,1094
|
||||
Size=330,826
|
||||
Collapsed=0
|
||||
DockId=0x00000003,1
|
||||
DockId=0x00000001,0
|
||||
|
||||
[Window][Light]
|
||||
Pos=1648,27
|
||||
@ -29,25 +29,31 @@ DockId=0x00000005,1
|
||||
|
||||
[Window][Shader Manager]
|
||||
Pos=8,27
|
||||
Size=331,1094
|
||||
Size=330,1094
|
||||
Collapsed=0
|
||||
DockId=0x00000003,2
|
||||
DockId=0x00000001,2
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1648,27
|
||||
Size=392,1094
|
||||
Pos=1201,27
|
||||
Size=375,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,2
|
||||
DockId=0x00000005,1
|
||||
|
||||
[Window][DockSpace Demo]
|
||||
Pos=0,0
|
||||
Size=2048,1129
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xC0DFADC4 Window=0xD0388BC8 Pos=8,27 Size=2032,1094 Split=X
|
||||
DockNode ID=0x00000002 Parent=0xC0DFADC4 SizeRef=1655,1094 Split=X
|
||||
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=331,826 Selected=0x031DC75C
|
||||
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=1322,826 CentralNode=1 Selected=0x9F035453
|
||||
DockNode ID=0x00000005 Parent=0xC0DFADC4 SizeRef=375,1094 Selected=0x9F035453
|
||||
[Window][Render Window]
|
||||
Pos=340,27
|
||||
Size=859,826
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xC0DFADC4 Window=0xD0388BC8 Pos=8,27 Size=1568,826 Split=X
|
||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x031DC75C
|
||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 Split=X
|
||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1655,1094 CentralNode=1 Selected=0x9204953B
|
||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=375,1094 Selected=0x9F035453
|
||||
|
||||
|
@ -416,6 +416,8 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
||||
WidgetEngineSettingsWindow(app);
|
||||
}
|
||||
|
||||
WidgetRenderWindow(app, ImVec2(800, 600));
|
||||
|
||||
//render imgui
|
||||
Render();
|
||||
|
||||
@ -475,5 +477,30 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
app->SetFrustumTolerance(frustumTolerance);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize)
|
||||
{
|
||||
ImGui::Begin("Render Window");
|
||||
|
||||
windowSize = ImGui::GetContentRegionAvail();
|
||||
app->SetWindowSize(windowSize);
|
||||
|
||||
// Assurez-vous que la texture est valide
|
||||
RenderTextureClass* renderTexture = app->GetRenderTexture();
|
||||
if (renderTexture)
|
||||
{
|
||||
// Obtenez la vue de la ressource shader de la texture rendue
|
||||
ID3D11ShaderResourceView* texture = renderTexture->GetShaderResourceView();
|
||||
|
||||
// Affichez la texture dans une fenêtre ImGui
|
||||
ImGui::Image((ImTextureID)texture, windowSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Render texture is not available.");
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
@ -34,9 +34,13 @@ public:
|
||||
void WidgetLightWindow(ApplicationClass* app);
|
||||
void WidgetShaderWindow(ApplicationClass* app);
|
||||
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
||||
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
||||
|
||||
bool ImGuiWidgetRenderer(ApplicationClass* app);
|
||||
|
||||
void SetWindowSize(ImVec2 size) { windowSize = size; }
|
||||
ImVec2 GetWindowSize() const { return windowSize; }
|
||||
|
||||
// Shader toggles
|
||||
|
||||
bool m_EnableCelShading;
|
||||
@ -54,6 +58,7 @@ private :
|
||||
|
||||
ID3D11Device* m_device;
|
||||
ID3D11DeviceContext* m_deviceContext;
|
||||
ImVec2 windowSize;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user