Start aligning Dx and OpenGl approaches.
This commit is contained in:
parent
d1ec8b4f68
commit
d99a36f24f
22 changed files with 899 additions and 366 deletions
64
src/graphics/directx/DirectXTextPainter.cpp
Normal file
64
src/graphics/directx/DirectXTextPainter.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "DirectXTextPainter.h"
|
||||
|
||||
#include "DrawingContext.h"
|
||||
#include "DrawingSurface.h"
|
||||
|
||||
#include "FontsManager.h"
|
||||
#include "FontGlyph.h"
|
||||
|
||||
#include "DirectXShaderProgram.h"
|
||||
#include "TextData.h"
|
||||
|
||||
#include "SceneText.h"
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <d2d1_3.h>
|
||||
#include <d2d1_1.h>
|
||||
#include <dwrite.h>
|
||||
|
||||
DirectXTextPainter::DirectXTextPainter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DirectXTextPainter::paint(SceneText* text, DrawingContext* context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DirectXTextPainter::paint(ID2D1DeviceContext2* d2dContext, float width, float height)
|
||||
{
|
||||
D2D1_RECT_F textRect = D2D1::RectF(0, 0, width, height);
|
||||
static const WCHAR text[] = L"11On12";
|
||||
|
||||
d2dContext->BeginDraw();
|
||||
d2dContext->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2dContext->DrawText(text, _countof(text) - 1, mTextFormat.Get(), &textRect, mTextBrush.Get());
|
||||
d2dContext->EndDraw();
|
||||
}
|
||||
|
||||
void DirectXTextPainter::initializeBrush(ID2D1DeviceContext2* d2dContext)
|
||||
{
|
||||
d2dContext->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black), &mTextBrush);
|
||||
}
|
||||
|
||||
void DirectXTextPainter::initializeTextFormat(IDWriteFactory* directWriteFactory)
|
||||
{
|
||||
directWriteFactory->CreateTextFormat(
|
||||
L"Verdana",
|
||||
NULL,
|
||||
DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL,
|
||||
50,
|
||||
L"en-us",
|
||||
&mTextFormat
|
||||
);
|
||||
mTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
|
||||
mTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue