From 2ab975ce9317971abf8ec3853e0a830df6220f4a Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Thu, 4 Apr 2024 22:15:09 +0200 Subject: [PATCH] Texture translation fonctionne --- enginecustom/applicationclass.cpp | 47 ++++--------------------------- enginecustom/applicationclass.h | 3 +- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 04d83bc..e3bd39e 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -683,7 +683,7 @@ bool ApplicationClass::Frame(InputClass* Input) m_Camera->Render(); // Render the graphics scene. - result = Render(rotation, x, y, z); + result = Render(rotation, x, y, z, textureTranslation); if (!result) { return false; @@ -718,19 +718,6 @@ bool ApplicationClass::Frame(InputClass* Input) return false; } - // Render the graphics scene. - result = Render(rotation, x, y, z); - if (!result) - { - return false; - } - - result = RenderTextureTranslation(textureTranslation); - if (!result) - { - return false; - } - // Check if the mouse has been pressed. mouseDown = Input->IsMousePressed(); @@ -751,36 +738,13 @@ bool ApplicationClass::Frame(InputClass* Input) textureTranslation -= 1.0f; } - return true; -} - -bool ApplicationClass::RenderTextureTranslation(float textureTranslation) -{ - XMMATRIX worldMatrix, viewMatrix, projectionMatrix; - bool result; - - - // Clear the buffers to begin the scene. - m_Direct3D->BeginScene(0.0f, 0.0f, 0.0f, 1.0f); - - // Get the world, view, and projection matrices from the camera and d3d objects. - m_Direct3D->GetWorldMatrix(worldMatrix); - m_Camera->GetViewMatrix(viewMatrix); - m_Direct3D->GetProjectionMatrix(projectionMatrix); - - // Render the model using the translate shader. - m_Model->Render(m_Direct3D->GetDeviceContext()); - - result = m_TranslateShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, - m_Model->GetTexture(0), textureTranslation); + // Render the graphics scene. + result = Render(rotation, x, y, z, textureTranslation); if (!result) { return false; } - // Present the rendered scene to the screen. - m_Direct3D->EndScene(); - return true; } @@ -821,7 +785,7 @@ bool ApplicationClass::RenderSceneToTexture(float rotation) return true; } -bool ApplicationClass::Render(float rotation, float x, float y, float z) +bool ApplicationClass::Render(float rotation, float x, float y, float z, float textureTranslation) { XMMATRIX worldMatrix, viewMatrix, orthoMatrix, projectionMatrix, rotateMatrix, translateMatrix, scaleMatrix, srMatrix; float positionX, positionY, positionZ, radius; @@ -848,7 +812,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z) // Render the display plane using the texture shader and the render texture resource. m_DisplayPlane->Render(m_Direct3D->GetDeviceContext()); - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView()); + result = m_TranslateShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_Model->GetTexture(0), textureTranslation); if (!result) { return false; diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index d7d0826..9aad0e7 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -56,12 +56,11 @@ public: bool Frame(InputClass*); private: - bool Render(float, float, float, float); + bool Render(float, float, float, float, float); bool UpdateMouseStrings(int, int, bool); bool UpdateFps(); bool UpdateRenderCountString(int); bool RenderSceneToTexture(float); - bool RenderTextureTranslation(static float); private: D3DClass* m_Direct3D;