From b5d597b64e6ff62f08e77b9c7679d80be849da35 Mon Sep 17 00:00:00 2001
From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com>
Date: Thu, 4 Apr 2024 10:50:37 +0200
Subject: [PATCH] bug bug bug mais integrer
---
enginecustom/Translate.xaml | 13 ------
enginecustom/applicationclass.cpp | 63 +++++++++++++++++++++++++++
enginecustom/applicationclass.h | 1 +
enginecustom/enginecustom.vcxproj | 38 +++-------------
enginecustom/packages.config | 4 --
enginecustom/translate.cpp | 18 --------
enginecustom/translate.h | 21 ---------
enginecustom/translateshaderclass.cpp | 4 +-
8 files changed, 72 insertions(+), 90 deletions(-)
delete mode 100644 enginecustom/Translate.xaml
delete mode 100644 enginecustom/packages.config
delete mode 100644 enginecustom/translate.cpp
delete mode 100644 enginecustom/translate.h
diff --git a/enginecustom/Translate.xaml b/enginecustom/Translate.xaml
deleted file mode 100644
index 0780d74..0000000
--- a/enginecustom/Translate.xaml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp
index 0444768..04d83bc 100644
--- a/enginecustom/applicationclass.cpp
+++ b/enginecustom/applicationclass.cpp
@@ -29,6 +29,7 @@ ApplicationClass::ApplicationClass()
m_Position = 0;
m_Frustum = 0;
m_DisplayPlane = 0;
+ m_TranslateShader = 0;
}
@@ -262,6 +263,16 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
return false;
}
+ // Create and initialize the translate shader object.
+ m_TranslateShader = new TranslateShaderClass;
+
+ result = m_TranslateShader->Initialize(m_Direct3D->GetDevice(), hwnd);
+ if (!result)
+ {
+ MessageBox(hwnd, L"Could not initialize the translate shader object.", L"Error", MB_OK);
+ return false;
+ }
+
// Create and initialize the light shader object.
m_LightShader = new LightShaderClass;
@@ -395,6 +406,14 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
void ApplicationClass::Shutdown()
{
+ // Release the translate shader object.
+ if (m_TranslateShader)
+ {
+ m_TranslateShader->Shutdown();
+ delete m_TranslateShader;
+ m_TranslateShader = 0;
+ }
+
// Release the frustum class object.
if (m_Frustum)
{
@@ -597,6 +616,7 @@ bool ApplicationClass::Frame(InputClass* Input)
int mouseX, mouseY, currentMouseX, currentMouseY;
bool result, mouseDown, keyDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE;
float rotationY, rotationX, positionX, positionY, positionZ;
+ static float textureTranslation = 0.0f;
float frameTime;
@@ -705,6 +725,12 @@ bool ApplicationClass::Frame(InputClass* Input)
return false;
}
+ result = RenderTextureTranslation(textureTranslation);
+ if (!result)
+ {
+ return false;
+ }
+
// Check if the mouse has been pressed.
mouseDown = Input->IsMousePressed();
@@ -718,6 +744,43 @@ bool ApplicationClass::Frame(InputClass* Input)
// Update the sprite object using the frame time.
m_Sprite->Update(frameTime);
+ // Increment the texture translation.
+ textureTranslation += 0.01f;
+ if (textureTranslation > 1.0f)
+ {
+ 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);
+ if (!result)
+ {
+ return false;
+ }
+
+ // Present the rendered scene to the screen.
+ m_Direct3D->EndScene();
+
return true;
}
diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h
index b7241f7..d7d0826 100644
--- a/enginecustom/applicationclass.h
+++ b/enginecustom/applicationclass.h
@@ -61,6 +61,7 @@ private:
bool UpdateFps();
bool UpdateRenderCountString(int);
bool RenderSceneToTexture(float);
+ bool RenderTextureTranslation(static float);
private:
D3DClass* m_Direct3D;
diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj
index db59440..be18868 100644
--- a/enginecustom/enginecustom.vcxproj
+++ b/enginecustom/enginecustom.vcxproj
@@ -1,6 +1,5 @@
-
Debug
@@ -49,10 +48,6 @@
-
- translate.vs
- Code
-
@@ -84,10 +79,6 @@
-
- translate.vs
- Code
-
@@ -103,7 +94,6 @@
-
@@ -115,7 +105,6 @@
Pixel
Pixel
Pixel
- false
Document
@@ -123,7 +112,6 @@
Vertex
Vertex
Vertex
- false
Document
@@ -146,23 +134,19 @@
-
+
Designer
-
-
+ Document
+
+
Designer
-
-
-
-
- Designer
-
+ Document
+
17.0
Win32Proj
{92cf56c4-76bb-40d4-8fe5-36c15f5f127a}
- enginecustom
10.0
@@ -267,14 +251,4 @@
-
-
-
-
-
- Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.
-
-
-
-
\ No newline at end of file
diff --git a/enginecustom/packages.config b/enginecustom/packages.config
deleted file mode 100644
index cbf6205..0000000
--- a/enginecustom/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/enginecustom/translate.cpp b/enginecustom/translate.cpp
deleted file mode 100644
index 7bf765c..0000000
--- a/enginecustom/translate.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "pch.h"
-#include "Translate.h"
-#if __has_include("Translate.g.cpp")
-#include "Translate.g.cpp"
-#endif
-
-namespace winrt::enginecustom::implementation
-{
- int32_t Translate::MyProperty()
- {
- throw hresult_not_implemented();
- }
-
- void Translate::MyProperty(int32_t /*value*/)
- {
- throw hresult_not_implemented();
- }
-}
diff --git a/enginecustom/translate.h b/enginecustom/translate.h
deleted file mode 100644
index 5e8a544..0000000
--- a/enginecustom/translate.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include "Translate.g.h"
-
-namespace winrt::enginecustom::implementation
-{
- struct Translate : TranslateT
- {
- Translate() = default;
-
- int32_t MyProperty();
- void MyProperty(int32_t value);
- };
-}
-
-namespace winrt::enginecustom::factory_implementation
-{
- struct Translate : TranslateT
- {
- };
-}
diff --git a/enginecustom/translateshaderclass.cpp b/enginecustom/translateshaderclass.cpp
index 47692f3..8be41d1 100644
--- a/enginecustom/translateshaderclass.cpp
+++ b/enginecustom/translateshaderclass.cpp
@@ -31,14 +31,14 @@ bool TranslateShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
int error;
// Set the filename of the vertex shader.
- error = wcscpy_s(vsFilename, 128, L"../Engine/translate.vs");
+ error = wcscpy_s(vsFilename, 128, L"translate.vs");
if (error != 0)
{
return false;
}
// Set the filename of the pixel shader.
- error = wcscpy_s(psFilename, 128, L"../Engine/translate.ps");
+ error = wcscpy_s(psFilename, 128, L"translate.ps");
if (error != 0)
{
return false;