Clean up of scene nodes to support 2d and non int positioning.
This commit is contained in:
parent
1eeaebd0a9
commit
672b31b603
45 changed files with 341 additions and 200 deletions
|
@ -13,6 +13,7 @@ public:
|
|||
|
||||
virtual ~AbstractPainter() = default;
|
||||
virtual void paint() = 0;
|
||||
virtual bool supportsGeometryPrimitives() const { return false; };
|
||||
|
||||
protected:
|
||||
DrawingContext* mDrawingContext{ nullptr };
|
||||
|
|
|
@ -21,6 +21,7 @@ list(APPEND graphics_HEADERS
|
|||
DrawingContext.h
|
||||
PainterFactory.h
|
||||
AbstractPainter.h
|
||||
DrawingSurface.h
|
||||
)
|
||||
if(UNIX)
|
||||
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||
|
|
|
@ -45,3 +45,8 @@ AbstractPainter* DrawingContext::getPainter() const
|
|||
{
|
||||
return mPainter.get();
|
||||
}
|
||||
|
||||
bool DrawingContext::painterSupportsGeometryPrimitives() const
|
||||
{
|
||||
return mPainter->supportsGeometryPrimitives();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ enum class DrawingMode
|
|||
class DrawingContext
|
||||
{
|
||||
public:
|
||||
DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode);
|
||||
DrawingContext(DrawingSurface* surface, FontsManager* fontsManager = nullptr, DrawingMode requestedDrawingMode = DrawingMode::GRAPH);
|
||||
|
||||
static std::unique_ptr<DrawingContext> Create(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode);
|
||||
|
||||
|
@ -28,6 +28,8 @@ public:
|
|||
|
||||
AbstractPainter* getPainter() const;
|
||||
|
||||
bool painterSupportsGeometryPrimitives() const;
|
||||
|
||||
private:
|
||||
DrawingMode mDrawingMode;
|
||||
FontsManager* mFontsManager{nullptr};
|
||||
|
|
|
@ -39,7 +39,7 @@ void DirectXMesh::update(DrawingContext* context, ID3D12Device* device)
|
|||
y = 2 * y - 1;
|
||||
|
||||
Vertex vert;
|
||||
vert.position = DirectX::XMFLOAT3(x, y, 0.0);
|
||||
vert.position = DirectX::XMFLOAT3(static_cast<float>(x), static_cast<float>(y), 0.0);
|
||||
vert.color = DirectX::XMFLOAT4(color[0], color[1], color[2], color[3]);
|
||||
MLOG_INFO("Adding vert: " << x << " | " << y);
|
||||
mVertexBuffer.push_back(vert);
|
||||
|
@ -94,7 +94,7 @@ void DirectXMesh::createD3dVertexBuffer(ID3D12Device* device)
|
|||
|
||||
mVertexBufferView.BufferLocation = mD3dVertexBuffer->GetGPUVirtualAddress();
|
||||
mVertexBufferView.StrideInBytes = sizeof(Vertex);
|
||||
mVertexBufferView.SizeInBytes = buffer_size;
|
||||
mVertexBufferView.SizeInBytes = static_cast<UINT>(buffer_size);
|
||||
}
|
||||
|
||||
void DirectXMesh::uploadVertexBuffer(unsigned char* pBuffer) const
|
||||
|
@ -116,7 +116,7 @@ void DirectXMesh::createD3dIndexBuffer(ID3D12Device* device)
|
|||
mD3dIndexBuffer->Unmap(0, nullptr);
|
||||
|
||||
mIndexBufferView.BufferLocation = mD3dIndexBuffer->GetGPUVirtualAddress();
|
||||
mIndexBufferView.SizeInBytes = buffer_size;
|
||||
mIndexBufferView.SizeInBytes = static_cast<UINT>(buffer_size);
|
||||
mIndexBufferView.Format = DXGI_FORMAT_R16_UINT;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void DirectXTextPainter::initializeBrush(ID2D1DeviceContext2* d2dContext)
|
|||
d2dContext->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black), &mTextBrush);
|
||||
}
|
||||
|
||||
void DirectXTextPainter::updateTextFormat(IDWriteFactory* directWriteFactory, unsigned fontSize)
|
||||
void DirectXTextPainter::updateTextFormat(IDWriteFactory* directWriteFactory, float fontSize)
|
||||
{
|
||||
directWriteFactory->CreateTextFormat(
|
||||
L"Verdana",
|
||||
|
@ -54,9 +54,9 @@ void DirectXTextPainter::updateTextFormat(IDWriteFactory* directWriteFactory, un
|
|||
void DirectXTextPainter::paint(SceneText* text, DrawingContext* context, ID2D1DeviceContext2* d2dContext, IDWriteFactory* directWriteFactory)
|
||||
{
|
||||
const auto location = text->getTransform().getLocation();
|
||||
D2D1_RECT_F textRect = D2D1::RectF(location.getX(), location.getY(), location.getX() + 200, location.getY() + 100);
|
||||
D2D1_RECT_F textRect = D2D1::RectF(static_cast<float>(location.getX()), static_cast<float>(location.getY()), static_cast<float>(location.getX() + 200), static_cast<float>(location.getY() + 100));
|
||||
|
||||
updateTextFormat(directWriteFactory, text->getTextData().mFont.getSize());
|
||||
updateTextFormat(directWriteFactory, static_cast<float>(text->getTextData().mFont.getSize()));
|
||||
|
||||
auto content = StringUtils::convert(text->getTextData().mContent);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
private:
|
||||
void initializeBrush(ID2D1DeviceContext2* d2dContext);
|
||||
void updateTextFormat(IDWriteFactory* directWriteFactory, unsigned fontSize);
|
||||
void updateTextFormat(IDWriteFactory* directWriteFactory, float fontSize);
|
||||
|
||||
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> mTextBrush;
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> mTextFormat;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue