1 /*
2  * DSFML - The Simple and Fast Multimedia Library for D
3  *
4  * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com)
5  *
6  * This software is provided 'as-is', without any express or implied warranty.
7  * In no event will the authors be held liable for any damages arising from the
8  * use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not claim
15  * that you wrote the original software. If you use this software in a product,
16  * an acknowledgment in the product documentation would be appreciated but is
17  * not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  * misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source distribution
23  *
24  *
25  * DSFML is based on SFML (Copyright Laurent Gomila)
26  */
27 
28 /**
29  * $(U Drawable) is a very simple base interface that allows objects of derived
30  * classes to be drawn to a RenderTarget.
31  *
32  * All you have to do in your derived class is to override the draw virtual
33  * function.
34  *
35  * Note that inheriting from $(DRAWABLE_LINK) is not mandatory, but it allows
36  * this nice syntax `window.draw(object)` rather than `object.draw(window)`,
37  * which is more consistent with other DSFML classes.
38  *
39  * Example:
40  * ---
41  * class MyDrawable : Drawable
42  * {
43  * public:
44  *
45  *     this()
46  *     {
47  *         m_sprite = Sprite();
48  *         m_texture = Texture();
49  *         m_vertices = VertexArray();
50  *
51  *         // additional setup
52  *     }
53  *    ...
54  *
55  *     void draw(RenderTarget target, RenderStates states) const
56  *     {
57  *         // You can draw other high-level objects
58  *         target.draw(m_sprite, states);
59  *
60  *         // ... or use the low-level API
61  *         states.texture = m_texture;
62  *         target.draw(m_vertices, states);
63  *
64  *         // ... or draw with OpenGL directly
65  *         glBegin(GL_QUADS);
66  *         ...
67  *         glEnd();
68  *     }
69  *
70  * private:
71  *     Sprite m_sprite;
72  *     Texture m_texture;
73  *     VertexArray m_vertices;
74  * }
75  * ---
76  *
77  * See_Also:
78  * $(RENDERTARGET_LINK)
79  */
80 module dsfml.graphics.drawable;
81 
82 import dsfml.graphics.rendertarget;
83 import dsfml.graphics.renderstates;
84 
85 /**
86  * Interface for objects that can be drawn to a render target.
87  */
88 interface Drawable
89 {
90     /**
91      * Draw the object to a render target.
92      *
93      * Params:
94      *  		renderTarget =	Render target to draw to
95      *  		renderStates =	Current render states
96      */
97     void draw(RenderTarget renderTarget, RenderStates renderStates);
98 }