#include <windows.h>
#include <d2d1.h>
#include <d2d1helper.h>
#include <dwrite.h>
#pragma comment(lib, "dwrite.lib")
#pragma comment(lib, "d2d1.lib")
HINSTANCE g_hinst;
HWND g_hwnd;
ID2D1Factory * g_factory;
ID2D1HwndRenderTarget * g_render_target;
ID2D1SolidColorBrush * g_brush;
IDWriteFactory * g_write_factory;
IDWriteTextFormat * g_text_format;
bool AppInit()
{
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_factory);
RECT rc;
GetClientRect(g_hwnd, &rc);
g_factory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(g_hwnd, D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top) ),
&g_render_target);
g_render_target->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::ForestGreen), &g_brush);
// Init Font
DWriteCreateFactory(DWRITE_FACTORY_TYPE_SH

本文是Direct2D系列的第三篇,详细讲解如何使用Direct2D API进行文字绘制,涵盖字体选择、布局、样式设置等关键步骤,适用于Windows平台的2D图形开发,是GDI和VC开发者进阶Direct2D的重要参考。
最低0.47元/天 解锁文章
1794

被折叠的 条评论
为什么被折叠?



