Commit caca4839 authored by chili's avatar chili
Browse files

crashy crashy

parent d5ba4169
...@@ -23,5 +23,6 @@ void App::DoFrame() ...@@ -23,5 +23,6 @@ void App::DoFrame()
{ {
const float c = sin( timer.Peek() ) / 2.0f + 0.5f; const float c = sin( timer.Peek() ) / 2.0f + 0.5f;
wnd.Gfx().ClearBuffer( c,c,1.0f ); wnd.Gfx().ClearBuffer( c,c,1.0f );
wnd.Gfx().DrawTestTriangle();
wnd.Gfx().EndFrame(); wnd.Gfx().EndFrame();
} }
\ No newline at end of file
...@@ -94,6 +94,44 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept ...@@ -94,6 +94,44 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
pContext->ClearRenderTargetView( pTarget.Get(),color ); pContext->ClearRenderTargetView( pTarget.Get(),color );
} }
void Graphics::DrawTestTriangle()
{
namespace wrl = Microsoft::WRL;
HRESULT hr;
struct Vertex
{
float x;
float y;
};
// create vertex buffer (1 2d triangle at center of screen)
const Vertex vertices[] =
{
{ 0.0f,0.5f },
{ 0.5f,-0.5f },
{ -0.5f,-0.5f },
};
wrl::ComPtr<ID3D11Buffer> pVertexBuffer;
D3D11_BUFFER_DESC bd = {};
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.Usage = D3D11_USAGE_DEFAULT;
bd.CPUAccessFlags = 0u;
bd.MiscFlags = 0u;
bd.ByteWidth = sizeof( vertices );
bd.StructureByteStride = sizeof( Vertex );
D3D11_SUBRESOURCE_DATA sd = {};
sd.pSysMem = vertices;
GFX_THROW_INFO( pDevice->CreateBuffer( &bd,&sd,&pVertexBuffer ) );
// Bind vertex buffer to pipeline
const UINT stride = sizeof( Vertex );
const UINT offset = 0u;
pContext->IASetVertexBuffers( 0u,1u,&pVertexBuffer,&stride,&offset );
pContext->Draw( 3u,0u );
}
// Graphics exception stuff // Graphics exception stuff
Graphics::HrException::HrException( int line,const char * file,HRESULT hr,std::vector<std::string> infoMsgs ) noexcept Graphics::HrException::HrException( int line,const char * file,HRESULT hr,std::vector<std::string> infoMsgs ) noexcept
......
...@@ -42,6 +42,7 @@ public: ...@@ -42,6 +42,7 @@ public:
~Graphics() = default; ~Graphics() = default;
void EndFrame(); void EndFrame();
void ClearBuffer( float red,float green,float blue ) noexcept; void ClearBuffer( float red,float green,float blue ) noexcept;
void DrawTestTriangle();
private: private:
#ifndef NDEBUG #ifndef NDEBUG
DxgiInfoManager infoManager; DxgiInfoManager infoManager;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment