Working DirectX textures
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#define DD_BASERENDERER_H__
|
||||
|
||||
#include "Core/Util/Rectangle.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/Camera.h"
|
||||
#include "Rendering/RenderQueue.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BaseTexture_h__
|
||||
#define BaseTexture_h__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/PNG.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class BaseTexture : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
public:
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -4,9 +4,10 @@
|
||||
#include <string>
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include "Rendering/RawModel.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -21,7 +22,8 @@ private:
|
||||
public:
|
||||
~Model();
|
||||
|
||||
ID3D11Buffer* VertexBuffer;
|
||||
ID3D11Buffer* VertexBuffer = nullptr;
|
||||
ID3D11Buffer* IndexBuffer = nullptr;
|
||||
unsigned int NumVertices;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ using namespace DirectX::SimpleMath;
|
||||
//#pragma comment (lib, "DirectXTK.lib")
|
||||
|
||||
#include "Rendering/BaseRenderer.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -47,6 +46,7 @@ public:
|
||||
ID3D11DeviceContext* m_DeviceContext = nullptr;
|
||||
ID3D11RenderTargetView* m_BackBuffer = nullptr;
|
||||
ID3D11DepthStencilView* m_DepthBuffer = nullptr;
|
||||
ID3D11SamplerState* m_SamplerState = nullptr;
|
||||
|
||||
private:
|
||||
struct ConstantBufferStruct
|
||||
@@ -63,7 +63,8 @@ private:
|
||||
const Model* testModel = nullptr;
|
||||
ID3D11Buffer* constantBuffer = nullptr;
|
||||
|
||||
DirectX::SimpleMath::Matrix GLMtoDX(glm::mat4 m);
|
||||
static DirectX::SimpleMath::Matrix GLMtoDXModelView(glm::mat4 m);
|
||||
static DirectX::SimpleMath::Matrix GLMtoDXProjection(glm::mat4 m);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <d3d11.h>
|
||||
#include <d3dcompiler.h>
|
||||
#pragma comment (lib, "D3DCompiler.lib")
|
||||
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
|
||||
@@ -19,17 +19,16 @@
|
||||
#ifndef Texture_h__
|
||||
#define Texture_h__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdio>
|
||||
#include <d3d11.h>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/PNG.h"
|
||||
#include "Rendering/BaseTexture.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Texture : public Resource
|
||||
class Texture : public BaseTexture
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
@@ -39,11 +38,13 @@ private:
|
||||
public:
|
||||
~Texture();
|
||||
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
};
|
||||
operator ID3D11Texture2D*() { return m_Texture; }
|
||||
|
||||
ID3D11Texture2D* m_Texture = nullptr;
|
||||
ID3D11ShaderResourceView* m_ShaderResourceView = nullptr;
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Texture_h__
|
||||
#endif
|
||||
|
||||
@@ -19,17 +19,12 @@
|
||||
#ifndef Texture_h__
|
||||
#define Texture_h__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/PNG.h"
|
||||
#include "Rendering/BaseTexture.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Texture : public Resource
|
||||
class Texture : public BaseTexture
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
@@ -43,14 +38,10 @@ public:
|
||||
|
||||
operator GLuint() const { return m_Texture; }
|
||||
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
|
||||
private:
|
||||
GLuint m_Texture = 0;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // Texture_h__
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include <forward_list>
|
||||
|
||||
#include "Core/Util/Rectangle.h"
|
||||
#include "Rendering/Texture.h"
|
||||
#include "Rendering/Model.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -52,20 +50,18 @@ protected:
|
||||
|
||||
struct ModelJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID;
|
||||
unsigned int TextureID;
|
||||
unsigned int ShaderID = 0;
|
||||
unsigned int TextureID = 0;
|
||||
|
||||
glm::mat4 ProjectionMatrix;
|
||||
glm::mat4 ViewMatrix;
|
||||
glm::mat4 ModelMatrix;
|
||||
const Texture* DiffuseTexture;
|
||||
const Texture* NormalTexture;
|
||||
const Texture* SpecularTexture;
|
||||
float Shininess;
|
||||
float Shininess = 0.f;
|
||||
glm::vec4 Color;
|
||||
const dd::Model* Model;
|
||||
unsigned int StartIndex;
|
||||
unsigned int EndIndex;
|
||||
const dd::Model* Model = nullptr;
|
||||
unsigned int StartIndex = 0;
|
||||
unsigned int EndIndex = 0;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
@@ -75,15 +71,13 @@ struct ModelJob : RenderJob
|
||||
|
||||
struct SpriteJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID;
|
||||
unsigned int TextureID;
|
||||
unsigned int ShaderID = 0;
|
||||
unsigned int TextureID = 0;
|
||||
|
||||
glm::mat4 ProjectionMatrix;
|
||||
glm::mat4 ViewMatrix;
|
||||
glm::mat4 ModelMatrix;
|
||||
const Texture* DiffuseTexture;
|
||||
const Texture* NormalTexture;
|
||||
const Texture* SpecularTexture;
|
||||
const Texture* DiffuseTexture = nullptr;
|
||||
const Texture* NormalTexture = nullptr;
|
||||
const Texture* SpecularTexture = nullptr;
|
||||
glm::vec4 Color;
|
||||
|
||||
void CalculateHash() override
|
||||
|
||||
Reference in New Issue
Block a user