MAJOR UPDATE - REWORK TEXTURE
-support texture tga retirer +support texture format standard ajouter
This commit is contained in:
parent
c4b4ef83e3
commit
bbbea117c3
@ -1105,7 +1105,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
|
||||
if (!m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(),
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(0),
|
||||
diffuseColor, lightPosition, ambientColor);
|
||||
if (!result)
|
||||
{
|
||||
@ -1116,7 +1116,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
||||
if (m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(),
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(0),
|
||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
||||
if (!result)
|
||||
{
|
||||
@ -1143,7 +1143,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
object->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
if (!m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(),
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(0),
|
||||
diffuseColor, lightPosition, ambientColor);
|
||||
|
||||
if (!result)
|
||||
@ -1155,7 +1155,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
||||
if (m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(),
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(0),
|
||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
||||
if (!result)
|
||||
{
|
||||
@ -1178,7 +1178,13 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
chunk->Render(m_Direct3D->GetDeviceContext());
|
||||
if (!m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture());
|
||||
if (chunk->GetTexture(0) == nullptr)
|
||||
{
|
||||
Logger::Get().Log("Could not render the terrain model using the light shader, texture is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(0));
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@ -1190,7 +1196,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
||||
if (m_enableCelShading) {
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(),
|
||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(0),
|
||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
||||
if (!result)
|
||||
{
|
||||
@ -1578,7 +1584,6 @@ void ApplicationClass::GenerateTerrain()
|
||||
Logger::Get().Log("Generating terrain", __FILE__, __LINE__);
|
||||
|
||||
char modelFilename[128];
|
||||
std::vector<string> Filename;
|
||||
bool result;
|
||||
|
||||
XMMATRIX scaleMatrix;
|
||||
@ -1622,13 +1627,16 @@ void ApplicationClass::GenerateTerrain()
|
||||
return ; // Assurez-vous de retourner false ou de gérer l'erreur de manière appropriée
|
||||
}
|
||||
textures.push_back(texture);
|
||||
|
||||
// log success message
|
||||
Logger::Get().Log("Texture loaded: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
}
|
||||
|
||||
std::filesystem::path p(modelFilename);
|
||||
std::string filenameWithoutExtension = p.stem().string();
|
||||
|
||||
|
||||
|
||||
// for loop to generate terrain chunks for a 10x10 grid
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="alpha01.tga" />
|
||||
<Image Include="C:\Users\Bacon\Downloads\BricksDragfacedRunning008\Bricks2K.png" />
|
||||
<CopyFileToFolders Include="C:\Users\Bacon\Downloads\BricksDragfacedRunning008\Bricks2K.png" />
|
||||
<Image Include="dirt01.tga" />
|
||||
<CopyFileToFolders Include="font01.tga" />
|
||||
<Image Include="KhaoticIcon.ico" />
|
||||
|
@ -370,9 +370,6 @@
|
||||
<Image Include="KhaoticIcon.ico">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="C:\Users\Bacon\Downloads\BricksDragfacedRunning008\Bricks2K.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
@ -559,5 +556,8 @@
|
||||
<CopyFileToFolders Include="celshading.ps">
|
||||
<Filter>shader</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="C:\Users\Bacon\Downloads\BricksDragfacedRunning008\Bricks2K.png">
|
||||
<Filter>Assets</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -19,6 +19,6 @@ Pos=1564,17
|
||||
Size=345,519
|
||||
|
||||
[Window][Shader Manager]
|
||||
Pos=32,253
|
||||
Pos=34,253
|
||||
Size=172,284
|
||||
|
||||
|
@ -167,7 +167,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
for (int count = 0; count < 6; count++)
|
||||
{
|
||||
std::string textureLabel = "Texture##" + std::to_string(index);
|
||||
ID3D11ShaderResourceView* texture = object->GetTexture();
|
||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
||||
if (texture != nullptr)
|
||||
{
|
||||
// Set the cursor position
|
||||
@ -188,7 +188,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
for (int count = 0; count < 6; count++)
|
||||
{
|
||||
std::string textureLabel = "Texture##" + std::to_string(index);
|
||||
ID3D11ShaderResourceView* texture = object->GetTexture();
|
||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
||||
if (texture != nullptr)
|
||||
{
|
||||
// Set the cursor position
|
||||
|
@ -77,9 +77,11 @@ int ModelClass::GetIndexCount()
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* ModelClass::GetTexture(int index)
|
||||
{
|
||||
return m_Textures[index];
|
||||
ID3D11ShaderResourceView* ModelClass::GetTexture(int index) const {
|
||||
if (index >= 0 && index < m_Textures.size()) {
|
||||
return m_Textures[index];
|
||||
}
|
||||
return nullptr; // Retourne nullptr si l'index est hors limites
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
void Render(ID3D11DeviceContext*);
|
||||
|
||||
int GetIndexCount();
|
||||
ID3D11ShaderResourceView* GetTexture(int);
|
||||
ID3D11ShaderResourceView* GetTexture(int index) const;
|
||||
bool ChangeTexture(ID3D11Device*, ID3D11DeviceContext*, std::wstring filename, int index);
|
||||
|
||||
private:
|
||||
|
@ -17,23 +17,7 @@ Object::Object() : ModelClass()
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
if (m_Texture) {
|
||||
m_Texture->Release();
|
||||
m_Texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Object::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::wstring& filename) {
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &m_Texture);
|
||||
if (FAILED(result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* Object::GetTexture() const
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
|
||||
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||
|
@ -54,8 +54,6 @@ public:
|
||||
|
||||
bool LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::wstring& filename);
|
||||
|
||||
ID3D11ShaderResourceView* GetTexture() const;
|
||||
|
||||
public :
|
||||
bool m_demoSpinning = false;
|
||||
XMVECTOR m_previousPosition;
|
||||
@ -74,5 +72,4 @@ private:
|
||||
bool m_isGrounded;
|
||||
|
||||
std::string m_name;
|
||||
ID3D11ShaderResourceView* m_Texture;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user