Core Update
This commit is contained in:
parent
c9e6bbf899
commit
425a838f31
|
@ -1,9 +1,9 @@
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
|
|
||||||
Oyster::Buffer::Buffer()
|
Buffer::Buffer()
|
||||||
{
|
{
|
||||||
mBuffer = NULL;
|
mBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -23,32 +23,32 @@ HRESULT Buffer::Apply(UINT32 misc) const
|
||||||
{
|
{
|
||||||
UINT32 vertexSize = mElementSize;
|
UINT32 vertexSize = mElementSize;
|
||||||
UINT32 offset = 0;
|
UINT32 offset = 0;
|
||||||
Oyster::Core::DeviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
Core::deviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEX_BUFFER:
|
case INDEX_BUFFER:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
Core::deviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_VS:
|
case CONSTANT_BUFFER_VS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_GS:
|
case CONSTANT_BUFFER_GS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_PS:
|
case CONSTANT_BUFFER_PS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_CS:
|
case CONSTANT_BUFFER_CS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
Core::deviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -145,11 +145,11 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
||||||
data.pSysMem = initDesc.InitData;
|
data.pSysMem = initDesc.InitData;
|
||||||
data.SysMemPitch=0;
|
data.SysMemPitch=0;
|
||||||
data.SysMemSlicePitch = 0;
|
data.SysMemSlicePitch = 0;
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
|
@ -173,7 +173,7 @@ void* Buffer::Map()
|
||||||
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if(FAILED(hr = Oyster::Core::DeviceContext->Map(
|
if(FAILED(hr = Core::deviceContext->Map(
|
||||||
mBuffer,
|
mBuffer,
|
||||||
0,
|
0,
|
||||||
(D3D11_MAP)mapType,
|
(D3D11_MAP)mapType,
|
||||||
|
@ -194,10 +194,10 @@ void* Buffer::Map()
|
||||||
|
|
||||||
void Buffer::Unmap()
|
void Buffer::Unmap()
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
Core::deviceContext->Unmap( mBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Buffer::operator ID3D11Buffer *()
|
Buffer::operator ID3D11Buffer *()
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
class Buffer
|
class Buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -71,7 +73,7 @@ namespace Oyster
|
||||||
UINT32 GetVertexSize();
|
UINT32 GetVertexSize();
|
||||||
UINT32 GetElementCount();
|
UINT32 GetElementCount();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,169 +1,25 @@
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
//GPU
|
//GPU
|
||||||
ID3D11Device *Core::Device = NULL;
|
ID3D11Device *Core::device = NULL;
|
||||||
|
|
||||||
//API
|
//API
|
||||||
ID3D11DeviceContext *Core::DeviceContext = NULL;
|
ID3D11DeviceContext *Core::deviceContext = NULL;
|
||||||
|
|
||||||
//SwapChain
|
//SwapChain
|
||||||
IDXGISwapChain* Core::SwapChain = NULL;
|
IDXGISwapChain* Core::swapChain = NULL;
|
||||||
|
|
||||||
std::stringstream Log;
|
std::stringstream Core::log;
|
||||||
|
|
||||||
inline std::stringstream* AccesLog(){return &Log;}
|
ID3D11RenderTargetView* Core::backBufferRTV = NULL;
|
||||||
|
|
||||||
bool Core::Init(bool SingleThreaded, bool Reference,bool ForceDX11)
|
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
||||||
{
|
|
||||||
UINT createDeviceFlags = 0;
|
|
||||||
|
|
||||||
if( SingleThreaded )
|
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
||||||
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
|
||||||
|
|
||||||
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
D3D11_VIEWPORT* Core::viewPort = NULL;
|
||||||
|
|
||||||
if(Reference)
|
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
||||||
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(_DEBUG)
|
|
||||||
Log << "DirectX running in debug mode.\n";
|
|
||||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
|
||||||
{
|
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
|
||||||
D3D_FEATURE_LEVEL_10_0
|
|
||||||
};
|
|
||||||
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
|
||||||
|
|
||||||
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
|
||||||
driverType,
|
|
||||||
NULL, // no software device
|
|
||||||
createDeviceFlags,
|
|
||||||
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
|
||||||
D3D11_SDK_VERSION,
|
|
||||||
&Device, // device
|
|
||||||
&initiatedFeatureLevel,
|
|
||||||
&DeviceContext ) ) ) // context
|
|
||||||
{ // if failed
|
|
||||||
if( DeviceContext ) { DeviceContext->Release(); DeviceContext = NULL; } // safe cleanup
|
|
||||||
if( Device ) { Device->Release(); Device = NULL; } // safe cleanup
|
|
||||||
}
|
|
||||||
|
|
||||||
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
|
||||||
Log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
|
||||||
else
|
|
||||||
Log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
|
||||||
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 11.0 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(ForceDX11)
|
|
||||||
return false;
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.1 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.0 supported.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Device)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen)
|
|
||||||
{
|
|
||||||
//generate static Swapchain Desc
|
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
|
||||||
desc.OutputWindow=Window;
|
|
||||||
desc.BufferCount=NrofBuffers;
|
|
||||||
desc.Windowed=!Fullscreen;
|
|
||||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
|
||||||
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
|
||||||
desc.Flags=0;
|
|
||||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
|
||||||
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
|
||||||
desc.BufferDesc.RefreshRate.Denominator=1;
|
|
||||||
desc.BufferDesc.RefreshRate.Numerator=60;
|
|
||||||
|
|
||||||
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
|
|
||||||
if(MSAA_Quality)
|
|
||||||
{
|
|
||||||
if(FAILED(Device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
|
||||||
{
|
|
||||||
Log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
desc.SampleDesc.Count=4;
|
|
||||||
--desc.SampleDesc.Quality;
|
|
||||||
Log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
desc.SampleDesc.Count=1;
|
|
||||||
desc.SampleDesc.Quality=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get Device Factory
|
|
||||||
::IDXGIDevice *dxgiDevice = NULL;
|
|
||||||
if( FAILED( Device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
|
||||||
{
|
|
||||||
Log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
::IDXGIAdapter *dxgiAdapter = NULL;
|
|
||||||
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
|
||||||
{
|
|
||||||
dxgiDevice->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiDevice->Release();
|
|
||||||
|
|
||||||
::IDXGIFactory *dxgiFactory = NULL;
|
|
||||||
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
|
||||||
{
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
|
|
||||||
//Create SwapChain
|
|
||||||
if( FAILED( dxgiFactory->CreateSwapChain( Device, &desc, &SwapChain ) ) )
|
|
||||||
{
|
|
||||||
dxgiFactory->Release();
|
|
||||||
Log << "Failed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dxgiFactory->Release();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -7,23 +7,35 @@
|
||||||
#include "CoreIncludes.h"
|
#include "CoreIncludes.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include "OysterMath.h";
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
class Core
|
class Core
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static ID3D11Device* Device;
|
static ID3D11Device* device;
|
||||||
|
|
||||||
static ID3D11DeviceContext* DeviceContext;
|
static ID3D11DeviceContext* deviceContext;
|
||||||
|
|
||||||
static IDXGISwapChain* SwapChain;
|
static IDXGISwapChain* swapChain;
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
static std::stringstream log;
|
||||||
|
|
||||||
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
//BackBufferRTV
|
||||||
|
static ID3D11RenderTargetView* backBufferRTV;
|
||||||
|
//BackBufferUAV
|
||||||
|
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||||
|
//DepthStencil
|
||||||
|
static ID3D11DepthStencilView* depthStencil;
|
||||||
|
//ViewPort
|
||||||
|
static D3D11_VIEWPORT* viewPort;
|
||||||
|
|
||||||
|
static Oyster::Math::Float2 resolution;
|
||||||
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
|
||||||
|
|
||||||
class ShaderManager
|
class ShaderManager
|
||||||
{
|
{
|
||||||
|
@ -52,9 +64,9 @@ namespace Oyster
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
std::vector<Oyster::Buffer*> Vertex;
|
std::vector<Buffer*> Vertex;
|
||||||
std::vector<Oyster::Buffer*> Geometry;
|
std::vector<Buffer*> Geometry;
|
||||||
std::vector<Oyster::Buffer*> Pixel;
|
std::vector<Buffer*> Pixel;
|
||||||
}CBuffers;
|
}CBuffers;
|
||||||
|
|
||||||
ShaderEffect()
|
ShaderEffect()
|
||||||
|
@ -108,7 +120,33 @@ namespace Oyster
|
||||||
static void Domain(int Index);
|
static void Domain(int Index);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Set resulotion Before Calling Full Init
|
||||||
|
class Init
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum State
|
||||||
|
{
|
||||||
|
Sucsess,
|
||||||
|
Fail
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static State CreateDeviceAndDeviceContext(bool SingleThreaded = true, bool Reference = false, bool ForceDX11 = true);
|
||||||
|
|
||||||
|
static State CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size);
|
||||||
|
|
||||||
|
static State CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size);
|
||||||
|
|
||||||
|
static State CreateBackBufferViews();
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,337 @@
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
Core::Init::State Core::Init::CreateDeviceAndDeviceContext(bool SingleThreaded,bool Reference,bool ForceDX11)
|
||||||
|
{
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
|
||||||
|
if(Core::deviceContext)
|
||||||
|
{
|
||||||
|
Core::deviceContext->Release();
|
||||||
|
delete Core::deviceContext;
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
{
|
||||||
|
Core::device->Release();
|
||||||
|
delete Core::device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( SingleThreaded )
|
||||||
|
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||||
|
|
||||||
|
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
||||||
|
|
||||||
|
if(Reference)
|
||||||
|
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
||||||
|
|
||||||
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
|
log << "DirectX running in debug mode.\n";
|
||||||
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
|
D3D_FEATURE_LEVEL_10_0
|
||||||
|
};
|
||||||
|
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
||||||
|
|
||||||
|
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
||||||
|
driverType,
|
||||||
|
NULL, // no software device
|
||||||
|
createDeviceFlags,
|
||||||
|
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
||||||
|
D3D11_SDK_VERSION,
|
||||||
|
&Core::device, // device
|
||||||
|
&initiatedFeatureLevel,
|
||||||
|
&Core::deviceContext ) ) ) // context
|
||||||
|
{ // if failed
|
||||||
|
if( Core::deviceContext ) { Core::deviceContext->Release(); Core::deviceContext = NULL; } // safe cleanup
|
||||||
|
if( Core::device ) { Core::device->Release(); Core::device = NULL; } // safe cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
||||||
|
log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
||||||
|
else
|
||||||
|
log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
||||||
|
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 11.0 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(ForceDX11)
|
||||||
|
return Init::Fail;
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.1 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.0 supported.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
return Init::Sucsess;
|
||||||
|
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
//generate static Swapchain Desc
|
||||||
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
desc.OutputWindow=Window;
|
||||||
|
desc.BufferCount=NrofBuffers;
|
||||||
|
desc.Windowed=!Fullscreen;
|
||||||
|
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
||||||
|
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
desc.Flags=0;
|
||||||
|
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||||
|
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
||||||
|
desc.BufferDesc.RefreshRate.Denominator=1;
|
||||||
|
desc.BufferDesc.RefreshRate.Numerator=60;
|
||||||
|
|
||||||
|
desc.BufferDesc.Height = Size.y;
|
||||||
|
desc.BufferDesc.Width = Size.x;
|
||||||
|
|
||||||
|
if(Core::swapChain)
|
||||||
|
{
|
||||||
|
Core::swapChain->Release();
|
||||||
|
delete Core::swapChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get Device Factory
|
||||||
|
::IDXGIDevice *dxgiDevice = NULL;
|
||||||
|
if( FAILED( Core::device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
||||||
|
{
|
||||||
|
log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
::IDXGIAdapter *dxgiAdapter = NULL;
|
||||||
|
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
||||||
|
{
|
||||||
|
dxgiDevice->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiDevice->Release();
|
||||||
|
|
||||||
|
::IDXGIFactory *dxgiFactory = NULL;
|
||||||
|
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
||||||
|
{
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
|
||||||
|
//Create SwapChain
|
||||||
|
if( FAILED( dxgiFactory->CreateSwapChain( Core::device, &desc, &Core::swapChain ) ) )
|
||||||
|
{
|
||||||
|
dxgiFactory->Release();
|
||||||
|
log << "Failed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
dxgiFactory->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
desc.MipLevels=1;
|
||||||
|
desc.ArraySize=1;
|
||||||
|
desc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
|
desc.CPUAccessFlags=0;
|
||||||
|
desc.MiscFlags=0;
|
||||||
|
desc.Height = Size.y;
|
||||||
|
desc.Width = Size.x;
|
||||||
|
|
||||||
|
if(Core::depthStencil)
|
||||||
|
{
|
||||||
|
Core::depthStencil->Release();
|
||||||
|
delete Core::depthStencil;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Texture2D* depthstencil;
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateTexture2D(&desc,0,&depthstencil)))
|
||||||
|
return Init::Fail;
|
||||||
|
if(FAILED(Core::device->CreateDepthStencilView(depthstencil,0,&Core::depthStencil)))
|
||||||
|
{
|
||||||
|
depthstencil->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
depthstencil->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateBackBufferViews()
|
||||||
|
{
|
||||||
|
D3D11_UNORDERED_ACCESS_VIEW_DESC descView;
|
||||||
|
ZeroMemory( &descView, sizeof(descView) );
|
||||||
|
descView.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
|
||||||
|
descView.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
descView.Texture2D.MipSlice=0;
|
||||||
|
|
||||||
|
ID3D11Texture2D* backBuffer;
|
||||||
|
if(FAILED(Core::swapChain->GetBuffer(0,__uuidof(ID3D11Texture2D),reinterpret_cast<void**>(&backBuffer))))
|
||||||
|
{
|
||||||
|
log << "Failed to get BackBuffer from Swapchain";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferRTV)
|
||||||
|
{
|
||||||
|
Core::backBufferRTV->Release();
|
||||||
|
delete Core::backBufferRTV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateRenderTargetView(backBuffer,0,&Core::backBufferRTV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create RTV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferUAV)
|
||||||
|
{
|
||||||
|
Core::backBufferUAV->Release();
|
||||||
|
delete Core::backBufferUAV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateUnorderedAccessView(backBuffer,0,&Core::backBufferUAV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create UAV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
backBuffer->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
if(Core::viewPort)
|
||||||
|
delete Core::viewPort;
|
||||||
|
Core::viewPort = new D3D11_VIEWPORT;
|
||||||
|
|
||||||
|
Core::viewPort->TopLeftX = Origin.x;
|
||||||
|
Core::viewPort->TopLeftY = Origin.y;
|
||||||
|
Core::viewPort->Width = Size.x;
|
||||||
|
Core::viewPort->Height = Size.y;
|
||||||
|
Core::viewPort->MinDepth = 0.0f;
|
||||||
|
Core::viewPort->MaxDepth = 1.0f;
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateDeviceAndDeviceContext() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ const char* ShaderFunction = "main";
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
namespace
|
namespace
|
||||||
|
@ -28,7 +30,7 @@ namespace Oyster
|
||||||
std::map<std::wstring,int> VSMap;
|
std::map<std::wstring,int> VSMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Init
|
#pragma region Init
|
||||||
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
||||||
{
|
{
|
||||||
if(Precompiled)
|
if(Precompiled)
|
||||||
|
@ -73,7 +75,7 @@ namespace Oyster
|
||||||
if(VSMap.count(name))
|
if(VSMap.count(name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(FAILED(Core::Device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
if(FAILED(Core::device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +93,7 @@ namespace Oyster
|
||||||
|
|
||||||
if(GSMap.count(name))
|
if(GSMap.count(name))
|
||||||
return false;
|
return false;
|
||||||
if(FAILED(Core::Device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
if(FAILED(Core::device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +105,7 @@ namespace Oyster
|
||||||
|
|
||||||
if(PSMap.count(name))
|
if(PSMap.count(name))
|
||||||
return false;
|
return false;
|
||||||
if(FAILED(Core::Device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
if(FAILED(Core::device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +117,7 @@ namespace Oyster
|
||||||
|
|
||||||
if(CSMap.count(name))
|
if(CSMap.count(name))
|
||||||
return false;
|
return false;
|
||||||
if(FAILED(Core::Device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
if(FAILED(Core::device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,9 +149,8 @@ namespace Oyster
|
||||||
Error->Release();
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(FAILED(Oyster::Core::Device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
if(FAILED(Core::device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||||
{
|
{
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -175,9 +176,8 @@ namespace Oyster
|
||||||
Error->Release();
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(FAILED(Oyster::Core::Device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
if(FAILED(Core::device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||||
{
|
{
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -203,9 +203,8 @@ namespace Oyster
|
||||||
Error->Release();
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(FAILED(Oyster::Core::Device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
if(FAILED(Core::device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||||
{
|
{
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +233,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||||
{
|
{
|
||||||
|
@ -243,10 +242,10 @@ namespace Oyster
|
||||||
Layout=0;
|
Layout=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
Core::device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Get
|
#pragma region Get
|
||||||
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(PSMap.count(Name))
|
if(PSMap.count(Name))
|
||||||
|
@ -281,37 +280,37 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Set
|
#pragma region Set
|
||||||
/// \todo smart set
|
/// \todo smart set
|
||||||
void Core::ShaderManager::Set::Pixel(int Index)
|
void Core::ShaderManager::Set::Pixel(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Index==-1)
|
||||||
DeviceContext->PSSetShader( NULL,NULL,0);
|
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
||||||
else
|
else
|
||||||
DeviceContext->PSSetShader( PS[Index],NULL,0);
|
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Vertex(int Index)
|
void Core::ShaderManager::Set::Vertex(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Index==-1)
|
||||||
DeviceContext->VSSetShader( NULL,NULL,0);
|
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
||||||
else
|
else
|
||||||
DeviceContext->VSSetShader( VS[Index],NULL,0);
|
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Geometry(int Index)
|
void Core::ShaderManager::Set::Geometry(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Index==-1)
|
||||||
DeviceContext->GSSetShader( NULL,NULL,0);
|
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
||||||
else
|
else
|
||||||
DeviceContext->GSSetShader( GS[Index],NULL,0);
|
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Compute(int Index)
|
void Core::ShaderManager::Set::Compute(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Index==-1)
|
||||||
DeviceContext->CSSetShader( NULL,NULL,0);
|
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
||||||
else
|
else
|
||||||
DeviceContext->CSSetShader( CS[Index],NULL,0);
|
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
||||||
}
|
}
|
||||||
/// \todo set Hull
|
/// \todo set Hull
|
||||||
void Core::ShaderManager::Set::Hull(int Index)
|
void Core::ShaderManager::Set::Hull(int Index)
|
||||||
|
@ -323,7 +322,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
/// \todo smart Set ie. not resetting the shader
|
/// \todo smart Set ie. not resetting the shader
|
||||||
/// \todo research states
|
/// \todo research states
|
||||||
|
@ -334,18 +333,18 @@ namespace Oyster
|
||||||
Set::Vertex(se.Shaders.Vertex);
|
Set::Vertex(se.Shaders.Vertex);
|
||||||
Set::Geometry(se.Shaders.Geometry);
|
Set::Geometry(se.Shaders.Geometry);
|
||||||
Set::Compute(se.Shaders.Compute);
|
Set::Compute(se.Shaders.Compute);
|
||||||
Oyster::Core::DeviceContext->IASetInputLayout(se.IAStage.Layout);
|
Core::deviceContext->IASetInputLayout(se.IAStage.Layout);
|
||||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
||||||
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
||||||
se.CBuffers.Vertex[i]->Apply(i);
|
se.CBuffers.Vertex[i]->Apply(i);
|
||||||
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
||||||
se.CBuffers.Geometry[i]->Apply(i);
|
se.CBuffers.Geometry[i]->Apply(i);
|
||||||
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
||||||
se.CBuffers.Pixel[i]->Apply(i);
|
se.CBuffers.Pixel[i]->Apply(i);
|
||||||
Oyster::Core::DeviceContext->RSSetState(se.RenderStates.Rasterizer);
|
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||||
Oyster::Core::DeviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||||
float test[4] = {0};
|
float test[4] = {0};
|
||||||
Oyster::Core::DeviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
class Engine
|
class Engine
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -16,7 +18,7 @@ namespace Oyster
|
||||||
~Engine();
|
~Engine();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Init
|
/*class Init
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Setup
|
struct Setup
|
||||||
|
@ -66,7 +68,7 @@ namespace Oyster
|
||||||
private:
|
private:
|
||||||
Init();
|
Init();
|
||||||
~Init();
|
~Init();
|
||||||
};
|
};*/
|
||||||
|
|
||||||
class States
|
class States
|
||||||
{
|
{
|
||||||
|
@ -94,7 +96,7 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
/// Render a number of models, setting the Per model data to the included cBuffer
|
/// Render a number of models, setting the Per model data to the included cBuffer
|
||||||
/// specify NULL if no such data exists
|
/// specify NULL if no such data exists
|
||||||
static void Geometry(const Oyster::Render::Model* models,int count,Oyster::Buffer* cBufferEveryObject, int slot);
|
//static void Geometry(const Oyster::Graphics::Render::Model* models,int count,Buffer* cBufferEveryObject, int slot);
|
||||||
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
||||||
//static void TextBox(const Oyster::Render::
|
//static void TextBox(const Oyster::Render::
|
||||||
|
|
||||||
|
@ -147,19 +149,20 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//Basic Setup
|
//Basic Setup
|
||||||
static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
//static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
||||||
|
|
||||||
//Geometry Pass
|
//Geometry Pass
|
||||||
static void BeginRenderGeometry();
|
static void BeginRenderGeometry();
|
||||||
static void RenderGeometry(const Oyster::Render::Model* models,int count);
|
//static void RenderGeometry(const Oyster::Graphics::Render::Model* models,int count);
|
||||||
static void EndRenderGeometry();
|
static void EndRenderGeometry();
|
||||||
|
|
||||||
//Lightning Pass
|
//Lightning Pass
|
||||||
static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
//static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
||||||
static void RenderLightning();
|
static void RenderLightning();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
//Oyster
|
//Oyster
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
#include "Render\Model.h"
|
//#include "Render\Model.h"
|
||||||
#include "Render\Camera.h"
|
//#include "Render\Camera.h"
|
||||||
#include "Render\TextBox.h"
|
//#include "Render\TextBox.h"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
#include "Core\Core.h"
|
#include "Core\Core.h"
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
#include "Resourses\ShaderEffects.h"
|
//#include "Resourses\ShaderEffects.h"
|
||||||
#include "Resourses\Buffers.h"
|
//#include "Resourses\Buffers.h"
|
||||||
#include "Resourses\PipelineResources.h"
|
//#include "Resourses\PipelineResources.h"
|
||||||
#include "Resourses\GraphicsDefinitions.h"
|
//#include "Resourses\GraphicsDefinitions.h"
|
||||||
#include "Resourses\Manager.h"
|
//#include "Resourses\Manager.h"
|
|
@ -15,16 +15,17 @@ using namespace Oyster::Math;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
namespace Render
|
namespace Render
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Model
|
struct Model
|
||||||
{
|
{
|
||||||
ModelInfo* info;
|
ModelInfo* info;
|
||||||
Float4x4 *World;
|
Float4x4 *World;
|
||||||
bool Visible;
|
bool Visible;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -14,16 +14,19 @@ using namespace Oyster::Math;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
namespace Render
|
namespace Render
|
||||||
{
|
{
|
||||||
struct ModelInfo
|
struct ModelInfo
|
||||||
{
|
{
|
||||||
std::vector<ID3D11ShaderResourceView*> Material;
|
std::vector<ID3D11ShaderResourceView*> Material;
|
||||||
Oyster::Buffer Vertices,Indecies;
|
Buffer Vertices,Indecies;
|
||||||
bool Indexed;
|
bool Indexed;
|
||||||
int VertexCount;
|
int VertexCount;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,70 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "..\Engine.h"
|
||||||
|
const int MAX_LETTER_COUNT=60;
|
||||||
|
const int TEXT_NR_LETTERS=95;
|
||||||
|
const float TEXT_SIZE=2.5;
|
||||||
|
struct Text2D
|
||||||
|
{
|
||||||
|
Oyster::Math::Float Pos;
|
||||||
|
int offset;
|
||||||
|
float coff;
|
||||||
|
};
|
||||||
|
/*struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
/*struct TextData
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PerCharData
|
||||||
|
{
|
||||||
|
float data;
|
||||||
|
Oyster::Math::Float3 charOffset;
|
||||||
|
};
|
||||||
|
struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Textbox
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static float getCharID(char _in);
|
||||||
|
static HRESULT CreateVertexBuffer();
|
||||||
|
static HRESULT CreateTextfield(int _id);
|
||||||
|
public:
|
||||||
|
//static Oyster::Buffer TextBuffer;
|
||||||
|
//static int NumVertices;
|
||||||
|
//static std::vector<TextInstanceData> TextInstances;
|
||||||
|
static Buffer TextBuffer;
|
||||||
|
static int NumLetters;
|
||||||
|
static ID3D11ShaderResourceView* Texture;
|
||||||
|
|
||||||
|
static bool Init();
|
||||||
|
static bool UpdateTextField(std::string _str);
|
||||||
|
static bool SetTexture(const char* _file);
|
||||||
|
//Updates a textbox with the certain id
|
||||||
|
static void Update(std::string _str, float _scale);
|
||||||
|
//Removes all old instances and recreates it with the input data
|
||||||
|
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
||||||
|
static void Apply(int _id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -90,11 +90,14 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
|
<ProjectReference>
|
||||||
|
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||||
|
</ProjectReference>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -140,31 +143,15 @@
|
||||||
<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\Init.cpp" />
|
||||||
<ClCompile Include="Core\ShaderManager.cpp" />
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
<ClCompile Include="Engine.cpp" />
|
|
||||||
<ClCompile Include="Render\Model.cpp" />
|
|
||||||
<ClCompile Include="Render\TextBox.cpp" />
|
|
||||||
<ClCompile Include="Resourses\Buffers.cpp" />
|
|
||||||
<ClCompile Include="Resourses\Manager.cpp" />
|
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h" />
|
<ClInclude Include="Core\Buffer.h" />
|
||||||
<ClInclude Include="Core\Core.h" />
|
<ClInclude Include="Core\Core.h" />
|
||||||
<ClInclude Include="Core\CoreIncludes.h" />
|
<ClInclude Include="Core\CoreIncludes.h" />
|
||||||
<ClInclude Include="Engine.h" />
|
|
||||||
<ClInclude Include="EngineIncludes.h" />
|
<ClInclude Include="EngineIncludes.h" />
|
||||||
<ClInclude Include="FileLoader\ObjReader.h" />
|
<ClInclude Include="Render\Preparations.h" />
|
||||||
<ClInclude Include="Render\Lights.h" />
|
|
||||||
<ClInclude Include="Render\Model.h" />
|
|
||||||
<ClInclude Include="Render\ModelInfo.h" />
|
|
||||||
<ClInclude Include="Render\TextBox.h" />
|
|
||||||
<ClInclude Include="Resourses\Buffers.h" />
|
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h" />
|
|
||||||
<ClInclude Include="Resourses\Manager.h" />
|
|
||||||
<ClInclude Include="Resourses\PipelineResources.h" />
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
@ -192,6 +179,8 @@
|
||||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -21,30 +21,12 @@
|
||||||
<ClCompile Include="Core\Core.cpp">
|
<ClCompile Include="Core\Core.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Render\Model.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\TextBox.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Buffers.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Manager.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Engine.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Core\ShaderManager.cpp">
|
<ClCompile Include="Core\ShaderManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Init.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h">
|
<ClInclude Include="Core\Buffer.h">
|
||||||
|
@ -56,40 +38,10 @@
|
||||||
<ClInclude Include="Core\CoreIncludes.h">
|
<ClInclude Include="Core\CoreIncludes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\Lights.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\Model.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\ModelInfo.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\TextBox.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\Buffers.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\Manager.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\PipelineResources.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Engine.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="EngineIncludes.h">
|
<ClInclude Include="EngineIncludes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FileLoader\ObjReader.h">
|
<ClInclude Include="Render\Preparations.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "..\Core\Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Preparations
|
||||||
|
{
|
||||||
|
class Basic
|
||||||
|
{
|
||||||
|
void BindBackBufferRTV(bool UseDepthStencil = true);
|
||||||
|
void BindBackBufferRTV(ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
void BindBackBufferUAV();
|
||||||
|
|
||||||
|
void ClearBackBuffer(Oyster::Math::Float4 Color, bool ClearDepthStencil);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,67 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "..\Engine.h"
|
|
||||||
const int MAX_LETTER_COUNT=60;
|
|
||||||
const int TEXT_NR_LETTERS=95;
|
|
||||||
const float TEXT_SIZE=2.5;
|
|
||||||
struct Text2D
|
|
||||||
{
|
|
||||||
Oyster::Math::Float Pos;
|
|
||||||
int offset;
|
|
||||||
float coff;
|
|
||||||
};
|
|
||||||
/*struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
/*struct TextData
|
|
||||||
{
|
|
||||||
Oyster::Math::Float3 pos;
|
|
||||||
Oyster::Math::Float2 uv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PerCharData
|
|
||||||
{
|
|
||||||
float data;
|
|
||||||
Oyster::Math::Float3 charOffset;
|
|
||||||
};
|
|
||||||
struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
class Textbox
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static float getCharID(char _in);
|
|
||||||
static HRESULT CreateVertexBuffer();
|
|
||||||
static HRESULT CreateTextfield(int _id);
|
|
||||||
public:
|
|
||||||
//static Oyster::Buffer TextBuffer;
|
|
||||||
//static int NumVertices;
|
|
||||||
//static std::vector<TextInstanceData> TextInstances;
|
|
||||||
static Oyster::Buffer TextBuffer;
|
|
||||||
static int NumLetters;
|
|
||||||
static ID3D11ShaderResourceView* Texture;
|
|
||||||
|
|
||||||
static bool Init();
|
|
||||||
static bool UpdateTextField(std::string _str);
|
|
||||||
static bool SetTexture(const char* _file);
|
|
||||||
//Updates a textbox with the certain id
|
|
||||||
static void Update(std::string _str, float _scale);
|
|
||||||
//Removes all old instances and recreates it with the input data
|
|
||||||
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
|
||||||
static void Apply(int _id);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
class Shader
|
class Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -75,4 +77,5 @@ namespace Oyster
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
static std::stringstream* AccesLog();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -131,22 +131,21 @@ HRESULT InitDirect3D()
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;;
|
HRESULT hr = S_OK;;
|
||||||
|
|
||||||
Oyster::Engine::Init::Setup setup;
|
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
|
||||||
setup.Fullscreen = false;
|
|
||||||
setup.ForceDX11 = true;
|
if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
|
||||||
setup.SingleThreaded = true;
|
return E_FAIL;
|
||||||
setup.window = g_hWnd;
|
|
||||||
|
|
||||||
Oyster::Engine::Init::FullInit( setup );
|
|
||||||
|
|
||||||
std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\";
|
std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\";
|
||||||
std::wstring EffectPath = L"SimpleDebug\\";
|
std::wstring EffectPath = L"SimpleDebug\\";
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
|
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
|
||||||
Oyster::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Core::ShaderManager::ShaderType::Vertex,L"Debug",false);
|
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"Debug",false);
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::Set::Vertex(Oyster::Core::ShaderManager::Get::Vertex(L"Debug"));
|
Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"Debug"));
|
||||||
Oyster::Core::ShaderManager::Set::Pixel(Oyster::Core::ShaderManager::Get::Pixel(L"Debug"));
|
Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug"));
|
||||||
|
|
||||||
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
|
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
|
||||||
{
|
{
|
||||||
|
@ -155,12 +154,14 @@ HRESULT InitDirect3D()
|
||||||
|
|
||||||
ID3D11InputLayout* layout;
|
ID3D11InputLayout* layout;
|
||||||
|
|
||||||
Oyster::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Core::ShaderManager::Get::Vertex(L"Debug"), layout);
|
Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"Debug"), layout);
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->IASetInputLayout(layout);
|
Oyster::Graphics::Core::deviceContext->IASetInputLayout(layout);
|
||||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
Oyster::Engine::PrepareForRendering::BindBackBuffer();
|
Oyster::Graphics::Core::deviceContext->OMSetRenderTargets(1,&Oyster::Graphics::Core::backBufferRTV,Oyster::Graphics::Core::depthStencil);
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::deviceContext->RSSetViewports(1,Oyster::Graphics::Core::viewPort);
|
||||||
|
|
||||||
struct float4
|
struct float4
|
||||||
{
|
{
|
||||||
|
@ -174,14 +175,14 @@ HRESULT InitDirect3D()
|
||||||
{1.0f,-1.0f,0.0f,1.0f},
|
{1.0f,-1.0f,0.0f,1.0f},
|
||||||
};
|
};
|
||||||
|
|
||||||
Oyster::Buffer::BUFFER_INIT_DESC desc;
|
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
||||||
desc.ElementSize= sizeof(float4);
|
desc.ElementSize= sizeof(float4);
|
||||||
desc.NumElements = 3;
|
desc.NumElements = 3;
|
||||||
desc.InitData=mesh;
|
desc.InitData=mesh;
|
||||||
desc.Type = Oyster::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
||||||
desc.Usage = Oyster::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
||||||
|
|
||||||
Oyster::Buffer b;
|
Oyster::Graphics::Buffer b;
|
||||||
b.Init(desc);
|
b.Init(desc);
|
||||||
b.Apply(0);
|
b.Apply(0);
|
||||||
|
|
||||||
|
@ -195,11 +196,12 @@ HRESULT Update(float deltaTime)
|
||||||
|
|
||||||
HRESULT Render(float deltaTime)
|
HRESULT Render(float deltaTime)
|
||||||
{
|
{
|
||||||
Oyster::Engine::PrepareForRendering::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1));
|
Oyster::Graphics::Core::deviceContext->ClearRenderTargetView(Oyster::Graphics::Core::backBufferRTV, Oyster::Math::Float4(0,0,1,1));
|
||||||
|
Oyster::Graphics::Core::deviceContext->ClearDepthStencilView(Oyster::Graphics::Core::depthStencil,1,1,0);
|
||||||
|
|
||||||
Oyster::Core::DeviceContext->Draw(3,0);
|
Oyster::Graphics::Core::deviceContext->Draw(3,0);
|
||||||
|
|
||||||
Oyster::Core::SwapChain->Present(0,0);
|
Oyster::Graphics::Core::swapChain->Present(0,0);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue