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

purdy colors (clear backbuffer)

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