stuff-from-scratch/src/graphics/DrawingContext.h

38 lines
854 B
C
Raw Normal View History

2021-04-17 12:57:14 +00:00
#pragma once
#include <memory>
2022-05-15 13:58:31 +00:00
#include <vector>
2021-04-17 12:57:14 +00:00
class INativeDrawingContext;
2022-05-15 13:58:31 +00:00
class AbstractGeometricItem;
using AbstractGeometricItemPtr = std::unique_ptr<AbstractGeometricItem>;
2021-04-17 12:57:14 +00:00
2022-11-13 17:02:09 +00:00
class TriMesh;
2021-04-17 12:57:14 +00:00
class DrawingContext
{
public:
DrawingContext() = default;
static std::unique_ptr<DrawingContext> Create();
2022-11-13 17:02:09 +00:00
void setNativeContext(std::unique_ptr<INativeDrawingContext> context);
2021-04-17 12:57:14 +00:00
2022-11-13 17:02:09 +00:00
INativeDrawingContext* getNativeContext();
2021-04-17 12:57:14 +00:00
2022-11-13 17:02:09 +00:00
unsigned getNumItems() const;
2022-05-15 13:58:31 +00:00
2022-11-13 17:02:09 +00:00
void addDrawable(AbstractGeometricItemPtr item);
2022-05-15 13:58:31 +00:00
2022-11-13 17:02:09 +00:00
AbstractGeometricItem* getDrawable(unsigned idx) const;
2022-05-15 13:58:31 +00:00
2021-04-17 12:57:14 +00:00
private:
2022-11-13 17:02:09 +00:00
void updateMesh();
2021-04-17 12:57:14 +00:00
2022-11-13 17:02:09 +00:00
std::unique_ptr<TriMesh> mMesh;
2022-05-15 13:58:31 +00:00
std::vector<std::unique_ptr<AbstractGeometricItem> > mItems;
2021-04-17 12:57:14 +00:00
std::unique_ptr<INativeDrawingContext> mNativeDrawingContext;
};
using DrawingContextPtr = std::unique_ptr<DrawingContext>;