3 #include "ScopeDefines.h"
24 pFactory->GetDesktopDpi(&X,&Y);
32 return D2D1::Point2F(static_cast<float>(x) / scaleX, static_cast<float>(y) / scaleY);
38 template <D2D1_FACTORY_TYPE policy_
class>
51 if ( SCOPE_DIRECT2D_DEBUG ) {
52 D2D1_FACTORY_OPTIONS options;
53 options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
54 D2D1CreateFactory(policy_class, options, &pd2d_factory);
58 D2D1CreateFactory(policy_class, &pd2d_factory);
103 HRESULT
CreateSolidColorBrush(ID2D1SolidColorBrush** _brush,
const D2D1_COLOR_F& _color = D2D1::ColorF(D2D1::ColorF::White));
108 HRESULT
CreateBitmap(ID2D1Bitmap** _bitmap,
const uint32_t& _yres,
const uint32_t& _xres);
126 void Clear(
const D2D1_COLOR_F& _clearColor = D2D1::ColorF(D2D1::ColorF::White));
136 void DrawBitmap(ID2D1Bitmap* _bitmap, D2D1_BITMAP_INTERPOLATION_MODE _mode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
139 void DrawLine(
const D2D1_POINT_2F& _point0,
const D2D1_POINT_2F& _point1, ID2D1Brush* _brush,
const FLOAT& _strokeWidth);
142 void DrawText(
const CString& _text,
const D2D1_RECT_F* _layoutRect, IDWriteTextFormat* _text_format, ID2D1Brush* _brush);
145 void FillRectangle(
const D2D1_RECT_F* _rect, ID2D1Brush* _brush);
155 HRESULT
Resize(
const D2D1_SIZE_U& _pixelSize);
void Clear(const D2D1_COLOR_F &_clearColor=D2D1::ColorF(D2D1::ColorF::White))
Clear the window with a certain color.
IDWriteFactory * dwrite_factory
Direct2D write factory for text rendering (do not use a unique_ptr for COM interfaces) ...
void ClearWindow()
Clear the window with black.
HRESULT CreateBitmap(ID2D1Bitmap **_bitmap, const uint32_t &_yres, const uint32_t &_xres)
Creates a new Direct2D bitmap.
void SetTransform(const D2D1_MATRIX_3X2_F &_transform)
Set current transform matrix.
void DrawLine(const D2D1_POINT_2F &_point0, const D2D1_POINT_2F &_point1, ID2D1Brush *_brush, const FLOAT &_strokeWidth)
Draw a line.
HRESULT CreateTextFormat(IDWriteTextFormat **_text_format)
Create a text format.
Helper class to convert from screen mouse coordinates to device independent pixels for Direct2D...
static void Initialize(ID2D1Factory *pFactory)
Initialize with desktop dpis.
d2dfactory< D2D1_FACTORY_TYPE_MULTI_THREADED > factory
Direct2D factory.
void BeginDraw()
Trigger Direct2D begin draw.
RenderTarget & operator=(const RenderTarget &)
disable assignment
ID2D1HwndRenderTarget * target
Direct2D render target (do not use a unique_ptr for COM interfaces)
Wrappers around the Direct2D interface.
void FillRectangle(const D2D1_RECT_F *_rect, ID2D1Brush *_brush)
Fill a rectangle.
static float scaleX
x scale factor
void SafeRelease(Interface **ppInterfaceToRelease)
A safe release for COM objects.
ID2D1Factory * pd2d_factory
Direct2D factory (do not use a unique_ptr for COM interfaces)
HRESULT EndDraw()
Trigger Direct2D end draw.
HRESULT Resize(const D2D1_SIZE_U &_pixelSize)
Resize render target.
HRESULT CreateSolidColorBrush(ID2D1SolidColorBrush **_brush, const D2D1_COLOR_F &_color=D2D1::ColorF(D2D1::ColorF::White))
Create a solid color brush.
Simple wrapper around a Direct2D factory.
D2D1_PIXEL_FORMAT pixelformat
current pixel format
~d2dfactory()
Safely release the factory.
static D2D1_POINT_2F PixelsToDips(T x, T y)
Convert screen pixels to device independent points.
static float scaleY
y scale factor
d2dfactory()
Create the factory and initialize the global DPIScale object, if debug build activate Direct2D debug ...
Wrapper around a Direct2D render target and the underlying Direct2D factory and IDWriteFactory.
void DrawText(const CString &_text, const D2D1_RECT_F *_layoutRect, IDWriteTextFormat *_text_format, ID2D1Brush *_brush)
Draw text.
HRESULT CreateRectangleGeometry(const D2D1_RECT_F &_rectangle, ID2D1RectangleGeometry **_rectangleGeometry)
Create a rectangle geometry.
D2D1_SIZE_F GetSize() const
Get size of render target.
~RenderTarget()
Release resources.
Various helper functions and classes for Scope.
RenderTarget(const RenderTarget &)
disable copy
void DrawBitmap(ID2D1Bitmap *_bitmap, D2D1_BITMAP_INTERPOLATION_MODE _mode=D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
Draws a Direct2D bitmap.
HRESULT hr
for error logging
HRESULT Flush()
Flush the render target.
D2D1_WINDOW_STATE CheckWindowState()
Check state of window, e.g.