Gorgon Game Engine
TextureTargets.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../Graphics.h"
4 #include "Color.h"
5 #include "../Geometry/Point.h"
6 #include "../Geometry/Size.h"
7 #include "../Geometry/Rectangle.h"
8 
9 namespace Gorgon { namespace Graphics {
10 
12  class TextureTarget {
13  public:
14  enum DrawMode {
18  UseMask
19  };
20 
23  virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2,
24  const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color = RGBAf(1.f)) = 0;
25 
27  virtual void Draw(const Geometry::Pointf &p1, const Geometry::Pointf &p2,
28  const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color = RGBAf(1.f)) = 0;
29 
31  virtual void Draw(float x, float y, const Geometry::Sizef &size, RGBAf color = RGBAf(1.f)) {
32  Draw({x, y, size}, color);
33  }
34 
36  virtual void Draw(const Geometry::Pointf &location, float w, float h, RGBAf color = RGBAf(1.f)) {
37  Draw({location, w, h}, color);
38  }
39 
41  virtual void Draw(float x, float y, float w, float h, RGBAf color = RGBAf(1.f)) {
42  Draw({x, y, w, h}, color);
43  }
44 
46  virtual void Draw(int x, int y, int w, int h, RGBAf color = RGBAf(1.f)) {
47  Draw({float(x), float(y), float(w), float(h)}, color);
48  }
49 
51  virtual void Draw(const Geometry::Pointf &location, const Geometry::Sizef &size, RGBAf color = RGBAf(1.f)) {
52  Draw({location, size}, color);
53  }
54 
56  virtual void Draw(const Geometry::Rectanglef &location, RGBAf color = RGBAf(1.f)) {
57  Draw(location.TopLeft(), location.TopRight(), location.BottomRight(), location.BottomLeft(), color);
58  }
59 
61  virtual void Draw(RGBAf color = RGBAf(1.f)) {
62  Draw({0.f, 0.f}, Geometry::Sizef(GetTargetSize()), color);
63  }
64 
67  virtual void Draw(const TextureSource &image,
68  const Geometry::Pointf &p1, const Geometry::Pointf &p2,
69  const Geometry::Pointf &p3, const Geometry::Pointf &p4,
70  const Geometry::Pointf &tex1, const Geometry::Pointf &tex2,
71  const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color = RGBAf(1.f)) = 0;
72 
74  virtual void Draw(const TextureSource &image, const Geometry::Pointf &location, RGBAf color) {
75  Draw(image, {location, image.GetImageSize()}, color);
76  }
77 
79  virtual void Draw(const TextureSource &image, const Geometry::Rectanglef &location, RGBAf color = RGBAf(1.f)) {
80  Draw(image, location.TopLeft(), location.TopRight(), location.BottomLeft(), location.BottomRight(), color);
81  }
82 
84  virtual void Draw(const TextureSource &image, Tiling tiling, const Geometry::Rectanglef &location, RGBAf color = RGBAf(1.f)) = 0;
85 
88  virtual void Clear()=0;
89 
91  virtual Geometry::Size GetTargetSize() const = 0;
92 
94  virtual DrawMode GetDrawMode() const = 0;
95 
97  virtual void SetDrawMode(DrawMode mode) = 0 ;
98 
100  virtual void NewMask() = 0;
101  };
102 
103 } }
Gorgon::Graphics::TextureTarget::DrawMode
DrawMode
Definition: TextureTargets.h:14
Gorgon::Geometry::basic_Rectangle::TopLeft
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
Gorgon::Graphics::TextureTarget::Clear
virtual void Clear()=0
Clears drawing buffer, in layer architecture this request only affects the layer itself,...
Gorgon::Graphics::RGBAf
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
Color.h
Gorgon::Graphics::Tiling
Tiling
Details which directions a texture should tile.
Definition: Graphics.h:31
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::Graphics::TextureTarget::UseMask
@ UseMask
Definition: TextureTargets.h:18
Gorgon::Graphics::TextureTarget::FrameBuffer
@ FrameBuffer
Definition: TextureTargets.h:16
Gorgon::Graphics::TextureTarget::GetTargetSize
virtual Geometry::Size GetTargetSize() const =0
Get size of the target.
Gorgon::Graphics::TextureTarget::Normal
@ Normal
Definition: TextureTargets.h:15
Gorgon::Geometry::basic_Rectangle::TopRight
basic_Point< T_ > TopRight() const
Returns the top right coordinates of the rectangle.
Definition: Rectangle.h:203
Gorgon::Geometry::Sizef
basic_Size< Float > Sizef
Definition: Size.h:388
Gorgon::Graphics::TextureTarget
This interface defines a class that can be used as a common target for texture based drawing.
Definition: TextureTargets.h:12
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Graphics::TextureTarget::Draw
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.
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Gorgon::Graphics::TextureSource
This interface represents a GL texture source.
Definition: Graphics.h:480
Gorgon::Geometry::basic_Rectangle::BottomLeft
basic_Point< T_ > BottomLeft() const
Returns the bottom left coordinates of the rectangle.
Definition: Rectangle.h:208
Gorgon::Geometry::basic_Rectangle::BottomRight
basic_Point< T_ > BottomRight() const
Returns the bottom right coordinates of the rectangle.
Definition: Rectangle.h:213
Gorgon::Graphics::TextureTarget::NewMask
virtual void NewMask()=0
Should queue the start of a new mask. Only one mask buffer exists and it will be cleared and reused.
Gorgon::Graphics::TextureTarget::GetDrawMode
virtual DrawMode GetDrawMode() const =0
Returns current draw mode.
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::Graphics::TextureSource::GetImageSize
virtual Geometry::Size GetImageSize() const =0
Should return the size of the image stored in texture. Not the whole texture size.
Gorgon::Graphics::TextureTarget::SetDrawMode
virtual void SetDrawMode(DrawMode mode)=0
Sets current draw mode.
Gorgon::Graphics::TextureTarget::ToMask
@ ToMask
Definition: TextureTargets.h:17