bug bug bug mais integrer

This commit is contained in:
GolfOcean334 2024-04-04 10:50:37 +02:00
parent 25316d3f4b
commit b5d597b64e
8 changed files with 72 additions and 90 deletions

View File

@ -1,13 +0,0 @@
<Page
x:Class="enginecustom.Translate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:enginecustom"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="Button" Click="ClickHandler">Click Me</Button>
</StackPanel>
</Page>

View File

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

View File

@ -61,6 +61,7 @@ private:
bool UpdateFps();
bool UpdateRenderCountString(int);
bool RenderSceneToTexture(float);
bool RenderTextureTranslation(static float);
private:
D3DClass* m_Direct3D;

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -49,10 +48,6 @@
<ClCompile Include="textureclass.cpp" />
<ClCompile Include="textureshaderclass.cpp" />
<ClCompile Include="Timerclass.cpp" />
<ClCompile Include="translate.cpp">
<DependentUpon>translate.vs</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="translateshaderclass.cpp" />
</ItemGroup>
<ItemGroup>
@ -84,10 +79,6 @@
<ClInclude Include="textureclass.h" />
<ClInclude Include="textureshaderclass.h" />
<ClInclude Include="Timerclass.h" />
<ClInclude Include="translate.h">
<DependentUpon>translate.vs</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="translateshaderclass.h" />
</ItemGroup>
<ItemGroup>
@ -103,7 +94,6 @@
<None Include="Multitexture.vs" />
<None Include="normalmap.ps" />
<None Include="normalmap.vs" />
<None Include="packages.config" />
<None Include="specmap.ps" />
<None Include="specmap.vs" />
<None Include="texture.ps" />
@ -115,7 +105,6 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<FileType>Document</FileType>
</None>
<None Include="Color.vs">
@ -123,7 +112,6 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<FileType>Document</FileType>
</None>
</ItemGroup>
@ -146,23 +134,19 @@
<Text Include="square.txt" />
</ItemGroup>
<ItemGroup>
<Midl Include="translate.ps">
<None Include="translate.ps">
<SubType>Designer</SubType>
</Midl>
<Midl Include="translate.vs">
<FileType>Document</FileType>
</None>
<None Include="translate.vs">
<SubType>Designer</SubType>
</Midl>
</ItemGroup>
<ItemGroup>
<Page Include="Translate.xaml">
<SubType>Designer</SubType>
</Page>
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{92cf56c4-76bb-40d4-8fe5-36c15f5f127a}</ProjectGuid>
<RootNamespace>enginecustom</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -267,14 +251,4 @@
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.220531.1" targetFramework="native" />
</packages>

View File

@ -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();
}
}

View File

@ -1,21 +0,0 @@
#pragma once
#include "Translate.g.h"
namespace winrt::enginecustom::implementation
{
struct Translate : TranslateT<Translate>
{
Translate() = default;
int32_t MyProperty();
void MyProperty(int32_t value);
};
}
namespace winrt::enginecustom::factory_implementation
{
struct Translate : TranslateT<Translate, implementation::Translate>
{
};
}

View File

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