Commit 6554f8c8 authored by chili's avatar chili
Browse files

purdy colors (clear backbuffer)

parent 831380f6
......@@ -21,5 +21,7 @@ int App::Go()
void App::DoFrame()
{
const float c = sin( timer.Peek() ) / 2.0f + 0.5f;
wnd.Gfx().ClearBuffer( c,c,1.0f );
wnd.Gfx().EndFrame();
}
\ No newline at end of file
#pragma once
#include "Window.h"
#include "ChiliTimer.h"
class App
{
......@@ -11,4 +12,5 @@ private:
void DoFrame();
private:
Window wnd;
ChiliTimer timer;
};
\ No newline at end of file
......@@ -36,10 +36,23 @@ Graphics::Graphics( HWND hWnd )
nullptr,
&pContext
);
// gain access to texture subresource in swap chain (back buffer)
ID3D11Resource* pBackBuffer = nullptr;
pSwap->GetBuffer( 0,__uuidof(ID3D11Resource),reinterpret_cast<void**>(&pBackBuffer) );
pDevice->CreateRenderTargetView(
pBackBuffer,
nullptr,
&pTarget
);
pBackBuffer->Release();
}
Graphics::~Graphics()
{
if( pTarget != nullptr )
{
pTarget->Release();
}
if( pContext != nullptr )
{
pContext->Release();
......
......@@ -10,8 +10,14 @@ public:
Graphics& operator=( const Graphics& ) = delete;
~Graphics();
void EndFrame();
void ClearBuffer( float red,float green,float blue ) noexcept
{
const float color[] = { red,green,blue,1.0f };
pContext->ClearRenderTargetView( pTarget,color );
}
private:
ID3D11Device* pDevice = nullptr;
IDXGISwapChain* pSwap = nullptr;
ID3D11DeviceContext* pContext = nullptr;
ID3D11RenderTargetView* pTarget = nullptr;
};
\ No newline at end of file
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