Danbias/Code/OysterGraphics/Core/Core.h

153 lines
3.3 KiB
C
Raw Normal View History

#pragma once
#ifndef Core_h
#define Core_h
#include "CoreIncludes.h"
#include <sstream>
#include "Buffer.h"
2013-11-20 10:22:01 +01:00
#include "OysterMath.h";
namespace Oyster
{
2013-11-20 10:22:01 +01:00
namespace Graphics
{
2013-11-20 10:22:01 +01:00
class Core
{
public:
2013-11-20 10:22:01 +01:00
static ID3D11Device* device;
2013-11-20 10:22:01 +01:00
static ID3D11DeviceContext* deviceContext;
2013-11-20 10:22:01 +01:00
static IDXGISwapChain* swapChain;
2013-11-20 10:22:01 +01:00
static std::stringstream log;
2013-11-20 10:22:01 +01:00
//BackBufferRTV
static ID3D11RenderTargetView* backBufferRTV;
//BackBufferUAV
static ID3D11UnorderedAccessView* backBufferUAV;
//DepthStencil
static ID3D11DepthStencilView* depthStencil;
//ViewPort
static D3D11_VIEWPORT* viewPort;
2013-11-20 10:22:01 +01:00
static Oyster::Math::Float2 resolution;
2013-11-20 10:22:01 +01:00
class ShaderManager
{
2013-11-20 10:22:01 +01:00
public:
struct ShaderEffect
{
2013-11-20 10:22:01 +01:00
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<Buffer*> Vertex;
std::vector<Buffer*> Geometry;
std::vector<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
{
2013-11-20 10:22:01 +01:00
Vertex,
Hull,
Domain,
Geometry,
Pixel,
Compute
};
2013-11-20 10:22:01 +01:00
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);
2013-11-20 10:22:01 +01:00
struct Get
{
2013-11-20 10:22:01 +01:00
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);
};
};
2013-11-20 10:22:01 +01:00
//Set resulotion Before Calling Full Init
class Init
{
2013-11-20 10:22:01 +01:00
public:
enum State
{
Sucsess,
Fail
};
2013-11-20 10:22:01 +01:00
static State CreateDeviceAndDeviceContext(bool SingleThreaded = true, bool Reference = false, bool ForceDX11 = true);
2013-11-20 10:22:01 +01:00
static State CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size);
2013-11-20 10:22:01 +01:00
static State CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size);
2013-11-20 10:22:01 +01:00
static State CreateBackBufferViews();
2013-11-20 10:22:01 +01:00
static State CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size);
static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen);
static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen);
};
};
2013-11-20 10:22:01 +01:00
}
}
#endif