Scope
d2d::RenderTarget Class Reference

#include <d2wrap.h>

Public Member Functions

 RenderTarget (HWND _hwnd)
 
 ~RenderTarget ()
 
HRESULT Resize (const D2D1_SIZE_U &_pixelSize)
 
D2D1_WINDOW_STATE CheckWindowState ()
 
D2D1_SIZE_F GetSize () const
 
Methods for creation of resources
HRESULT CreateSolidColorBrush (ID2D1SolidColorBrush **_brush, const D2D1_COLOR_F &_color=D2D1::ColorF(D2D1::ColorF::White))
 
HRESULT CreateBitmap (ID2D1Bitmap **_bitmap, const uint32_t &_yres, const uint32_t &_xres)
 
HRESULT CreateTextFormat (IDWriteTextFormat **_text_format)
 
HRESULT CreateRectangleGeometry (const D2D1_RECT_F &_rectangle, ID2D1RectangleGeometry **_rectangleGeometry)
 
Methods for drawing
void BeginDraw ()
 
void SetTransform (const D2D1_MATRIX_3X2_F &_transform)
 
void Clear (const D2D1_COLOR_F &_clearColor=D2D1::ColorF(D2D1::ColorF::White))
 
void ClearWindow ()
 
void DrawBitmap (ID2D1Bitmap *_bitmap, D2D1_BITMAP_INTERPOLATION_MODE _mode=D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
 
void DrawLine (const D2D1_POINT_2F &_point0, const D2D1_POINT_2F &_point1, ID2D1Brush *_brush, const FLOAT &_strokeWidth)
 
void DrawText (const CString &_text, const D2D1_RECT_F *_layoutRect, IDWriteTextFormat *_text_format, ID2D1Brush *_brush)
 
void FillRectangle (const D2D1_RECT_F *_rect, ID2D1Brush *_brush)
 
HRESULT Flush ()
 
HRESULT EndDraw ()
 

Protected Member Functions

 RenderTarget (const RenderTarget &)
 
RenderTargetoperator= (const RenderTarget &)
 

Protected Attributes

d2dfactory< D2D1_FACTORY_TYPE_MULTI_THREADED > factory
 
ID2D1HwndRenderTarget * target
 
IDWriteFactory * dwrite_factory
 
D2D1_PIXEL_FORMAT pixelformat
 

Detailed Description

Wrapper around a Direct2D render target and the underlying Direct2D factory and IDWriteFactory.

Definition at line 71 of file d2wrap.h.

Constructor & Destructor Documentation

d2d::RenderTarget::RenderTarget ( const RenderTarget )
protected

disable copy

d2d::RenderTarget::RenderTarget ( HWND  _hwnd)

Create render target on window.

Definition at line 10 of file d2wrap.cpp.

d2d::RenderTarget::~RenderTarget ( )

Release resources.

Definition at line 42 of file d2wrap.cpp.

Member Function Documentation

RenderTarget& d2d::RenderTarget::operator= ( const RenderTarget )
protected

disable assignment

HRESULT d2d::RenderTarget::CreateSolidColorBrush ( ID2D1SolidColorBrush **  _brush,
const D2D1_COLOR_F &  _color = D2D1::ColorF(D2D1::ColorF::White) 
)

Create a solid color brush.

Definition at line 47 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::CreateBitmap ( ID2D1Bitmap **  _bitmap,
const uint32_t &  _yres,
const uint32_t &  _xres 
)

Creates a new Direct2D bitmap.

Parameters
[out]_bitmaphandle to the new bitmap
[in]_yres,_xresresolution of the bitmap

Definition at line 52 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::CreateTextFormat ( IDWriteTextFormat **  _text_format)

Create a text format.

Definition at line 79 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::CreateRectangleGeometry ( const D2D1_RECT_F &  _rectangle,
ID2D1RectangleGeometry **  _rectangleGeometry 
)

Create a rectangle geometry.

Definition at line 96 of file d2wrap.cpp.

void d2d::RenderTarget::BeginDraw ( )

Trigger Direct2D begin draw.

Definition at line 101 of file d2wrap.cpp.

void d2d::RenderTarget::SetTransform ( const D2D1_MATRIX_3X2_F &  _transform)

Set current transform matrix.

Definition at line 109 of file d2wrap.cpp.

void d2d::RenderTarget::Clear ( const D2D1_COLOR_F &  _clearColor = D2D1::ColorF(D2D1::ColorF::White))

Clear the window with a certain color.

Definition at line 118 of file d2wrap.cpp.

void d2d::RenderTarget::ClearWindow ( )

Clear the window with black.

Definition at line 113 of file d2wrap.cpp.

void d2d::RenderTarget::DrawBitmap ( ID2D1Bitmap *  _bitmap,
D2D1_BITMAP_INTERPOLATION_MODE  _mode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR 
)

Draws a Direct2D bitmap.

Parameters
[in]_bitmappointer to bitmap
[in]_modeinterpolation mode, possible values
  • D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
  • D2D1_BITMAP_INTERPOLATION_MODE_LINEAR

Definition at line 123 of file d2wrap.cpp.

void d2d::RenderTarget::DrawLine ( const D2D1_POINT_2F &  _point0,
const D2D1_POINT_2F &  _point1,
ID2D1Brush *  _brush,
const FLOAT &  _strokeWidth 
)

Draw a line.

Definition at line 131 of file d2wrap.cpp.

void d2d::RenderTarget::DrawText ( const CString &  _text,
const D2D1_RECT_F *  _layoutRect,
IDWriteTextFormat *  _text_format,
ID2D1Brush *  _brush 
)

Draw text.

Definition at line 135 of file d2wrap.cpp.

void d2d::RenderTarget::FillRectangle ( const D2D1_RECT_F *  _rect,
ID2D1Brush *  _brush 
)

Fill a rectangle.

Definition at line 143 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::Flush ( )

Flush the render target.

Definition at line 159 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::EndDraw ( )

Trigger Direct2D end draw.

Definition at line 151 of file d2wrap.cpp.

HRESULT d2d::RenderTarget::Resize ( const D2D1_SIZE_U &  _pixelSize)

Resize render target.

Definition at line 155 of file d2wrap.cpp.

D2D1_WINDOW_STATE d2d::RenderTarget::CheckWindowState ( )

Check state of window, e.g.

if it is occluded

Definition at line 105 of file d2wrap.cpp.

D2D1_SIZE_F d2d::RenderTarget::GetSize ( void  ) const

Get size of render target.

Definition at line 147 of file d2wrap.cpp.

Member Data Documentation

d2dfactory<D2D1_FACTORY_TYPE_MULTI_THREADED> d2d::RenderTarget::factory
protected

Direct2D factory.

Definition at line 75 of file d2wrap.h.

ID2D1HwndRenderTarget* d2d::RenderTarget::target
protected

Direct2D render target (do not use a unique_ptr for COM interfaces)

Definition at line 78 of file d2wrap.h.

IDWriteFactory* d2d::RenderTarget::dwrite_factory
protected

Direct2D write factory for text rendering (do not use a unique_ptr for COM interfaces)

Definition at line 81 of file d2wrap.h.

D2D1_PIXEL_FORMAT d2d::RenderTarget::pixelformat
protected

current pixel format

Definition at line 84 of file d2wrap.h.


The documentation for this class was generated from the following files: