13 #define ASSERT(e) assert(e) 16 #define DRAW_NO_EXCEPTIONS 17 #ifndef DRAW_NO_EXCEPTIONS 22 #define SHARED_PTR std::shared_ptr 23 #define MAKE_SHARED_PTR std::make_shared 39 #ifndef DRAW_NO_EXCEPTIONS 42 class Error :
public std::exception {
45 virtual ~Error() =
default;
85 Size(uint32_t width, uint32_t height) :
86 width(width), height(height) {};
106 Rect(int32_t left, int32_t bottom, int32_t right, int32_t top) :
107 left(left), bottom(bottom), right(right), top(top) {};
144 Color(
float r,
float g,
float b,
float a = 1.0f) :
145 r(r), g(g), b(b), a(a) {};
149 template <
typename T>
158 Span(
const T* ptr, uint32_t count) :
159 ptr(ptr), count(count) {}
172 static const uint32_t kMaxVertexCount = 65535;
183 position(position), uv(uv) {};
200 virtual uint32_t vertexCount()
const = 0;
202 virtual uint32_t indexCount()
const = 0;
211 #ifdef DRAW_NO_EXCEPTIONS 221 static const uint32_t kMaxSize = 4096;
231 virtual ~
Image() =
default;
234 virtual const Size& size()
const = 0;
236 virtual Format format()
const = 0;
238 virtual bool filter()
const = 0;
244 virtual void upload(
Bytes bytes) = 0;
253 virtual ~
Visual() =
default;
255 virtual void visibility(
bool enable) = 0;
257 virtual bool visibility()
const = 0;
259 virtual void order(uint32_t order) = 0;
261 virtual uint32_t order()
const = 0;
263 virtual void position(
const Point& position) = 0;
265 virtual const Point& position()
const = 0;
267 virtual const Rect& bounds()
const = 0;
277 virtual ~
Shape() =
default;
279 virtual void size(
const Size& size) = 0;
281 virtual const Size& size()
const = 0;
283 virtual void color(
const Color& color) = 0;
285 virtual const Color& color()
const = 0;
287 virtual void transparency(
bool value) = 0;
289 virtual bool transparency()
const = 0;
291 virtual void geometry(
const GeometryPtr& geometry) = 0;
295 virtual void image(
const ImagePtr& image) = 0;
301 virtual void image(
const ImagePtr& atlas,
const Rect& element) = 0;
314 static const uint32_t kMinLetterSize = 5;
316 virtual ~
Font() =
default;
318 virtual const char* filePath()
const = 0;
320 virtual uint32_t letterSize()
const = 0;
330 virtual ~
Text() =
default;
332 virtual void font(
const FontPtr& font) = 0;
334 virtual FontPtr font()
const = 0;
336 virtual void text(
const wchar_t* text) = 0;
338 virtual const wchar_t* text()
const = 0;
340 virtual void color(
const Color& color) = 0;
342 virtual const Color& color()
const = 0;
351 virtual void horizAlign(
HorizAlign alignment) = 0;
362 virtual void vertAlign(
VertAlign alignment) = 0;
371 #ifdef DRAW_NO_EXCEPTIONS 411 virtual FontPtr makeFont(
const char* filePath, uint32_t letterSize) = 0;
426 virtual TextPtr makeText() = 0;
431 virtual uint32_t
draw(
const Color& clear) = 0;
433 virtual void resize(
const Size& size) = 0;
449 virtual void setCurrent() = 0;
455 #ifdef DRAW_NO_EXCEPTIONS A visual shape.
Definition: draw.h:274
Vector2 position
2D-position in [0.0, 1.0] space
Definition: draw.h:176
Vector2 uv
UV-coordinates in [0.0, 1.0] space.
Definition: draw.h:178
A text object.
Definition: draw.h:327
A rect in pixel space.
Definition: draw.h:96
Point(int32_t x, int32_t y)
constructs from parameters
Definition: draw.h:66
RendererPtr makeRenderer(ContextPtr context)
make Renderer object
A point in pixel space.
Definition: draw.h:57
SHARED_PTR< Renderer > RendererPtr
Definition: draw.h:436
Factory and context owner.
Definition: draw.h:377
HorizAlign
Horizontal alignment.
Definition: draw.h:344
Floating-point 2D-vector.
Definition: draw.h:117
Set of characters of the same style and size.
Definition: draw.h:310
uint16_t Index
An index of a vertex.
Definition: draw.h:188
2D-vertex.
Definition: draw.h:174
ErrorCode
An error code which library can generate.
Definition: draw.h:29
const T * ptr
pointer to the first element
Definition: draw.h:153
Color(float r, float g, float b, float a=1.0f)
construct from parameters
Definition: draw.h:144
RGBA floating-point color.
Definition: draw.h:130
Base interface class of any visual object.
Definition: draw.h:250
VertAlign
Vertical alignment.
Definition: draw.h:355
SHARED_PTR< Visual > VisualPtr
Definition: draw.h:270
Vector2(float x, float y)
construct from parameters
Definition: draw.h:125
SHARED_PTR< Font > FontPtr
Definition: draw.h:323
ErrorCode getLastError()
return last error and set the value to draw::NoError
bool operator==(const Point &left, const Point &right)
checks if two points are equal
Set of indexed 2D-primitives.
Definition: draw.h:168
Contiguous sequence of elements.
Definition: draw.h:150
Format
A pixel format.
Definition: draw.h:225
std::unique_ptr< Context > ContextPtr
Definition: draw.h:452
A size in pixel space.
Definition: draw.h:77
Span(const T *ptr, uint32_t count)
constructs from parameters
Definition: draw.h:158
Primitive
A type of primitive.
Definition: draw.h:192
SHARED_PTR< Text > TextPtr
Definition: draw.h:367
Vertex(const Vector2 &position, const Vector2 &uv)
constructs from parameters
Definition: draw.h:182
SHARED_PTR< Image > ImagePtr
Definition: draw.h:247
Size(uint32_t width, uint32_t height)
Constructs from parameters.
Definition: draw.h:85
SHARED_PTR< Shape > ShapePtr
Definition: draw.h:306
Rect(int32_t left, int32_t bottom, int32_t right, int32_t top)
constructs from parameters
Definition: draw.h:106
SHARED_PTR< Geometry > GeometryPtr
Definition: draw.h:207
2D-array of pixels specified format.
Definition: draw.h:217
OpenGL rendering context base interface class.
Definition: draw.h:444
bool operator!=(const Point &left, const Point &right)
checks if two points are not equal
uint32_t count
elements count
Definition: draw.h:155