Fixed OysterGraphics to compile.
New baseline for engine.
This commit is contained in:
parent
9edd98d2b9
commit
c021187db9
|
@ -1,8 +1,9 @@
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
|
||||||
Buffer::Buffer()
|
Oyster::Buffer::Buffer()
|
||||||
{
|
{
|
||||||
mBuffer = NULL;
|
mBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +119,11 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
||||||
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
bufferDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_WRITE;
|
bufferDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_WRITE;
|
||||||
}
|
}
|
||||||
|
else if(mUsage == BUFFER_USAGE_IMMUTABLE)
|
||||||
|
{
|
||||||
|
bufferDesc.Usage = D3D11_USAGE_IMMUTABLE;
|
||||||
|
bufferDesc.CPUAccessFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//Desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
//Desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
bufferDesc.MiscFlags = 0;
|
bufferDesc.MiscFlags = 0;
|
||||||
|
@ -191,7 +197,7 @@ void Buffer::Unmap()
|
||||||
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::operator ID3D11Buffer *()
|
Oyster::Buffer::operator ID3D11Buffer *()
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#ifndef CoreBuffer
|
#ifndef CoreBuffer
|
||||||
#define CoreBuffer
|
#define CoreBuffer
|
||||||
|
|
||||||
#include "Core.h"
|
#include "CoreIncludes.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,8 @@ namespace Oyster
|
||||||
BUFFER_CPU_WRITE,
|
BUFFER_CPU_WRITE,
|
||||||
BUFFER_CPU_WRITE_DISCARD,
|
BUFFER_CPU_WRITE_DISCARD,
|
||||||
BUFFER_CPU_READ,
|
BUFFER_CPU_READ,
|
||||||
BUFFER_USAGE_COUNT
|
BUFFER_USAGE_COUNT,
|
||||||
|
BUFFER_USAGE_IMMUTABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BUFFER_INIT_DESC
|
struct BUFFER_INIT_DESC
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "..\Window\Window.h"
|
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -29,10 +28,10 @@ bool Core::Init(bool SingleThreaded, bool Reference,bool ForceDX11)
|
||||||
if(Reference)
|
if(Reference)
|
||||||
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
||||||
|
|
||||||
/*#if defined(DEBUG) || defined(_DEBUG)
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
Log << "DirectX running in debug mode.\n";
|
Log << "DirectX running in debug mode.\n";
|
||||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
#endif*/
|
#endif
|
||||||
|
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
||||||
|
@ -103,8 +102,14 @@ bool Core::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool
|
||||||
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
||||||
desc.BufferDesc.RefreshRate.Denominator=1;
|
desc.BufferDesc.RefreshRate.Denominator=1;
|
||||||
desc.BufferDesc.RefreshRate.Numerator=60;
|
desc.BufferDesc.RefreshRate.Numerator=60;
|
||||||
desc.BufferDesc.Height = Window::Size.bottom;
|
|
||||||
desc.BufferDesc.Width = Window::Size.left;
|
RECT rc;
|
||||||
|
GetClientRect( Window, &rc );
|
||||||
|
int screenWidth = rc.right - rc.left;
|
||||||
|
int screenHeight = rc.bottom - rc.top;
|
||||||
|
|
||||||
|
desc.BufferDesc.Height = screenHeight;
|
||||||
|
desc.BufferDesc.Width = screenWidth;
|
||||||
|
|
||||||
//Check and Set multiSampling
|
//Check and Set multiSampling
|
||||||
if(MSAA_Quality)
|
if(MSAA_Quality)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "CoreIncludes.h"
|
#include "CoreIncludes.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "Buffer.h"
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Core
|
class Core
|
||||||
|
@ -23,6 +24,90 @@ namespace Oyster
|
||||||
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
||||||
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
||||||
|
|
||||||
|
class ShaderManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct ShaderEffect
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
||||||
|
}Shaders;
|
||||||
|
|
||||||
|
struct IAStage_
|
||||||
|
{
|
||||||
|
ID3D11InputLayout* Layout;
|
||||||
|
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
||||||
|
}IAStage;
|
||||||
|
|
||||||
|
struct RenderStates_
|
||||||
|
{
|
||||||
|
ID3D11DepthStencilState *DepthStencil;
|
||||||
|
ID3D11RasterizerState *Rasterizer;
|
||||||
|
ID3D11SamplerState **SampleState;
|
||||||
|
int SampleCount;
|
||||||
|
ID3D11BlendState *BlendState;
|
||||||
|
}RenderStates;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
std::vector<Oyster::Buffer*> Vertex;
|
||||||
|
std::vector<Oyster::Buffer*> Geometry;
|
||||||
|
std::vector<Oyster::Buffer*> Pixel;
|
||||||
|
}CBuffers;
|
||||||
|
|
||||||
|
ShaderEffect()
|
||||||
|
{
|
||||||
|
RenderStates.BlendState=NULL;
|
||||||
|
RenderStates.DepthStencil=NULL;
|
||||||
|
RenderStates.Rasterizer=NULL;
|
||||||
|
RenderStates.SampleState=NULL;
|
||||||
|
RenderStates.SampleCount=0;
|
||||||
|
Shaders.Compute=-1;
|
||||||
|
Shaders.Domain=-1;
|
||||||
|
Shaders.Geometry=-1;
|
||||||
|
Shaders.Hull=-1;
|
||||||
|
Shaders.Pixel=-1;
|
||||||
|
Shaders.Vertex=-1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
enum ShaderType
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Hull,
|
||||||
|
Domain,
|
||||||
|
Geometry,
|
||||||
|
Pixel,
|
||||||
|
Compute
|
||||||
|
};
|
||||||
|
|
||||||
|
static void SetShaderEffect(ShaderEffect);
|
||||||
|
|
||||||
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
|
|
||||||
|
static bool Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled = true);
|
||||||
|
|
||||||
|
struct Get
|
||||||
|
{
|
||||||
|
static int Pixel(std::wstring Name);
|
||||||
|
static int Vertex(std::wstring Name);
|
||||||
|
static int Geometry(std::wstring Name);
|
||||||
|
static int Compute(std::wstring Name);
|
||||||
|
static int Hull(std::wstring Name);
|
||||||
|
static int Domain(std::wstring Name);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Set
|
||||||
|
{
|
||||||
|
static void Pixel(int Index);
|
||||||
|
static void Vertex(int Index);
|
||||||
|
static void Geometry(int Index);
|
||||||
|
static void Compute(int Index);
|
||||||
|
static void Hull(int Index);
|
||||||
|
static void Domain(int Index);
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
|
|
||||||
#define NOMINMAX // Because I hate Microsoft now. ~Angry Dan.
|
#define NOMINMAX // Because I hate Microsoft now. ~Angry Dan.
|
||||||
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
||||||
#include <WinSock2.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <D3D11.h>
|
#include <D3D11.h>
|
||||||
#include <D3DX11.h>
|
|
||||||
#include <D3DX10math.h>
|
|
||||||
#include <d3dx11effect.h>
|
|
||||||
#include <d3dCompiler.h>
|
#include <d3dCompiler.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "d3d11.lib")
|
||||||
|
#pragma comment(lib, "d3dcompiler.lib")
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -22,19 +22,4 @@
|
||||||
#define SAFE_DELETE_ARRAY(x) if( x ) { delete[](x); (x) = NULL; }
|
#define SAFE_DELETE_ARRAY(x) if( x ) { delete[](x); (x) = NULL; }
|
||||||
#define PI (3.14159265358979323846f)
|
#define PI (3.14159265358979323846f)
|
||||||
|
|
||||||
#pragma comment(lib, "d3d11.lib")
|
|
||||||
#pragma comment(lib, "d3dcompiler.lib")
|
|
||||||
#pragma comment (lib,"dxerr.lib")
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "d3dx11d.lib")
|
|
||||||
#pragma comment(lib, "Effects11D.lib")
|
|
||||||
#pragma comment(lib, "d3dx10d.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "d3dx11.lib")
|
|
||||||
#pragma comment(lib, "Effects11.lib")
|
|
||||||
#pragma comment(lib, "d3dx10.lib")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,351 @@
|
||||||
|
#include "Core.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
const char* ShaderFunction = "ShaderMain";
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct ShaderData
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
char* data;
|
||||||
|
};
|
||||||
|
std::vector<ID3D11PixelShader*> PS;
|
||||||
|
std::map<std::wstring,int> PSMap;
|
||||||
|
|
||||||
|
std::vector<ID3D11GeometryShader*> GS;
|
||||||
|
std::map<std::wstring,int> GSMap;
|
||||||
|
|
||||||
|
std::vector<ID3D11ComputeShader*> CS;
|
||||||
|
std::map<std::wstring,int> CSMap;
|
||||||
|
|
||||||
|
std::vector<ID3D11VertexShader*> VS;
|
||||||
|
std::vector<ShaderData> VData;
|
||||||
|
std::map<std::wstring,int> VSMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Init
|
||||||
|
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
||||||
|
{
|
||||||
|
if(Precompiled)
|
||||||
|
{
|
||||||
|
return LoadPrecompiled(filename, type, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return LoadCompile(filename, type, name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
|
{
|
||||||
|
|
||||||
|
std::ifstream stream;
|
||||||
|
ShaderData sd;
|
||||||
|
|
||||||
|
|
||||||
|
//Create Vertex shader and Layout
|
||||||
|
stream.open(filename, std::ifstream::in | std::ifstream::binary);
|
||||||
|
if(stream.good())
|
||||||
|
{
|
||||||
|
stream.seekg(0, std::ios::end);
|
||||||
|
sd.size = size_t(stream.tellg());
|
||||||
|
sd.data = new char[sd.size];
|
||||||
|
stream.seekg(0, std::ios::beg);
|
||||||
|
stream.read(&sd.data[0], sd.size);
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
|
||||||
|
ID3D11VertexShader* vertex;
|
||||||
|
ID3D11GeometryShader* geometry;
|
||||||
|
ID3D11PixelShader* pixel;
|
||||||
|
ID3D11ComputeShader* compute;
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
|
if(VSMap.count(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(FAILED(Core::Device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back(vertex);
|
||||||
|
VData.push_back(sd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Hull:
|
||||||
|
case Core::ShaderManager::ShaderType::Domain:
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
|
if(GSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::Device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back(geometry);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
|
if(PSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::Device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back(pixel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Compute:
|
||||||
|
|
||||||
|
if(CSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::Device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CSMap[name] = CS.size();
|
||||||
|
CS.push_back(compute);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
|
{
|
||||||
|
/// \todo error reporting
|
||||||
|
ID3D10Blob *Shader,*Error;
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
|
ID3D11PixelShader* pixel;
|
||||||
|
|
||||||
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error)))
|
||||||
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(FAILED(Oyster::Core::Device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||||
|
{
|
||||||
|
Error->Release();
|
||||||
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Shader->Release();
|
||||||
|
if(!PSMap.count(name))
|
||||||
|
{
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back(pixel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PS[PSMap[name]] = pixel;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
|
ID3D11GeometryShader* geometry;
|
||||||
|
|
||||||
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error)))
|
||||||
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(FAILED(Oyster::Core::Device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||||
|
{
|
||||||
|
Error->Release();
|
||||||
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Shader->Release();
|
||||||
|
if(!GSMap.count(name))
|
||||||
|
{
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back(geometry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GS[GSMap[name]] = geometry;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
|
ID3D11VertexShader* vertex;
|
||||||
|
|
||||||
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",0,0,&Shader,&Error)))
|
||||||
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(FAILED(Oyster::Core::Device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||||
|
{
|
||||||
|
Error->Release();
|
||||||
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!VSMap.count(name))
|
||||||
|
{
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back(vertex);
|
||||||
|
ShaderData sd;
|
||||||
|
sd.size = Shader->GetBufferSize();
|
||||||
|
sd.data = new char[sd.size];
|
||||||
|
memcpy(sd.data,Shader->GetBufferPointer(),sd.size);
|
||||||
|
VData.push_back(sd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VS[VSMap[name]] = vertex;
|
||||||
|
delete[] VData[VSMap[name]].data;
|
||||||
|
VData[VSMap[name]].size = Shader->GetBufferSize();
|
||||||
|
VData[VSMap[name]].data = new char[VData[VSMap[name]].size];
|
||||||
|
memcpy(VData[VSMap[name]].data,Shader->GetBufferPointer(),VData[VSMap[name]].size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Shader->Release();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||||
|
{
|
||||||
|
if(VertexIndex==-1)
|
||||||
|
{
|
||||||
|
Layout=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Get
|
||||||
|
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(PSMap.count(Name))
|
||||||
|
return PSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(VSMap.count(Name))
|
||||||
|
return VSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(GSMap.count(Name))
|
||||||
|
return GSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(CSMap.count(Name))
|
||||||
|
return CSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Set
|
||||||
|
/// \todo smart set
|
||||||
|
void Core::ShaderManager::Set::Pixel(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
DeviceContext->PSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
DeviceContext->PSSetShader( PS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Vertex(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
DeviceContext->VSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
DeviceContext->VSSetShader( VS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Geometry(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
DeviceContext->GSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
DeviceContext->GSSetShader( GS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Compute(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
DeviceContext->CSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
DeviceContext->CSSetShader( CS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
/// \todo set Hull
|
||||||
|
void Core::ShaderManager::Set::Hull(int Index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/// \todo set Domain
|
||||||
|
void Core::ShaderManager::Set::Domain(int Index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
/// \todo smart Set ie. not resetting the shader
|
||||||
|
/// \todo research states
|
||||||
|
/// \todo smart buffer set
|
||||||
|
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
||||||
|
{
|
||||||
|
Set::Pixel(se.Shaders.Pixel);
|
||||||
|
Set::Vertex(se.Shaders.Vertex);
|
||||||
|
Set::Geometry(se.Shaders.Geometry);
|
||||||
|
Set::Compute(se.Shaders.Compute);
|
||||||
|
Oyster::Core::DeviceContext->IASetInputLayout(se.IAStage.Layout);
|
||||||
|
Oyster::Core::DeviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
||||||
|
se.CBuffers.Vertex[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
||||||
|
se.CBuffers.Geometry[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
||||||
|
se.CBuffers.Pixel[i]->Apply(i);
|
||||||
|
Oyster::Core::DeviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||||
|
Oyster::Core::DeviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||||
|
float test[4] = {0};
|
||||||
|
Oyster::Core::DeviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ public:
|
||||||
DXGI_SAMPLE_DESC sampleDesc;
|
DXGI_SAMPLE_DESC sampleDesc;
|
||||||
D3D11_VIEWPORT viewPort;
|
D3D11_VIEWPORT viewPort;
|
||||||
oysterPrivates():instance(false),swapChained(false),depth(NULL),rtv(NULL), depthTexture(NULL){};
|
oysterPrivates():instance(false),swapChained(false),depth(NULL),rtv(NULL), depthTexture(NULL){};
|
||||||
|
int sizeX, sizeY;
|
||||||
class State
|
class State
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -55,13 +56,11 @@ bool Oyster::Engine::Init::HasSwapChain()
|
||||||
|
|
||||||
bool Oyster::Engine::Init::CreateSwapChain(HWND Window,int NrofBuffers,bool MSAA_Quality,bool Fullscreen)
|
bool Oyster::Engine::Init::CreateSwapChain(HWND Window,int NrofBuffers,bool MSAA_Quality,bool Fullscreen)
|
||||||
{
|
{
|
||||||
if(Window==0)
|
RECT rc;
|
||||||
{
|
GetClientRect( Window, &rc );
|
||||||
if(Oyster::Window::Handle==0)
|
instance.sizeX = rc.right - rc.left;
|
||||||
return false;
|
instance.sizeY = rc.bottom - rc.top;
|
||||||
else
|
|
||||||
Window = Oyster::Window::Handle;
|
|
||||||
}
|
|
||||||
if(!instance.swapChained)
|
if(!instance.swapChained)
|
||||||
{
|
{
|
||||||
if(Oyster::Core::CreateSwapChain(Window,NrofBuffers,MSAA_Quality,Fullscreen))
|
if(Oyster::Core::CreateSwapChain(Window,NrofBuffers,MSAA_Quality,Fullscreen))
|
||||||
|
@ -71,11 +70,6 @@ bool Oyster::Engine::Init::CreateSwapChain(HWND Window,int NrofBuffers,bool MSAA
|
||||||
return instance.swapChained;
|
return instance.swapChained;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Oyster::Engine::Init::InitializeWindow(const LPCSTR appName, const LPCSTR className,const HINSTANCE &hInstance, const int &nCmdShow, WNDPROC wProc, bool handleLoop )
|
|
||||||
{
|
|
||||||
return Oyster::Window::init(appName,className,hInstance,nCmdShow,wProc,handleLoop);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Oyster::Engine::Init::FullInit(const Setup& setup)
|
bool Oyster::Engine::Init::FullInit(const Setup& setup)
|
||||||
{
|
{
|
||||||
if(!Oyster::Engine::Init::Instance(setup.Common.SingleThreaded,setup.Common.Reference,setup.Common.ForceDX11))
|
if(!Oyster::Engine::Init::Instance(setup.Common.SingleThreaded,setup.Common.Reference,setup.Common.ForceDX11))
|
||||||
|
@ -104,7 +98,7 @@ bool Oyster::Engine::Init::FullInit(const Setup& setup)
|
||||||
|
|
||||||
Oyster::Resources::Buffers::Init();
|
Oyster::Resources::Buffers::Init();
|
||||||
Oyster::Resources::ShaderEffects::Init();
|
Oyster::Resources::ShaderEffects::Init();
|
||||||
Oyster::Resources::PipeLineResourses::Init();
|
Oyster::Resources::PipeLineResourses::Init(instance.sizeX, instance.sizeY);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -186,7 +180,7 @@ void Oyster::Engine::Render::Geometry(const Oyster::Render::Model* models,int co
|
||||||
if(cBufferEveryObject)
|
if(cBufferEveryObject)
|
||||||
{
|
{
|
||||||
void* data = cBufferEveryObject->Map();
|
void* data = cBufferEveryObject->Map();
|
||||||
memcpy(data,&(models[i].World->getTranspose()),64);
|
memcpy(data,&(models[i].World->GetTranspose()),64);
|
||||||
cBufferEveryObject->Unmap();
|
cBufferEveryObject->Unmap();
|
||||||
}
|
}
|
||||||
Oyster::Core::DeviceContext->PSSetShaderResources(0,models[i].info->Material.size(),&(models[i].info->Material[0]));
|
Oyster::Core::DeviceContext->PSSetShaderResources(0,models[i].info->Material.size(),&(models[i].info->Material[0]));
|
||||||
|
@ -205,23 +199,23 @@ void Oyster::Engine::Render::Geometry(const Oyster::Render::Model* models,int co
|
||||||
|
|
||||||
void Oyster::Engine::Render::Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos)
|
void Oyster::Engine::Render::Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos)
|
||||||
{
|
{
|
||||||
Pos.x -= Oyster::Window::Size.left/2;
|
Pos.x -= instance.sizeX/2;
|
||||||
Pos.x += size.x;
|
Pos.x += size.x;
|
||||||
|
|
||||||
Pos.y -= Oyster::Window::Size.bottom/2;
|
Pos.y -= instance.sizeY/2;
|
||||||
Pos.y += size.y;
|
Pos.y += size.y;
|
||||||
|
|
||||||
Matrix m;
|
Matrix m;
|
||||||
Math::identityMatrix(m);
|
m = Math::Matrix::identity;
|
||||||
float width = (1.0f/(Window::Size.left/2.0f));
|
float width = (1.0f/(instance.sizeX/2.0f));
|
||||||
float height = (1.0f/(Window::Size.bottom/2.0f));
|
float height = (1.0f/(instance.sizeY/2.0f));
|
||||||
m.m41=Pos.x * width;
|
m.m41=Pos.x * width;
|
||||||
m.m42=-Pos.y * height;
|
m.m42=-Pos.y * height;
|
||||||
m.m43=Pos.z;
|
m.m43=Pos.z;
|
||||||
m.m11=width*size.x;
|
m.m11=width*size.x;
|
||||||
m.m22=height*size.y;
|
m.m22=height*size.y;
|
||||||
void* dest = Resources::Buffers::CBufferGs.Map();
|
void* dest = Resources::Buffers::CBufferGs.Map();
|
||||||
memcpy(dest,&m.getTranspose(),64);
|
memcpy(dest,&m.GetTranspose(),64);
|
||||||
Resources::Buffers::CBufferGs.Unmap();
|
Resources::Buffers::CBufferGs.Unmap();
|
||||||
Oyster::Render::Textbox::Update(text, size.x);
|
Oyster::Render::Textbox::Update(text, size.x);
|
||||||
Oyster::Engine::PrepareForRendering::Begin2DTextRender();
|
Oyster::Engine::PrepareForRendering::Begin2DTextRender();
|
||||||
|
@ -236,11 +230,11 @@ void Oyster::Engine::Render::ScreenQuad(ID3D11ShaderResourceView* srv, float ZPo
|
||||||
Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&srv);
|
Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&srv);
|
||||||
|
|
||||||
Matrix m;
|
Matrix m;
|
||||||
Math::identityMatrix(m);
|
m = Math::Matrix::identity;
|
||||||
m.m43=ZPos;
|
m.m43=ZPos;
|
||||||
|
|
||||||
void* dest = Resources::Buffers::CBufferGs.Map();
|
void* dest = Resources::Buffers::CBufferGs.Map();
|
||||||
memcpy(dest,&m.getTranspose(),64);
|
memcpy(dest,&m.GetTranspose(),64);
|
||||||
Resources::Buffers::CBufferGs.Unmap();
|
Resources::Buffers::CBufferGs.Unmap();
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->Draw(1,0);
|
Oyster::Core::DeviceContext->Draw(1,0);
|
||||||
|
@ -251,16 +245,16 @@ void Oyster::Engine::Render::Sprite(ID3D11ShaderResourceView* srv, Oyster::Math:
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&srv);
|
Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&srv);
|
||||||
|
|
||||||
Pos.x -= Oyster::Window::Size.left/2;
|
Pos.x -= instance.sizeX/2;
|
||||||
Pos.x += size.x/2;
|
Pos.x += size.x/2;
|
||||||
|
|
||||||
Pos.y -= Oyster::Window::Size.bottom/2;
|
Pos.y -= instance.sizeY/2;
|
||||||
Pos.y += size.y/2;
|
Pos.y += size.y/2;
|
||||||
|
|
||||||
Matrix m;
|
Matrix m;
|
||||||
Math::identityMatrix(m);
|
m = Math::Matrix::identity;
|
||||||
float width = (1.0f/(Window::Size.left/2.0f));
|
float width = (1.0f/(instance.sizeX/2.0f));
|
||||||
float height = (1.0f/(Window::Size.bottom/2.0f));
|
float height = (1.0f/(instance.sizeY/2.0f));
|
||||||
m.m41=Pos.x * width;
|
m.m41=Pos.x * width;
|
||||||
m.m42=-Pos.y * height;
|
m.m42=-Pos.y * height;
|
||||||
m.m43=Pos.z;
|
m.m43=Pos.z;
|
||||||
|
@ -268,7 +262,7 @@ void Oyster::Engine::Render::Sprite(ID3D11ShaderResourceView* srv, Oyster::Math:
|
||||||
m.m22=height*size.y/2;
|
m.m22=height*size.y/2;
|
||||||
|
|
||||||
void* dest = Resources::Buffers::CBufferGs.Map();
|
void* dest = Resources::Buffers::CBufferGs.Map();
|
||||||
memcpy(dest,&m.getTranspose(),64);
|
memcpy(dest,&m.GetTranspose(),64);
|
||||||
Resources::Buffers::CBufferGs.Unmap();
|
Resources::Buffers::CBufferGs.Unmap();
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->Draw(1,0);
|
Oyster::Core::DeviceContext->Draw(1,0);
|
||||||
|
@ -286,8 +280,8 @@ bool CreateDepthStencil(bool MSAA_Quality)
|
||||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
desc.CPUAccessFlags=0;
|
desc.CPUAccessFlags=0;
|
||||||
desc.MiscFlags=0;
|
desc.MiscFlags=0;
|
||||||
desc.Height = Oyster::Window::Size.bottom;
|
desc.Height = instance.sizeY;
|
||||||
desc.Width = Oyster::Window::Size.left;
|
desc.Width = instance.sizeX;
|
||||||
|
|
||||||
|
|
||||||
//Check and Set multiSampling
|
//Check and Set multiSampling
|
||||||
|
@ -355,8 +349,8 @@ void SetViewPort()
|
||||||
{
|
{
|
||||||
instance.viewPort.TopLeftX = 0.0f;
|
instance.viewPort.TopLeftX = 0.0f;
|
||||||
instance.viewPort.TopLeftY = 0.0f;
|
instance.viewPort.TopLeftY = 0.0f;
|
||||||
instance.viewPort.Width = (float)Oyster::Window::Size.left;
|
instance.viewPort.Width = (float)instance.sizeX;
|
||||||
instance.viewPort.Height = (float)Oyster::Window::Size.bottom;
|
instance.viewPort.Height = (float)instance.sizeY;
|
||||||
instance.viewPort.MinDepth = 0.0f;
|
instance.viewPort.MinDepth = 0.0f;
|
||||||
instance.viewPort.MaxDepth = 1.0f;
|
instance.viewPort.MaxDepth = 1.0f;
|
||||||
|
|
||||||
|
@ -373,7 +367,7 @@ void Blur(int target)
|
||||||
|
|
||||||
//dispatch blurr horizontal
|
//dispatch blurr horizontal
|
||||||
Oyster::Shader::Set::SetCompute(Oyster::Shader::Get::GetCompute("BlurHorizontal"));
|
Oyster::Shader::Set::SetCompute(Oyster::Shader::Get::GetCompute("BlurHorizontal"));
|
||||||
Oyster::Core::DeviceContext->Dispatch(7,Oyster::Window::Size.bottom,1);
|
Oyster::Core::DeviceContext->Dispatch(7,instance.sizeX,1);
|
||||||
|
|
||||||
//clean Pipeline
|
//clean Pipeline
|
||||||
Oyster::Core::DeviceContext->CSSetShaderResources(0,16,&Oyster::Resources::PipeLineResourses::SrvNulls[0]);
|
Oyster::Core::DeviceContext->CSSetShaderResources(0,16,&Oyster::Resources::PipeLineResourses::SrvNulls[0]);
|
||||||
|
@ -385,7 +379,7 @@ void Blur(int target)
|
||||||
|
|
||||||
//dispatch blurr vertical
|
//dispatch blurr vertical
|
||||||
Oyster::Shader::Set::SetCompute(Oyster::Shader::Get::GetCompute("BlurVertical"));
|
Oyster::Shader::Set::SetCompute(Oyster::Shader::Get::GetCompute("BlurVertical"));
|
||||||
Oyster::Core::DeviceContext->Dispatch(Oyster::Window::Size.left,5,1);
|
Oyster::Core::DeviceContext->Dispatch(instance.sizeY,5,1);
|
||||||
|
|
||||||
//clean Pipeline
|
//clean Pipeline
|
||||||
Oyster::Core::DeviceContext->CSSetShaderResources(0,16,&Oyster::Resources::PipeLineResourses::SrvNulls[0]);
|
Oyster::Core::DeviceContext->CSSetShaderResources(0,16,&Oyster::Resources::PipeLineResourses::SrvNulls[0]);
|
||||||
|
@ -419,24 +413,24 @@ void Oyster::Engine::Pipeline::Deffered_Lightning::NewFrame(const Float4& col, c
|
||||||
Matrix V = Oyster::Math::Float4x4(View);
|
Matrix V = Oyster::Math::Float4x4(View);
|
||||||
Matrix VP = V*P;
|
Matrix VP = V*P;
|
||||||
|
|
||||||
Oyster::Resources::PipeLineResourses::LightData.projectionMatrix = P.getTranspose();
|
Oyster::Resources::PipeLineResourses::LightData.projectionMatrix = P.GetTranspose();
|
||||||
Oyster::Resources::PipeLineResourses::LightData.viewMatrix = V;
|
Oyster::Resources::PipeLineResourses::LightData.viewMatrix = V;
|
||||||
|
|
||||||
Oyster::Collision::Frustrum( VP ).split(Oyster::Resources::PipeLineResourses::SubFrustrums, Oyster::Resources::PipeLineResourses::FrustrumDimensions.x, Oyster::Resources::PipeLineResourses::FrustrumDimensions.y, Oyster::Resources::PipeLineResourses::FrustrumDimensions.z );
|
Oyster::Collision3D::Frustrum( VP ).Split(Oyster::Resources::PipeLineResourses::SubFrustrums, Oyster::Resources::PipeLineResourses::FrustrumDimensions.x, Oyster::Resources::PipeLineResourses::FrustrumDimensions.y, Oyster::Resources::PipeLineResourses::FrustrumDimensions.z );
|
||||||
|
|
||||||
void* dest = Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[0]->Map();
|
void* dest = Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[0]->Map();
|
||||||
memcpy(dest,&VP.getTranspose(),64);
|
memcpy(dest,&VP.GetTranspose(),64);
|
||||||
Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[0]->Unmap();
|
Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[0]->Unmap();
|
||||||
|
|
||||||
dest= Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[1]->Map();
|
dest= Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[1]->Map();
|
||||||
memcpy(dest,&V.getTranspose(),64);
|
memcpy(dest,&V.GetTranspose(),64);
|
||||||
Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[1]->Unmap();
|
Oyster::Resources::ShaderEffects::ModelEffect.CBuffers.Vertex[1]->Unmap();
|
||||||
|
|
||||||
dest = Oyster::Resources::PipeLineResourses::Resources[0]->Map();
|
dest = Oyster::Resources::PipeLineResourses::Resources[0]->Map();
|
||||||
unsigned int bytes=0;
|
unsigned int bytes=0;
|
||||||
for(int i=0;i<Oyster::Resources::PipeLineResourses::FrustrumSize;++i)
|
for(int i=0;i<Oyster::Resources::PipeLineResourses::FrustrumSize;++i)
|
||||||
{
|
{
|
||||||
Oyster::Resources::PipeLineResourses::SubFrustrums[i].writeToByte( (unsigned char*)dest,bytes);
|
Oyster::Resources::PipeLineResourses::SubFrustrums[i].WriteToByte( (unsigned char*)dest,bytes);
|
||||||
}
|
}
|
||||||
Oyster::Resources::PipeLineResourses::Resources[0]->Unmap();
|
Oyster::Resources::PipeLineResourses::Resources[0]->Unmap();
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,14 @@
|
||||||
#include "Shader\Shader.h"
|
#include "Shader\Shader.h"
|
||||||
|
|
||||||
// Math
|
// Math
|
||||||
#include "Math\OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
// FileLoader
|
|
||||||
#include "FileLoader\ObjReader.h"
|
|
||||||
|
|
||||||
// Windows
|
|
||||||
#include "Window\Window.h"
|
|
||||||
|
|
||||||
// Input
|
|
||||||
#include "Input\InputController.h"
|
|
||||||
|
|
||||||
// Collision
|
// Collision
|
||||||
#include "Collision\Collision.h"
|
#include "Collision\Frustrum.h"
|
||||||
|
|
||||||
// Game Definitions
|
|
||||||
#include "Game\OysterGame.h"
|
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
#include "Resourses\ShaderEffects.h"
|
#include "Resourses\ShaderEffects.h"
|
||||||
|
|
|
@ -140,16 +140,14 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Core\Buffer.cpp" />
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
<ClCompile Include="Core\Core.cpp" />
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
<ClCompile Include="Engine.cpp" />
|
<ClCompile Include="Engine.cpp" />
|
||||||
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
|
||||||
<ClCompile Include="Render\Camera.cpp" />
|
|
||||||
<ClCompile Include="Render\Model.cpp" />
|
<ClCompile Include="Render\Model.cpp" />
|
||||||
<ClCompile Include="Render\TextBox.cpp" />
|
<ClCompile Include="Render\TextBox.cpp" />
|
||||||
<ClCompile Include="Resourses\Buffers.cpp" />
|
<ClCompile Include="Resourses\Buffers.cpp" />
|
||||||
<ClCompile Include="Resourses\Manager.cpp" />
|
<ClCompile Include="Resourses\Manager.cpp" />
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
||||||
<ClCompile Include="Shader\Shader.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h" />
|
<ClInclude Include="Core\Buffer.h" />
|
||||||
|
@ -158,7 +156,6 @@
|
||||||
<ClInclude Include="Engine.h" />
|
<ClInclude Include="Engine.h" />
|
||||||
<ClInclude Include="EngineIncludes.h" />
|
<ClInclude Include="EngineIncludes.h" />
|
||||||
<ClInclude Include="FileLoader\ObjReader.h" />
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
<ClInclude Include="Render\Camera.h" />
|
|
||||||
<ClInclude Include="Render\Lights.h" />
|
<ClInclude Include="Render\Lights.h" />
|
||||||
<ClInclude Include="Render\Model.h" />
|
<ClInclude Include="Render\Model.h" />
|
||||||
<ClInclude Include="Render\ModelInfo.h" />
|
<ClInclude Include="Render\ModelInfo.h" />
|
||||||
|
@ -168,7 +165,6 @@
|
||||||
<ClInclude Include="Resourses\Manager.h" />
|
<ClInclude Include="Resourses\Manager.h" />
|
||||||
<ClInclude Include="Resourses\PipelineResources.h" />
|
<ClInclude Include="Resourses\PipelineResources.h" />
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h" />
|
<ClInclude Include="Resourses\ShaderEffects.h" />
|
||||||
<ClInclude Include="Shader\Shader.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="Shader\HLSL\2D.hlsl">
|
<FxCompile Include="Shader\HLSL\2D.hlsl">
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
<ClCompile Include="Core\Core.cpp">
|
<ClCompile Include="Core\Core.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="FileLoader\ObjReader.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\Camera.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\Model.cpp">
|
<ClCompile Include="Render\Model.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -45,10 +39,10 @@
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp">
|
<ClCompile Include="Resourses\ShaderEffects.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Shader\Shader.cpp">
|
<ClCompile Include="Engine.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Engine.cpp">
|
<ClCompile Include="Core\ShaderManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -62,12 +56,6 @@
|
||||||
<ClInclude Include="Core\CoreIncludes.h">
|
<ClInclude Include="Core\CoreIncludes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FileLoader\ObjReader.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\Camera.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\Lights.h">
|
<ClInclude Include="Render\Lights.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -95,15 +83,15 @@
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h">
|
<ClInclude Include="Resourses\ShaderEffects.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Shader\Shader.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Engine.h">
|
<ClInclude Include="Engine.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="EngineIncludes.h">
|
<ClInclude Include="EngineIncludes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="Shader\HLSL\2D.hlsl" />
|
<FxCompile Include="Shader\HLSL\2D.hlsl" />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "..\Math\OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,12 +19,14 @@ bool Textbox::Init()
|
||||||
return true;
|
return true;
|
||||||
//return true;
|
//return true;
|
||||||
}
|
}
|
||||||
|
/// \todo proper reading of texture
|
||||||
bool Textbox::SetTexture(const char* _file)
|
bool Textbox::SetTexture(const char* _file)
|
||||||
{
|
{
|
||||||
if(FAILED(D3DX11CreateShaderResourceViewFromFileA(Oyster::Core::Device, _file, NULL, NULL, &Texture, NULL)))
|
return false;
|
||||||
|
/*if(FAILED(D3DX11CreateShaderResourceViewFromFileA(Oyster::Core::Device, _file, NULL, NULL, &Texture, NULL)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Textbox::UpdateTextField(std::string _str)
|
bool Textbox::UpdateTextField(std::string _str)
|
||||||
|
|
|
@ -4,44 +4,44 @@ std::unordered_map< std::string, Oyster::Render::ModelInfo*> Oyster::Resources::
|
||||||
|
|
||||||
Oyster::Render::Model* Oyster::Resources::Manager::LoadModel(std::string Filename, Matrix Scale)
|
Oyster::Render::Model* Oyster::Resources::Manager::LoadModel(std::string Filename, Matrix Scale)
|
||||||
{
|
{
|
||||||
//TODO: Add redundncy sheck, to ensure not recreating model
|
////TODO: Add redundncy sheck, to ensure not recreating model
|
||||||
|
|
||||||
//Loop to find filename
|
////Loop to find filename
|
||||||
|
|
||||||
//If found Return Model
|
////If found Return Model
|
||||||
|
|
||||||
//else Create Model
|
////else Create Model
|
||||||
|
|
||||||
Oyster::FileLoaders::ObjReader *reader = Oyster::FileLoaders::ObjReader::LoadFile(Filename, Scale);
|
//Oyster::FileLoaders::ObjReader *reader = Oyster::FileLoaders::ObjReader::LoadFile(Filename, Scale);
|
||||||
Oyster::FileLoaders::ObjReader::Vertex** vertex = new Oyster::FileLoaders::ObjReader::Vertex*[1];
|
//Oyster::FileLoaders::ObjReader::Vertex** vertex = new Oyster::FileLoaders::ObjReader::Vertex*[1];
|
||||||
int vcount;
|
//int vcount;
|
||||||
std::map<std::string,ID3D11ShaderResourceView *> textures;
|
//std::map<std::string,ID3D11ShaderResourceView *> textures;
|
||||||
reader->GetVertexData( vertex, vcount, textures );
|
//reader->GetVertexData( vertex, vcount, textures );
|
||||||
|
|
||||||
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
//Oyster::Buffer::BUFFER_INIT_DESC desc;
|
||||||
desc.ElementSize=sizeof(Oyster::FileLoaders::ObjReader::Vertex);
|
//desc.ElementSize=sizeof(Oyster::FileLoaders::ObjReader::Vertex);
|
||||||
desc.NumElements = vcount;
|
//desc.NumElements = vcount;
|
||||||
desc.InitData = *vertex;
|
//desc.InitData = *vertex;
|
||||||
desc.Type = Oyster::Buffer::VERTEX_BUFFER;
|
//desc.Type = Oyster::Buffer::VERTEX_BUFFER;
|
||||||
desc.Usage = Oyster::Buffer::BUFFER_DEFAULT;
|
//desc.Usage = Oyster::Buffer::BUFFER_DEFAULT;
|
||||||
|
//
|
||||||
|
//ID3D11ShaderResourceView *srv = textures["Diffuse"];
|
||||||
|
|
||||||
ID3D11ShaderResourceView *srv = textures["Diffuse"];
|
//Oyster::Render::ModelInfo* m = new Oyster::Render::ModelInfo();
|
||||||
|
//
|
||||||
Oyster::Render::ModelInfo* m = new Oyster::Render::ModelInfo();
|
//m->Vertices = *(Oyster::Engine::Init::Buffers::CreateBuffer(desc));
|
||||||
|
//m->VertexCount = vcount;
|
||||||
m->Vertices = *(Oyster::Engine::Init::Buffers::CreateBuffer(desc));
|
//m->Material.push_back(srv);
|
||||||
m->VertexCount = vcount;
|
//srv = textures["Specular"];
|
||||||
m->Material.push_back(srv);
|
//m->Material.push_back(srv);
|
||||||
srv = textures["Specular"];
|
//srv = textures["Glow"];
|
||||||
m->Material.push_back(srv);
|
//m->Material.push_back(srv);
|
||||||
srv = textures["Glow"];
|
//m->Indexed=false;
|
||||||
m->Material.push_back(srv);
|
//
|
||||||
m->Indexed=false;
|
//Oyster::Render::Model* model = new Oyster::Render::Model();
|
||||||
|
//model->info=m;
|
||||||
Oyster::Render::Model* model = new Oyster::Render::Model();
|
//model->Visible = true;
|
||||||
model->info=m;
|
//model->World = &Oyster::Math::Float4x4(Oyster::Math::Float4x4::identity);
|
||||||
model->Visible = true;
|
return NULL;
|
||||||
model->World = &Oyster::Math::Float4x4(Oyster::Math::Float4x4::identity);
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,29 +18,29 @@ ID3D11RenderTargetView* PipeLineResourses::RtvNulls[16] = {0};
|
||||||
ID3D11ShaderResourceView* PipeLineResourses::SrvNulls[16] = {0};
|
ID3D11ShaderResourceView* PipeLineResourses::SrvNulls[16] = {0};
|
||||||
ID3D11UnorderedAccessView* PipeLineResourses::uavNULL[16] = {0};
|
ID3D11UnorderedAccessView* PipeLineResourses::uavNULL[16] = {0};
|
||||||
|
|
||||||
Oyster::Collision::Frustrum* PipeLineResourses::SubFrustrums = 0;
|
Oyster::Collision3D::Frustrum* PipeLineResourses::SubFrustrums = 0;
|
||||||
int PipeLineResourses::FrustrumSize = 0;
|
int PipeLineResourses::FrustrumSize = 0;
|
||||||
LinearAlgebra::Vector3<unsigned int> PipeLineResourses::FrustrumDimensions = LinearAlgebra::Vector3<unsigned int>();
|
LinearAlgebra::Vector3<unsigned int> PipeLineResourses::FrustrumDimensions = LinearAlgebra::Vector3<unsigned int>();
|
||||||
|
|
||||||
Oyster::Resources::BufferDefinitions::LightStructureBuffer PipeLineResourses::LightData = Oyster::Resources::BufferDefinitions::LightStructureBuffer();
|
Oyster::Resources::BufferDefinitions::LightStructureBuffer PipeLineResourses::LightData = Oyster::Resources::BufferDefinitions::LightStructureBuffer();
|
||||||
|
|
||||||
void PipeLineResourses::Init()
|
void PipeLineResourses::Init(int sizeX, int sizeY)
|
||||||
{
|
{
|
||||||
InitGeometry();
|
InitGeometry(sizeX, sizeY);
|
||||||
|
|
||||||
InitSSAOData();
|
InitSSAOData();
|
||||||
InitSubFrustrums();
|
InitSubFrustrums(sizeX, sizeY);
|
||||||
InitPointLights();
|
InitPointLights();
|
||||||
InitLightData();
|
InitLightData();
|
||||||
|
|
||||||
InitLighting();
|
InitLighting(sizeX, sizeY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipeLineResourses::InitGeometry()
|
void PipeLineResourses::InitGeometry(int sizeX, int sizeY)
|
||||||
{
|
{
|
||||||
D3D11_TEXTURE2D_DESC Tdesc;
|
D3D11_TEXTURE2D_DESC Tdesc;
|
||||||
Tdesc.Width = Oyster::Window::Size.left;
|
Tdesc.Width = sizeX;
|
||||||
Tdesc.Height = Oyster::Window::Size.bottom;
|
Tdesc.Height = sizeY;
|
||||||
Tdesc.MipLevels = Tdesc.ArraySize = 1;
|
Tdesc.MipLevels = Tdesc.ArraySize = 1;
|
||||||
Tdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
Tdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
Tdesc.SampleDesc.Count = 1;
|
Tdesc.SampleDesc.Count = 1;
|
||||||
|
@ -86,7 +86,7 @@ void PipeLineResourses::InitSSAOData()
|
||||||
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
||||||
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
|
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
|
||||||
}
|
}
|
||||||
kernel[i].normalize();
|
kernel[i].Normalize();
|
||||||
|
|
||||||
float scale = float(i) / float(NrOfSamples);
|
float scale = float(i) / float(NrOfSamples);
|
||||||
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
|
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
|
||||||
|
@ -102,7 +102,7 @@ void PipeLineResourses::InitSSAOData()
|
||||||
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
|
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
|
||||||
0.0f);
|
0.0f);
|
||||||
}
|
}
|
||||||
random[i].normalize();
|
random[i].Normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,15 +137,15 @@ void PipeLineResourses::InitSSAOData()
|
||||||
delete[] random;
|
delete[] random;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipeLineResourses::InitSubFrustrums()
|
void PipeLineResourses::InitSubFrustrums(int sizeX, int sizeY)
|
||||||
{
|
{
|
||||||
FrustrumDimensions.x = (::Oyster::Window::Size.left + 15U) / 16U;
|
FrustrumDimensions.x = (sizeX + 15U) / 16U;
|
||||||
FrustrumDimensions.y = (::Oyster::Window::Size.bottom + 15U) / 16U;
|
FrustrumDimensions.y = (sizeY + 15U) / 16U;
|
||||||
FrustrumDimensions.z = 1;
|
FrustrumDimensions.z = 1;
|
||||||
FrustrumSize = FrustrumDimensions.x * FrustrumDimensions.y * FrustrumDimensions.z;
|
FrustrumSize = FrustrumDimensions.x * FrustrumDimensions.y * FrustrumDimensions.z;
|
||||||
if(SubFrustrums!=0)
|
if(SubFrustrums!=0)
|
||||||
delete[] SubFrustrums;
|
delete[] SubFrustrums;
|
||||||
SubFrustrums = new Frustrum[ FrustrumSize ];
|
SubFrustrums = new Collision3D::Frustrum[ FrustrumSize ];
|
||||||
|
|
||||||
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
||||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||||
|
@ -197,11 +197,11 @@ void PipeLineResourses::InitLightData()
|
||||||
LightData.numDispatches = FrustrumDimensions;
|
LightData.numDispatches = FrustrumDimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipeLineResourses::InitLighting()
|
void PipeLineResourses::InitLighting(int sizeX, int sizeY)
|
||||||
{
|
{
|
||||||
D3D11_TEXTURE2D_DESC Tdesc;
|
D3D11_TEXTURE2D_DESC Tdesc;
|
||||||
Tdesc.Width = Oyster::Window::Size.left;
|
Tdesc.Width = sizeX;
|
||||||
Tdesc.Height = Oyster::Window::Size.bottom;
|
Tdesc.Height = sizeY;
|
||||||
Tdesc.MipLevels = Tdesc.ArraySize = 1;
|
Tdesc.MipLevels = Tdesc.ArraySize = 1;
|
||||||
Tdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
Tdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
Tdesc.SampleDesc.Count = 1;
|
Tdesc.SampleDesc.Count = 1;
|
||||||
|
|
|
@ -43,22 +43,22 @@ namespace Oyster
|
||||||
static ID3D11ShaderResourceView* SrvNulls[16];
|
static ID3D11ShaderResourceView* SrvNulls[16];
|
||||||
static ID3D11UnorderedAccessView* uavNULL[16];
|
static ID3D11UnorderedAccessView* uavNULL[16];
|
||||||
|
|
||||||
static Oyster::Collision::Frustrum* SubFrustrums;
|
static Oyster::Collision3D::Frustrum* SubFrustrums;
|
||||||
static int FrustrumSize;
|
static int FrustrumSize;
|
||||||
static LinearAlgebra::Vector3<unsigned int> FrustrumDimensions;
|
static LinearAlgebra::Vector3<unsigned int> FrustrumDimensions;
|
||||||
|
|
||||||
static Oyster::Resources::BufferDefinitions::LightStructureBuffer LightData;
|
static Oyster::Resources::BufferDefinitions::LightStructureBuffer LightData;
|
||||||
|
|
||||||
static void Init();
|
static void Init(int sizeX, int sizeY);
|
||||||
|
|
||||||
static void InitGeometry();
|
static void InitGeometry(int sizeX, int sizeY);
|
||||||
|
|
||||||
static void InitSSAOData();
|
static void InitSSAOData();
|
||||||
static void InitSubFrustrums();
|
static void InitSubFrustrums(int sizeX, int sizeY);
|
||||||
static void InitPointLights();
|
static void InitPointLights();
|
||||||
static void InitLightData();
|
static void InitLightData();
|
||||||
|
|
||||||
static void InitLighting();
|
static void InitLighting(int sizeX, int sizeY);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue