 |
Gorgon Game Engine
|
Go to the documentation of this file.
5 #include "../Utils/Assert.h"
6 #include "../Geometry/Point3D.h"
7 #include "../Geometry/Transform3D.h"
8 #include "../Geometry/Rectangle.h"
9 #include "../GL/Simple.h"
10 #include "../GL/FrameBuffer.h"
20 Surface(
const Surface &) =
delete;
22 Surface(Surface &&s) {
23 vertices = s.vertices;
27 drawmode = s.drawmode;
33 Surface &operator =(
const Surface &) =
delete;
35 Surface &operator =(Surface &&s) {
36 vertices = s.vertices;
40 drawmode = s.drawmode;
51 source(&source), color(color), drawmode(drawmode) {
91 return source !=
nullptr;
95 GL::Texture TextureID()
const {
96 return source->GetID();
101 return transform*vertices;
105 GL::QuadTextureCoords GetTextureCoords() {
107 return {texture[0], texture[1], texture[2], texture[3]};
109 auto texture=source->GetCoordinates();
110 return {texture[0], texture[1], texture[2], texture[3]};
115 return source->IsPartial();
120 return source->GetMode();
124 RGBAf GetColor()
const {
137 if(texture)
delete[] texture;
144 GL::QuadVertices vertices;
147 const TextureSource *source =
nullptr;
207 swap(color, other.color);
208 swap(tint, other.tint);
209 swap(mode, other.mode);
210 swap(surfaces, other.surfaces);
215 auto otherparent = other.
parent;
221 myind = myparent->
Children.FindLocation(
this);
225 otherind = otherparent->Children.FindLocation(other);
229 myparent->Remove(
this);
230 myparent->Insert(other, myind);
234 otherparent->Remove(other);
235 otherparent->Insert(
this, otherind);
245 surfaces.emplace_back(image, p1, p2, p3, p4, color*this->color, mode);
252 surfaces.emplace_back(p1, p2, p3, p4, color*this->color, mode);
263 surfaces.emplace_back(image, p1, p2, p3, p4, tex1, tex2, tex3, tex4, color*this->color, mode);
274 virtual void Render()
override;
284 Operation op = {Operation::NewMask, surfaces.size()+operations.size()};
285 operations.push_back(op);
310 clippingenabled =
true;
315 clippingenabled =
false;
320 return clippingenabled;
326 std::vector<internal::Surface> surfaces;
327 std::vector<Operation> operations;
329 bool clippingenabled =
false;
DrawMode
Definition: TextureTargets.h:14
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
virtual void Clear() override
Clears drawing buffer, in layer architecture this request only affects the layer itself,...
Definition: Layer.h:269
bool IsClippingEnabled() const
Returns if the clipping is enabled.
Definition: Layer.h:319
Layer(const Geometry::Point &location)
Constructor that places the layer to the given location.
Definition: Layer.h:189
ColorMode
Color modes for images.
Definition: Color.h:16
const Containers::Collection< Layer > & Children
Sub-layers that this layer holds, all the sub-layers are considered to be above current layer.
Definition: Layer.h:475
virtual void SetColor(RGBAf value)
Changes the tint color of the layer, every image pixel will be multiplied by this color.
Definition: Layer.h:296
virtual void Render() override
Render this layer to the GL. This function is used internally and not necessary to be called.
Definition: Layer.cpp:61
T_ Width() const
Calculates and returns the width of the bounds.
Definition: Bounds.h:130
Layer * parent
Parent layer, could be nullptr.
Definition: Layer.h:504
void Swap(Layer &other)
Definition: Layer.h:201
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
T_ Height() const
Calculates and returns the height of the bounds.
Definition: Bounds.h:135
Layer(const Layer &)=delete
Copy constructor is disabled.
virtual Geometry::Size GetTargetSize() const override
Get size of the target.
Definition: Layer.h:301
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f)) override
Prefer using Draw functions of image or animations.
Definition: Layer.h:242
This layer allows drawing texture images on.
Definition: Layer.h:169
Tiling
Details which directions a texture should tile.
Definition: Graphics.h:31
virtual RGBAf GetColor() const
Changes the tint color of the layer, every image pixel will be multiplied by this color.
Definition: Layer.h:299
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
void DisableClipping()
Disables graphics clipping.
Definition: Layer.h:314
Layer()
Constructor that sets the layer to cover entire parent, no matter how big it is.
Definition: Layer.h:186
Geometry::Bounds bounds
Bounds of this layer.
Definition: Layer.h:507
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
Draws a simple texture to the screen.
virtual void SetTintColor(RGBAf value)
Changes the tint color of the layer, every image pixel will be multiplied by this color.
Definition: Layer.h:289
@ Normal
Definition: TextureTargets.h:15
friend void Initialize()
Initializes the filesystem module.
Definition: Filesystem.cpp:14
basic_Point< Float > Pointf
Definition: Point.h:601
This interface defines a class that can be used as a common target for texture based drawing.
Definition: TextureTargets.h:12
Layer(Layer &&other)
Move constructor.
Definition: Layer.h:197
This is a frame buffer object that can be used for render to texture tasks.
Definition: FrameBuffer.h:13
This class is the base class for all layer types.
Definition: Layer.h:79
This class represents a 2D point.
Definition: Point.h:32
Geometry::Bounds GetEffectiveBounds() const
Returns the effective boundaries of the layer.
Definition: Layer.h:423
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
Draws a simple texture to the screen.
void EnableClipping()
Enables graphics clipping from the visible borders of the layer.
Definition: Layer.h:309
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color=RGBAf(1.f)) override
Prefer using Draw functions of image or animations.
Definition: Layer.h:256
@ Graphics
Definition: Template.h:164
virtual void NewMask() override
Queues the start of a new mask. Only one mask buffer exists and it will be cleared and reused.
Definition: Layer.h:283
This interface represents a GL texture source.
Definition: Graphics.h:480
virtual DrawMode GetDrawMode() const override
Get current drawing mode. See Layer page to see available drawing modes.
Definition: Layer.h:277
basic_Size< T_ > GetSize() const
Returns the size of the bounds object.
Definition: Bounds.h:141
Layer(const Geometry::Bounds &bounds)
Initializing constructor.
Definition: Layer.h:181
virtual void Draw(const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f)) override
Prefer using Draw functions of image or animations.
Definition: Layer.h:249
virtual RGBAf GetTintColor() const
Returns the tint color of the layer, every image pixel will be multiplied by this color.
Definition: Layer.h:292
virtual void SetDrawMode(DrawMode mode) override
Change current drawing mode. See Layer page to see available drawing modes.
Definition: Layer.h:280
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Containers::Collection< Layer > children
Child layers that this layer holds, all child layers are considered to be above current layer.
Definition: Layer.h:501
basic_Transform3D< Float > Transform3D
Definition: Transform3D.h:176
bool isvisible
Whether this layer is visible, invisible layers will not be drawn or receive any events.
Definition: Layer.h:511
Geometry::Size GetSize() const
Returns the size of the layer.
Definition: Layer.h:362