Texture translation fonctionne

This commit is contained in:
GolfOcean334 2024-04-04 22:15:09 +02:00
parent b5d597b64e
commit 2ab975ce93
2 changed files with 7 additions and 43 deletions

View File

@ -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;

View File

@ -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;