Gorgon Game Engine
Graphics.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <algorithm>
4 #include <cmath>
5 #include <stdint.h>
6 #include <string.h>
7 
8 #include "GL.h"
9 #include "Geometry/Point.h"
10 #include "Geometry/Size.h"
11 #include "Geometry/Bounds.h"
12 #include "Geometry/Rectangle.h"
13 
14 #include "Geometry/Transform3D.h"
15 #include "Graphics/Color.h"
16 
17 namespace Gorgon {
18 
19 
22  namespace Graphics {
23 
26  void Initialize();
27 
31  enum class Tiling {
32  None = 0,
33  Horizontal = 1,
34  Vertical = 2,
35  Both = 3,
36  };
37 
39  enum class Orientation {
40  Horizontal = 1,
41  Vertical = 2
42  };
43 
45  inline Tiling Tile(bool horizontal, bool vertical) {
46  return (horizontal ?
47  (vertical ? Tiling::Both : Tiling::Horizontal) :
48  (vertical ? Tiling::Vertical : Tiling::None)
49  );
50  }
51 
53  enum class Alignment {
55  Start = 1,
56 
58  Center = 4,
59 
61  End = 2,
62  };
63 
64 
67  enum class TextAlignment {
69  Left = 8,
70 
72  Center = 32,
73 
75  Right = 16,
76  };
77 
79  enum class Placement {
81  TopLeft = 9,
82 
84  TopCenter = 33,
85 
87  TopRight = 17,
88 
89 
91  MiddleLeft = 12,
92 
94  MiddleCenter = 36,
95 
97  MiddleRight = 20,
98 
99 
101  BottomLeft = 10,
102 
104  BottomCenter = 34,
105 
107  BottomRight = 18,
108  };
109 
111  inline Alignment GetHorizontal(Placement placement) {
112  return Alignment(((int)placement & 56)>>3);
113  }
114 
116  inline Alignment GetVertical(Placement placement) {
117  return Alignment((int)placement & 7);
118  }
119 
124  switch(GetHorizontal(place)) {
125  case Alignment::Start:
126  remainder.Width=0;
127  break;
128  case Alignment::Center:
129  remainder.Width/=2;
130  break;
131  case Alignment::End:
132  break;
133 #ifndef NDEBUG
134  default:
135  throw std::runtime_error("Unknown mode");
136  break;
137 #endif
138  }
139 
140  switch(GetVertical(place)) {
141  case Alignment::Start:
142  remainder.Height=0;
143  break;
144  case Alignment::Center:
145  remainder.Height/=2;
146  break;
147  case Alignment::End:
148  break;
149 #ifndef NDEBUG
150  default:
151  throw std::runtime_error("Unknown mode");
152  break;
153 #endif
154  }
155 
156  return (Geometry::Point)remainder;
157  }
158 
159 
162  public:
164  enum Tiling {
167  Single = 0,
168 
171  Stretch = 2,
172 
178  Tile = 1,
179 
185 
190 
196  };
197 
200 
204 
207 
210  Horizontal(int(tile)&int(Graphics::Tiling::Horizontal) ? Tile : Stretch),
211  Vertical (int(tile)&int(Graphics::Tiling::Vertical) ? Tile : Stretch),
212  Place(p)
213  { }
214 
217  switch(Horizontal) {
218  case Integral_Smaller:
219  objectsize.Width=(area.Width/objectsize.Width)*objectsize.Width;
220  break;
221  case Integral_Fill:
222  objectsize.Width=int(std::ceil(float(area.Width)/objectsize.Width))*objectsize.Width;
223  break;
224  case Integral_Best:
225  objectsize.Width=int(std::round(float(area.Width)/objectsize.Width))*objectsize.Width;
226  break;
227  case Stretch:
228  case Tile:
229  objectsize.Width=area.Width;
230  break;
231  case Single:
232  break;
233 #ifndef NDEBUG
234  default:
235  throw std::runtime_error("Unknown mode");
236  break;
237 #endif
238  }
239 
240  switch(Vertical) {
241  case Integral_Smaller:
242  objectsize.Width=(area.Width/objectsize.Width)*objectsize.Width;
243  break;
244  case Integral_Fill:
245  objectsize.Width=int(std::ceil(float(area.Width)/objectsize.Width))*objectsize.Width;
246  break;
247  case Integral_Best:
248  objectsize.Width=int(std::round(float(area.Width)/objectsize.Width))*objectsize.Width;
249  break;
250  case Stretch:
251  case Tile:
252  objectsize.Height=area.Height;
253  break;
254  case Single:
255  break;
256 #ifndef NDEBUG
257  default:
258  throw std::runtime_error("Unknown mode");
259  break;
260 #endif
261  }
262 
263  return objectsize;
264  }
265 
268  switch(Horizontal) {
269  case Integral_Smaller:
270  objectsize.Width=floor(area.Width/objectsize.Width)*objectsize.Width;
271  break;
272  case Integral_Fill:
273  objectsize.Width=ceil(area.Width/objectsize.Width)*objectsize.Width;
274  break;
275  case Integral_Best:
276  objectsize.Width=round(area.Width/objectsize.Width)*objectsize.Width;
277  break;
278  case Stretch:
279  case Tile:
280  objectsize.Width=area.Width;
281  break;
282  case Single:
283  break;
284 #ifndef NDEBUG
285  default:
286  throw std::runtime_error("Unknown mode");
287  break;
288 #endif
289  }
290 
291  switch(Vertical) {
292  case Integral_Smaller:
293  objectsize.Height=floor(area.Height/objectsize.Height)*objectsize.Height;
294  break;
295  case Integral_Fill:
296  objectsize.Height=ceil(area.Height/objectsize.Height)*objectsize.Height;
297  break;
298  case Integral_Best:
299  objectsize.Height=round(area.Height/objectsize.Height)*objectsize.Height;
300  break;
301  case Stretch:
302  case Tile:
303  objectsize.Height=area.Height;
304  break;
305  case Single:
306  break;
307 #ifndef NDEBUG
308  default:
309  throw std::runtime_error("Unknown mode");
310  break;
311 #endif
312  }
313 
314  return objectsize;
315  }
316 
317 
319  Geometry::Point CalculateOffset(const Geometry::Size &objectsize, const Geometry::Size &area) const {
320  return Graphics::CalculateOffset(Place, area-CalculateSize(objectsize, area));
321  }
322 
323 
325  Geometry::Pointf CalculateOffset(const Geometry::Sizef &objectsize, const Geometry::Sizef &area) const {
326  return Graphics::CalculateOffset(Place, area-CalculateSize(objectsize, area));
327  }
328 
330  Geometry::Rectangle CalculateArea(const Geometry::Size &objectsize, const Geometry::Size &area) const {
331  auto size=CalculateSize(objectsize, area);
332  return{Graphics::CalculateOffset(Place, area-size), size};
333  }
334 
336  Geometry::Rectanglef CalculateArea(const Geometry::Sizef &objectsize, const Geometry::Sizef &area) const {
337  auto size=CalculateSize(objectsize, area);
338  return{Graphics::CalculateOffset(Place, area-size), size};
339  }
340 
342  Geometry::Size CalculateSize(Geometry::Size repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const {
343  switch(Horizontal) {
344  case Integral_Smaller:
345  repeatingsize.Width=((area.Width-fixedsize.Width)/repeatingsize.Width)*repeatingsize.Width+fixedsize.Width;
346  break;
347  case Integral_Fill:
348  repeatingsize.Width=int(std::ceil(float(area.Width-fixedsize.Width)/repeatingsize.Width))*repeatingsize.Width+fixedsize.Width;
349  break;
350  case Integral_Best:
351  repeatingsize.Width=int(std::round(float(area.Width-fixedsize.Width)/repeatingsize.Width))*repeatingsize.Width+fixedsize.Width;
352  break;
353  case Stretch:
354  case Tile:
355  repeatingsize.Width=area.Width;
356  break;
357  case Single:
358  break;
359 #ifndef NDEBUG
360  default:
361  throw std::runtime_error("Unknown mode");
362  break;
363 #endif
364  }
365 
366  switch(Vertical) {
367  case Integral_Smaller:
368  repeatingsize.Height=((area.Height-fixedsize.Height)/repeatingsize.Height)*repeatingsize.Height+fixedsize.Height;
369  break;
370  case Integral_Fill:
371  repeatingsize.Height=int(std::ceil(float(area.Height-fixedsize.Height)/repeatingsize.Height))*repeatingsize.Height+fixedsize.Height;
372  break;
373  case Integral_Best:
374  repeatingsize.Height=int(std::round(float(area.Height-fixedsize.Height)/repeatingsize.Height))*repeatingsize.Height+fixedsize.Height;
375  break;
376  case Stretch:
377  case Tile:
378  repeatingsize.Height=area.Height;
379  break;
380  case Single:
381  break;
382 #ifndef NDEBUG
383  default:
384  throw std::runtime_error("Unknown mode");
385  break;
386 #endif
387  }
388 
389  return repeatingsize;
390  }
391 
393  Geometry::Sizef CalculateSize(Geometry::Sizef repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const {
394  switch(Horizontal) {
395  case Integral_Smaller:
396  repeatingsize.Width=((area.Width-fixedsize.Width)/repeatingsize.Width)*repeatingsize.Width+fixedsize.Width;
397  break;
398  case Integral_Fill:
399  repeatingsize.Width=area.Width-fixedsize.Width/repeatingsize.Width*repeatingsize.Width+fixedsize.Width;
400  break;
401  case Integral_Best:
402  repeatingsize.Width=area.Width-fixedsize.Width/repeatingsize.Width*repeatingsize.Width+fixedsize.Width;
403  break;
404  case Stretch:
405  case Tile:
406  repeatingsize.Width=area.Width;
407  break;
408  case Single:
409  break;
410 #ifndef NDEBUG
411  default:
412  throw std::runtime_error("Unknown mode");
413  break;
414 #endif
415  }
416 
417  switch(Vertical) {
418  case Integral_Smaller:
419  repeatingsize.Width=((area.Width-fixedsize.Width)/repeatingsize.Width)*repeatingsize.Width+fixedsize.Width;
420  break;
421  case Integral_Fill:
422  repeatingsize.Width=area.Width-fixedsize.Width/repeatingsize.Width*repeatingsize.Width+fixedsize.Width;
423  break;
424  case Integral_Best:
425  repeatingsize.Width=area.Width-fixedsize.Width/repeatingsize.Width*repeatingsize.Width+fixedsize.Width;
426  break;
427  case Stretch:
428  case Tile:
429  repeatingsize.Height=area.Height;
430  break;
431  case Single:
432  break;
433 #ifndef NDEBUG
434  default:
435  throw std::runtime_error("Unknown mode");
436  break;
437 #endif
438  }
439 
440  return repeatingsize;
441  }
442 
444  Geometry::Point CalculateOffset(const Geometry::Size &repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const {
445  return Graphics::CalculateOffset(Place, area-CalculateSize(repeatingsize, fixedsize, area));
446  }
447 
449  Geometry::Pointf CalculateOffset(const Geometry::Sizef &repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const {
450  return Graphics::CalculateOffset(Place, area-CalculateSize(repeatingsize, fixedsize, area));
451  }
452 
454  Geometry::Rectangle CalculateArea(const Geometry::Size &repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const {
455  auto size=CalculateSize(repeatingsize, fixedsize, area);
456  return{Graphics::CalculateOffset(Place, area-size), size};
457  }
458 
460  Geometry::Rectangle CalculateArea(const Geometry::Sizef &repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const {
461  auto size=CalculateSize(repeatingsize, fixedsize, area);
462  return{Graphics::CalculateOffset(Place, area-size), size};
463  }
464 
467  }
468 
471 
474 
477  };
478 
481  public:
483  virtual GL::Texture GetID() const = 0;
484 
485  virtual ColorMode GetMode() const = 0;
486 
488  virtual Geometry::Size GetImageSize() const = 0;
489 
491  virtual const Geometry::Pointf *GetCoordinates() const = 0;
492 
495  bool IsPartial() const {
496  return memcmp(GetCoordinates(), fullcoordinates, sizeof(fullcoordinates))!=0;
497  }
498 
499  protected:
502  };
503 
504  namespace internal {
505 
506 
507  extern GL::Texture LastTexture;
508 
509  void ActivateQuadVertices();
510  void DrawQuadVertices();
511 
512  }
513  }
514 }
515 
516 
517 
518 #ifdef fnonona
519 #pragma once
520 
521 #include "GGE.h"
522 #include "OS.h"
523 
524 #include <GL/gl.h>
525 #include <assert.h>
526 #include <stdexcept>
527 #include <string>
528 #include <array>
529 
530 #ifdef WIN32
531 # undef APIENTRY
532 # undef WINGDIAPI
533 #endif
534 
535 #include "../Utils/ManagedBuffer.h"
536 #include "../Utils/Point2D.h"
537 #include "../Utils/Bounds2D.h"
538 #include "../Utils/Rectangle2D.h"
539 #include "../Utils/Size2D.h"
540 #include "../Utils/Logging.h"
541 #include "External/glutil/MatrixStack.h"
542 
543 #ifndef GL_BGR
544 # define GL_BGR 0x80E0
545 # define GL_BGRA 0x80E1
546 #endif
547 
548 #ifndef PI
549 # define PI 3.1415926535898f
550 #endif
551 
552 
554 namespace gge { namespace graphics {
555 
556  extern gge::utils::Logger log;
557 
558  extern glutil::MatrixStack ModelViewMatrixStack;
559  extern glutil::MatrixStack ProjectionMatrixStack;
560 
561 
562  class TextureAttachment {
563  public:
565  TexturePosition *TextureCoords;
567  bool HasOwnTextureCoords;
568  const GLTexture *Texture;
569 
570  TextureAttachment() : HasOwnTextureCoords(false), TextureCoords(NULL), Texture(NULL) {}
571 
573  void DeleteTextureCoords() {
574  if(HasOwnTextureCoords) {
575  HasOwnTextureCoords=false;
576  delete[] TextureCoords;
577  }
578  }
579 
581  void SetTexture(const GLTexture *texture) {
582  DeleteTextureCoords();
583 
584  this->Texture=texture;
585  TextureCoords=const_cast<TexturePosition*>((const TexturePosition*)texture->ImageCoord);
586  }
587 
589  const GLTexture *GetTexture() const {
590  return Texture;
591  }
592 
596  void CreateTextureCoords() {
597  if(!HasOwnTextureCoords) {
598  HasOwnTextureCoords=true;
599  TextureCoords=new TexturePosition[4];
600  }
601  }
602 
603  ~TextureAttachment() {
604  DeleteTextureCoords();
605  }
606  };
607 
610  class BasicSurface {
611  public:
613  VertexPosition VertexCoords[4];
615  TexturePosition *TextureCoords;
617  bool HasOwnTextureCoords;
618 
619  enum DrawMode {
620  Normal,
621  OffscreenAlphaOnly,
622  Offscreen,
623  SetAlpha
624  } Mode;
625 
627  BasicSurface() : Mode(Normal) {
628  Texture=NULL;
629  Alpha=NULL;
630  HasOwnTextureCoords=false;
631  TextureCoords=NULL;
632  VertexCoords[0].z=0;
633  VertexCoords[1].z=0;
634  VertexCoords[2].z=0;
635  VertexCoords[3].z=0;
636  }
637 
639  BasicSurface(GLTexture *texture) {
640  this->Texture=texture;
641  TextureCoords=texture->ImageCoord;
642 
643  HasOwnTextureCoords=false;
644  }
645 
647  void DeleteTextureCoords() {
648  if(HasOwnTextureCoords) {
649  HasOwnTextureCoords=false;
650  delete[] TextureCoords;
651  }
652  }
653 
655  void SetTexture(const GLTexture *texture) {
656  DeleteTextureCoords();
657 
658  this->Texture=texture;
659  TextureCoords=const_cast<TexturePosition*>((const TexturePosition*)texture->ImageCoord);
660 
661  if(Alpha) {
662  delete Alpha;
663  Alpha=NULL;
664  }
665  }
666 
668  const GLTexture *GetTexture() const {
669  return Texture;
670  }
671 
675  void CreateTextureCoords() {
676  if(!HasOwnTextureCoords) {
677  HasOwnTextureCoords=true;
678  TextureCoords=new TexturePosition[4];
679  }
680  }
681 
683  ~BasicSurface() {
684  if(HasOwnTextureCoords && TextureCoords)
685  delete[] TextureCoords;
686  }
687 
688  TextureAttachment *Alpha;
689 
690  protected:
692  const GLTexture *Texture;
693  };
694 
695  std::array<float,24> GetVertexData(const BasicSurface& surface);
696 
697 
698 
699  class SizeController2D {
700  public:
701 
702  enum TilingType {
703  //Should work as Continous if object is sizable
704  Single = B8(00000000),
705  //Should work as Continous if object is sizable
706  Stretch = B8(00000010),
707 
708  /*
709  Integral = B8(00000100),
710  Smaller = B8(00001000),
711  Closest = B8(00010000),
712  Best = B8(00100000),
713  */
714 
715  //An object can either be sizable or tilable,
716  // Careful! there is code to be updated if
717  // integrals and tiles are changed to be different
718  Continous = B8(00000001),
719  Integral_Smaller = B8(00001101),
720  Integral_Fill = B8(00010101),
721  Integral_Best = B8(00100101),
722 
723  Tile_Continous = B8(00000001),
724  Tile_Integral_Smaller = B8(00001101),
725  Tile_Integral_Fill = B8(00010101),
726  Tile_Integral_Best = B8(00100101),
727  } HorizontalTiling, VerticalTiling;
728 
729 
730  explicit SizeController2D(TilingType HorizontalTiling=Single, TilingType VerticalTiling=Single, Alignment::Type Align=Alignment::Middle_Center) :
731  HorizontalTiling(HorizontalTiling), VerticalTiling(VerticalTiling), Align(Align)
732  { }
733  Alignment::Type Align;
734 
735  static const SizeController2D TileFit;
736  static const SizeController2D StretchFit;
737  static const SizeController2D SingleTopLeft;
738  static const SizeController2D SingleBottomRight;
739  static const SizeController2D SingleMiddleCenter;
740 
741  int CalculateWidth(int W, int Increment) const {
742  if(HorizontalTiling==SizeController2D::Tile_Integral_Best) {
743  return (int)utils::Round((double)W/Increment)*Increment;
744  }
745  else if(HorizontalTiling==SizeController2D::Tile_Integral_Smaller) {
746  return (int)std::floor((double)W/Increment)*Increment;
747  }
748  else if(HorizontalTiling==SizeController2D::Tile_Integral_Fill) {
749  return (int)std::ceil((double)W/Increment)*Increment;
750  }
751  else
752  return W;
753  }
754 
755  int CalculateWidth(int W, int Increment, int Overhead) const {
756  if(HorizontalTiling==SizeController2D::Integral_Best) {
757  return (int)utils::Round((double)(W-Overhead)/Increment)*Increment+Overhead;
758  }
759  else if(HorizontalTiling==SizeController2D::Integral_Smaller) {
760  return (int)std::floor((double)(W-Overhead)/Increment)*Increment+Overhead;
761  }
762  else if(HorizontalTiling==SizeController2D::Integral_Fill) {
763  return (int)std::ceil((double)(W-Overhead)/Increment)*Increment+Overhead;
764  }
765  else
766  return W;
767  }
768 
769  int CalculateHeight(int H, int Increment) const {
770  if(VerticalTiling==SizeController2D::Tile_Integral_Best) {
771  return (int)utils::Round((double)H/Increment)*Increment;
772  }
773  else if(VerticalTiling==SizeController2D::Tile_Integral_Smaller) {
774  return (int)std::floor((double)H/Increment)*Increment;
775  }
776  else if(VerticalTiling==SizeController2D::Tile_Integral_Fill) {
777  return (int)std::ceil((double)H/Increment)*Increment;
778  }
779  else
780  return H;
781  }
782 
783  int CalculateHeight(int H, int Increment, int Overhead) const {
784  if(VerticalTiling==SizeController2D::Integral_Best) {
785  return (int)utils::Round((double)(H-Overhead)/Increment)*Increment+Overhead;
786  }
787  else if(VerticalTiling==SizeController2D::Integral_Smaller) {
788  return (int)std::floor((double)(H-Overhead)/Increment)*Increment+Overhead;
789  }
790  else if(VerticalTiling==SizeController2D::Integral_Fill) {
791  return (int)std::ceil((double)(H-Overhead)/Increment)*Increment+Overhead;
792  }
793  else
794  return H;
795  }
796  };
797 
798 
799 
804  os::DeviceHandle Initialize(os::WindowHandle hWnd, int BitDepth, int Width, int Height);
805 
806  namespace system {
807 
809  //RECT makerect(int x, int y, int w, int h);
817  void A8ToA8L8(int Width, int Height, Byte *Source, Byte *Destination);
819  void SetTexture(Byte *data, int cx, int cy, ColorMode::Type mode);
824  GLTexture GenerateTexture(Byte *Image,int Width,int Height,ColorMode::Type Mode);
825  void UpdateTexture(GLTexture TextureID, Byte *Image,ColorMode::Type Mode);
826  void DestroyTexture(GLTexture &texture);
829  GLenum getGLColorMode(ColorMode::Type Mode);
831  void PreRender();
835  void PostRender(os::DeviceHandle Device, os::WindowHandle win);
836 
837  void ResizeGL(int Width, int Height);
838  }
839 
840  extern utils::Size ScreenSize;
841 } }
842 
843 #endif
Gorgon::Graphics::SizeController::CalculateArea
Geometry::Rectangle CalculateArea(const Geometry::Sizef &repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const
Calculates the drawing area of the object according to the tiling and placement rules.
Definition: Graphics.h:460
Gorgon::Graphics::Orientation
Orientation
2D orientation constants
Definition: Graphics.h:39
Gorgon::Graphics::HTMLRendererInternal::Logger
Utils::Logger Logger
Definition: HTMLRenderer.cpp:10
Gorgon::GL::GenerateTexture
Texture GenerateTexture(const Containers::Image &data)
This function generates a texture from the given image data.
Definition: OpenGL.cpp:146
Gorgon::Graphics::SizeController
This class allows control over a sizable object.
Definition: Graphics.h:161
Gorgon::Graphics::Placement::TopRight
@ TopRight
Placed at top right.
Gorgon::Graphics::Alignment::Start
@ Start
Placed at the start of the axis.
Gorgon::Containers::Image
basic_Image< Byte > Image
Definition: Image.h:1364
Gorgon::Graphics::Placement::TopLeft
@ TopLeft
Placed at top left.
Gorgon::Graphics::Tiling::Horizontal
@ Horizontal
Gorgon::Graphics::SizeController::Tiling
Tiling
Controls how a direction is tiled.
Definition: Graphics.h:164
Gorgon::Graphics::TextureSource::IsPartial
bool IsPartial() const
Returns whether this texture uses only a part of the GL::Texture.
Definition: Graphics.h:495
Gorgon::Graphics::ColorMode
ColorMode
Color modes for images.
Definition: Color.h:16
Rectangle.h
contains the Rectangle class
Gorgon::Geometry::Round
Pointf Round(Pointf num)
Performs a rounding operation over a floating point point.
Definition: Point.h:604
OS.h
contains operating system functionality.
Gorgon::UI::MiddleLeft
@ MiddleLeft
Middle left.
Definition: Template.h:48
Gorgon::Graphics::internal::ActivateQuadVertices
void ActivateQuadVertices()
Definition: Graphics.cpp:23
Bounds.h
contains the Bounds class
Point.h
contains point class.
Gorgon::Graphics::Alignment::Center
@ Center
Centered along the axis.
Gorgon::UI::TopCenter
@ TopCenter
Top center.
Definition: Template.h:43
Size.h
contains the Size class
Gorgon::Geometry::basic_Size::Height
T_ Height
Height of this size object.
Definition: Size.h:261
Gorgon::Graphics::SizeController::CalculateOffset
Geometry::Pointf CalculateOffset(const Geometry::Sizef &objectsize, const Geometry::Sizef &area) const
Calculates the size of the object according to the tiling and placement rules.
Definition: Graphics.h:325
Gorgon::Graphics::TextureSource::GetMode
virtual ColorMode GetMode() const =0
Gorgon::Graphics::SizeController::Integral_Best
@ Integral_Best
The drawing is tiled along this axis to cover the given size.
Definition: Graphics.h:195
Gorgon::Graphics::SizeController::CalculateArea
Geometry::Rectanglef CalculateArea(const Geometry::Sizef &objectsize, const Geometry::Sizef &area) const
Calculates the drawing area of the object according to the tiling and placement rules.
Definition: Graphics.h:336
Gorgon::UI::TopLeft
@ TopLeft
Top left.
Definition: Template.h:41
Gorgon::Graphics::Alignment
Alignment
Defines how an object is aligned.
Definition: Graphics.h:53
Gorgon::Graphics::TextAlignment::Left
@ Left
Text is aligned to left.
GL.h
Gorgon::Graphics::SizeController::SizeController
SizeController()
Creates a default size controller which tiles the object from top-left.
Definition: Graphics.h:199
Gorgon::Geometry::Size
basic_Size< int > Size
Definition: Size.h:385
Gorgon::Graphics::Placement
Placement
Defines how an object is placed in a 2D axis system.
Definition: Graphics.h:79
Gorgon::Graphics::TextAlignment::Right
@ Right
Text is aligned to right.
Gorgon::Animation::log
Utils::Logger log
Definition: Animation.cpp:11
Gorgon::Graphics::SizeController::SizeController
SizeController(Tiling h, Tiling v, Placement p=Placement::TopLeft)
Creates a new size controller with the given tiling options and placement.
Definition: Graphics.h:206
Color.h
Gorgon::Input::Keyboard::Keycodes::H
constexpr Key H
Definition: Keyboard.h:87
Gorgon::Graphics::SizeController::Stretch
@ Stretch
The drawing is stretched along this axis to cover the given size.
Definition: Graphics.h:171
Gorgon::Graphics::SizeController::CalculateSize
Geometry::Sizef CalculateSize(Geometry::Sizef objectsize, const Geometry::Sizef &area) const
Calculates the size of the object according to the tiling rules.
Definition: Graphics.h:267
Gorgon::Graphics::Tiling
Tiling
Details which directions a texture should tile.
Definition: Graphics.h:31
Gorgon::Graphics::SizeController::CalculateSize
Geometry::Size CalculateSize(Geometry::Size repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const
Calculates the size of the object according to the tiling rules.
Definition: Graphics.h:342
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::TextureSource::GetCoordinates
virtual const Geometry::Pointf * GetCoordinates() const =0
Should return the coordinates of the texture to be used.
Gorgon::Graphics::Tiling::Vertical
@ Vertical
Gorgon::Graphics::GetHorizontal
Alignment GetHorizontal(Placement placement)
Returns horizontal alignment from a placement.
Definition: Graphics.h:111
Gorgon::Graphics::TextureSource::GetID
virtual GL::Texture GetID() const =0
Should return GL::Texture to be drawn. This could be 0 to denote no texture is to be used.
Gorgon::Graphics::GetVertical
Alignment GetVertical(Placement placement)
Returns vertical alignment from a placement.
Definition: Graphics.h:116
Gorgon::Graphics::internal::DrawQuadVertices
void DrawQuadVertices()
Definition: Graphics.cpp:32
Gorgon::Graphics::TextAlignment::Center
@ Center
Text is aligned to center.
Gorgon::Graphics::SizeController::CalculateSize
Geometry::Size CalculateSize(Geometry::Size objectsize, const Geometry::Size &area) const
Calculates the size of the object according to the tiling rules.
Definition: Graphics.h:216
Gorgon::Graphics::TextAlignment
TextAlignment
Defines how a text is aligned.
Definition: Graphics.h:67
Gorgon::GL::DestroyTexture
void DestroyTexture(Texture texture)
Destroys the given texture.
Definition: OpenGL.cpp:213
Gorgon::UI::BottomCenter
@ BottomCenter
Bottom center.
Definition: Template.h:58
Gorgon::Graphics::SizeController::Horizontal
Tiling Horizontal
Horizontal tiling mode.
Definition: Graphics.h:470
Gorgon::Graphics::SizeController::Place
Placement Place
Placement method.
Definition: Graphics.h:476
Gorgon::Graphics::Tiling::None
@ None
Gorgon::Graphics::internal::LastTexture
GL::Texture LastTexture
Definition: Graphics.cpp:13
Gorgon::Graphics::Orientation::Vertical
@ Vertical
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Graphics::Orientation::Horizontal
@ Horizontal
Gorgon::Graphics::Initialize
void Initialize()
Initializes Graphics module, should be performed after an OpenGL context is created.
Definition: Graphics.cpp:37
Gorgon::UI::MiddleRight
@ MiddleRight
Middle right.
Definition: Template.h:53
Gorgon::Input::Keyboard::Keycodes::W
constexpr Key W
Definition: Keyboard.h:102
Gorgon::Byte
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
Gorgon::Graphics::SizeController::CalculateArea
Geometry::Rectangle CalculateArea(const Geometry::Size &repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const
Calculates the drawing area of the object according to the tiling and placement rules.
Definition: Graphics.h:454
Gorgon::Graphics::SizeController::Integral_Smaller
@ Integral_Smaller
The drawing is tiled along this axis to cover the given size.
Definition: Graphics.h:184
Gorgon::Graphics::SizeController::SizeController
SizeController(Graphics::Tiling tile, Placement p=Placement::TopLeft)
Creates a new size controller with the given tiling options and placement.
Definition: Graphics.h:209
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Gorgon::Graphics::TextureSource
This interface represents a GL texture source.
Definition: Graphics.h:480
Gorgon::GL::UBOBindingPoint::Type
Type
Definition: Shader.h:14
Gorgon::UI::MiddleCenter
@ MiddleCenter
Middle center, using this position ensures that the components will be inside each other.
Definition: Template.h:51
Transform3D.h
Gorgon::Geometry::basic_Size::Width
T_ Width
Width of this size object.
Definition: Size.h:258
Gorgon::Graphics::Alignment::End
@ End
Placed at the end of the axis.
Gorgon::Graphics::SizeController::CalculateOffset
Geometry::Pointf CalculateOffset(const Geometry::Sizef &repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const
Calculates the size of the object according to the tiling and placement rules.
Definition: Graphics.h:449
Gorgon::Graphics::Placement::BottomRight
@ BottomRight
Placed at bottom right.
Gorgon::Graphics::SizeController::CalculateOffset
Geometry::Point CalculateOffset(const Geometry::Size &repeatingsize, const Geometry::Size &fixedsize, const Geometry::Size &area) const
Calculates the size of the object according to the tiling and placement rules.
Definition: Graphics.h:444
Gorgon::Graphics::SizeController::CalculateArea
Geometry::Rectangle CalculateArea(const Geometry::Size &objectsize, const Geometry::Size &area) const
Calculates the drawing area of the object according to the tiling and placement rules.
Definition: Graphics.h:330
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::Graphics::CalculateOffset
Geometry::Point CalculateOffset(Placement place, Geometry::Size remainder)
Returns the offset of the object according to the given placement rule when there is the given remain...
Definition: Graphics.h:123
Gorgon::Graphics::Placement::BottomLeft
@ BottomLeft
Placed at bottom.
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::GL::UpdateTexture
void UpdateTexture(Texture texture, const Containers::Image &data)
Updates the given texture to contain the given data.
Definition: OpenGL.cpp:177
Gorgon::Graphics::SizeController::Tile
@ Tile
The drawing is tiled along this axis to cover the given size.
Definition: Graphics.h:178
Gorgon::Graphics::Tile
Tiling Tile(bool horizontal, bool vertical)
Creates a Tiling class from the given horizontal, vertical tiling info.
Definition: Graphics.h:45
Gorgon::GL::getGLColorMode
GLenum getGLColorMode(Graphics::ColorMode mode)
Definition: OpenGL.cpp:107
Gorgon::ScreenSize
Geometry::Size ScreenSize
Definition: Window.cpp:15
Gorgon::Graphics::SizeController::CalculateSize
Geometry::Sizef CalculateSize(Geometry::Sizef repeatingsize, const Geometry::Sizef &fixedsize, const Geometry::Sizef &area) const
Calculates the size of the object according to the tiling rules.
Definition: Graphics.h:393
Gorgon::Graphics::SizeController::Single
@ Single
The drawing is drawn only once with its original size.
Definition: Graphics.h:167
Gorgon::Graphics::TextureSource::fullcoordinates
static const Geometry::Pointf fullcoordinates[4]
Coordinates that selects the entire texture to be used.
Definition: Graphics.h:501
Gorgon::Graphics::SizeController::Vertical
Tiling Vertical
Vertical tiling mode.
Definition: Graphics.h:473
Gorgon::Graphics::SizeController::GetTiling
Graphics::Tiling GetTiling() const
Definition: Graphics.h:465
Gorgon::GL::TextureUnit::Normal
@ Normal
Definition: Shader.h:15
Gorgon::Graphics::SizeController::CalculateOffset
Geometry::Point CalculateOffset(const Geometry::Size &objectsize, const Geometry::Size &area) const
Calculates the size of the object according to the tiling and placement rules.
Definition: Graphics.h:319
Gorgon::Graphics::SizeController::SizeController
SizeController(Placement p)
Creates a size controller that places a single object to the given placement.
Definition: Graphics.h:203
Gorgon::Graphics::SizeController::Integral_Fill
@ Integral_Fill
The drawing is tiled along this axis to cover the given size.
Definition: Graphics.h:189