Skip to content

Instantly share code, notes, and snippets.

@vasumahesh1
Last active March 25, 2016 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasumahesh1/333012f442b0a7882f5b to your computer and use it in GitHub Desktop.
Save vasumahesh1/333012f442b0a7882f5b to your computer and use it in GitHub Desktop.
ref class ResourceManager
{
internal :
ResourceManager(std::shared_ptr<DX::DeviceResources>& deviceResources);
// Main Init Task
Concurrency::task<void> Init();
auto GetTiles() { return m_tiles; }
// Getting Buffers
Microsoft::WRL::ComPtr<ID3D11Buffer> GetBufferNeverChanges() { return m_constantBufferNeverChanges; }
Microsoft::WRL::ComPtr<ID3D11Buffer> GetBufferChangesOnResize() { return m_constantBufferChangeOnResize; }
Microsoft::WRL::ComPtr<ID3D11Buffer> GetBufferChangesEveryFrame() { return m_constantBufferChangesEveryFrame; }
Microsoft::WRL::ComPtr<ID3D11Buffer> GetBufferChangesEveryPrim() { return m_constantBufferChangesEveryPrim; }
Microsoft::WRL::ComPtr<ID3D11SamplerState> GetLinearSampler() { return m_samplerLinear; }
Microsoft::WRL::ComPtr<ID3D11InputLayout> GetVertexLayout() { return m_vertexLayout; }
Microsoft::WRL::ComPtr<ID3D11VertexShader> GetVertexShader() { return m_vertexShader; }
Microsoft::WRL::ComPtr<ID3D11PixelShader> GetPixelShader() { return m_pixelShader; }
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> GetTileset() { return m_tileset; }
Material^ GetTilesetMaterial() { return m_tilesetMaterial; }
private:
Concurrency::task<void> LoadResources();
void LoadBuffers();
void InitTileMaterials();
void InitTileMeshes();
void InitTiles();
std::shared_ptr<DX::DeviceResources> m_deviceResources;
bool m_init;
// Textures
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_tileset;
// Maps & Tiles
std::map<TILE_FACES, TileMesh^> m_tileMeshes; // Mesh for Each Face
std::map<TILE_FACES, TerrainTile^> m_tiles; // Terrain Tile Object for Each Face
// Material
Material^ m_tilesetMaterial;
// Shaders
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
// Layouts
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_vertexLayout;
// Sampler
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_samplerLinear;
// Buffers
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBufferNeverChanges;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBufferChangeOnResize;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBufferChangesEveryFrame;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBufferChangesEveryPrim;
ID3D11Device* m_d3dDevice;
// D2D Factories
Microsoft::WRL::ComPtr<ID2D1Factory3> m_d2dFactory;
Microsoft::WRL::ComPtr<IDWriteFactory3> m_dwriteFactory;
Microsoft::WRL::ComPtr<ID2D1DeviceContext2> m_d2dContext;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment