ManaPlus
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
NullOpenGLGraphics Class Reference

#include <nullopenglgraphics.h>

Inheritance diagram for NullOpenGLGraphics:
Graphics

Public Member Functions

 NullOpenGLGraphics ()
 
 ~NullOpenGLGraphics ()
 
void drawQuadArrayfi (const int size) A_INLINE
 
void drawQuadArrayfi (const GLint *const intVertArray, const GLfloat *const floatTexArray, const int size) A_INLINE
 
void drawQuadArrayii (const int size) A_INLINE
 
void drawQuadArrayii (const GLint *const intVertArray, const GLint *const intTexArray, const int size) A_INLINE
 
void drawLineArrayi (const int size) A_INLINE
 
void drawLineArrayf (const int size) A_INLINE
 
void drawImageRect (int x, int y, int w, int h, const ImageRect &imgRect)
 
void beginDraw ()
 
void endDraw ()
 
void pushClipArea (const Rect &area)
 
void popClipArea ()
 
void drawRescaledImage (const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)
 
void drawPattern (const Image *const image, const int x, const int y, const int w, const int h)
 
void drawPatternInline (const Image *const image, const int x, const int y, const int w, const int h) A_INLINE
 
void drawRescaledPattern (const Image *const image, const int x, const int y, const int w, const int h, const int scaledWidth, const int scaledHeight)
 
void calcPattern (ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const
 
void calcPattern (ImageCollection *const vert, const Image *const image, const int x, const int y, const int w, const int h) const
 
void calcTileVertexes (ImageVertexes *const vert, const Image *const image, int x, int y) const
 
void calcTileCollection (ImageCollection *const vertCol, const Image *const image, int x, int y)
 
void drawTileVertexes (const ImageVertexes *const vert)
 
void drawTileCollection (const ImageCollection *const vertCol)
 
void updateScreen ()
 
void calcWindow (ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)
 
void drawRectangle (const Rect &rect)
 
void fillRectangle (const Rect &rect)
 
void drawPoint (int x, int y)
 
void drawLine (int x1, int y1, int x2, int y2)
 
bool setVideoMode (const int w, const int h, const int scalle, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)
 
void drawImage (const Image *const image, int dstX, int dstY)
 
void copyImage (const Image *const image, int dstX, int dstY)
 
void drawImageCached (const Image *const image, int x, int y)
 
void drawPatternCached (const Image *const image, const int x, const int y, const int w, const int h)
 
void completeCache ()
 
void drawRectangle (const Rect &rect, const bool filled)
 
void drawNet (const int x1, const int y1, const int x2, const int y2, const int width, const int height)
 
int getMemoryUsage ()
 
void updateTextureFormat ()
 
bool isAllowScale () const
 
void clearScreen () const
 
void deleteArrays ()
 
void setColor (const Color &color)
 
void drawVertexes (const OpenGLGraphicsVertexes &ogl) A_INLINE
 
void initArrays (const int vertCount)
 
- Public Member Functions inherited from Graphics
virtual ~Graphics ()
 
void setWindow (SDL_Surface *const window, const int width, const int height)
 
SDL_Surface * getWindow () const
 
void setSync (const bool sync)
 
bool getSync () const
 
bool setFullscreen (const bool fs)
 
virtual bool resizeScreen (const int width, const int height)
 
virtual void restoreContext ()
 
virtual void calcTileSDL (ImageVertexes *const vert, int x, int y) const
 
void setWindowSize (const int width, const int height)
 
int getWidth () const
 
int getHeight () const
 
int getMemoryUsage () const
 
ClipRectgetTopClip () const
 
void setRedraw (const bool n)
 
bool getRedraw () const
 
void setSecure (const bool n)
 
bool getSecure () const
 
int getBpp () const
 
bool getFullScreen () const
 
bool getHWAccel () const
 
bool getDoubleBuffer () const
 
RenderType getOpenGL () const
 
void setNoFrame (const bool n)
 
const std::string & getName () const
 
const ColorgetColor () const
 
int getScale () const
 
void setScale (int scale)
 
virtual void createGLContext (const bool custom)
 
virtual void postInit ()
 
virtual void finalize (ImageCollection *const col)
 
virtual void finalize (ImageVertexes *const vert)
 
virtual void testDraw ()
 
virtual void removeArray (const uint32_t sz, uint32_t *const arr)
 
virtual void screenResized ()
 

Static Public Member Functions

static void dumpSettings ()
 
static void bindTexture (const GLenum target, const GLuint texture)
 
- Static Public Member Functions inherited from Graphics
static void cleanUp ()
 

Static Public Attributes

static GLuint mTextureBinded = 0
 

Protected Member Functions

void enableTexturingAndBlending ()
 
void disableTexturingAndBlending ()
 
void debugBindTexture (const Image *const image)
 
void deleteArraysInternal ()
 
- Protected Member Functions inherited from Graphics
 Graphics ()
 
void setMainFlags (const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)
 
int getOpenGLFlags () const
 
int getSoftwareFlags () const
 
bool setOpenGLMode ()
 
void updateMemoryInfo ()
 
bool videoInfo ()
 
void setOpenGLFlags ()
 

Private Member Functions

void calcImageRect (ImageVertexes *const vert, int x, int y, int w, int h, const ImageRect &imgRect) A_INLINE
 
void calcPatternInline (ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const A_INLINE
 
void calcTileVertexesInline (ImageVertexes *const vert, const Image *const image, int x, int y) const A_INLINE
 
void drawImageInline (const Image *const image, int dstX, int dstY) A_INLINE
 
void setColorAlpha (const float alpha) A_INLINE
 
void restoreColor () A_INLINE
 

Private Attributes

GLfloat * mFloatTexArray
 
GLint * mIntTexArray
 
GLint * mIntVertArray
 
bool mTexture
 
bool mIsByteColor
 
Color mByteColor
 
float mFloatColor
 
int mMaxVertices
 
bool mColorAlpha
 
FBOInfo mFbo
 

Additional Inherited Members

- Public Types inherited from Graphics
enum  Alignment { LEFT = 0, CENTER, RIGHT }
 
- Data Fields inherited from Graphics
int mWidth
 
int mHeight
 
int mActualWidth
 
int mActualHeight
 
- Protected Attributes inherited from Graphics
MStack< ClipRectmClipStack
 
SDL_Surface * mWindow
 
int mBpp
 
bool mAlpha
 
bool mFullscreen
 
bool mHWAccel
 
bool mRedraw
 
bool mDoubleBuffer
 
SDL_Rect mRect
 
bool mSecure
 
RenderType mOpenGL
 
bool mEnableResize
 
bool mNoFrame
 
bool mAllowHighDPI
 
std::string mName
 
int mStartFreeMem
 
bool mSync
 
int mScale
 
Color mColor
 
- Static Protected Attributes inherited from Graphics
static void * mGLContext = 0
 

Detailed Description

Definition at line 55 of file nullopenglgraphics.h.

Constructor & Destructor Documentation

◆ NullOpenGLGraphics()

NullOpenGLGraphics::NullOpenGLGraphics ( )

Definition at line 46 of file nullopenglgraphics.cpp.

References Graphics::mName, Graphics::mOpenGL, and RENDER_NULL.

46  :
47  mFloatTexArray(nullptr),
48  mIntTexArray(nullptr),
49  mIntVertArray(nullptr),
50  mTexture(false),
51  mIsByteColor(false),
52  mByteColor(),
53  mFloatColor(1.0F),
54  mMaxVertices(500),
55  mColorAlpha(false),
56 #ifdef DEBUG_BIND_TEXTURE
57  mOldTexture(),
58  mOldTextureId(0),
59 #endif // DEBUG_BIND_TEXTURE
60  mFbo()
61 {
63  mName = "null OpenGL";
64 }
std::string mName
Definition: graphics.h:548
RenderType mOpenGL
Definition: graphics.h:544

◆ ~NullOpenGLGraphics()

NullOpenGLGraphics::~NullOpenGLGraphics ( )

Definition at line 66 of file nullopenglgraphics.cpp.

References mFloatTexArray, mIntTexArray, and mIntVertArray.

67 {
68  delete [] mFloatTexArray;
69  delete [] mIntTexArray;
70  delete [] mIntVertArray;
71 }

Member Function Documentation

◆ beginDraw()

void NullOpenGLGraphics::beginDraw ( )
virtual

Initializes drawing. Called by the Gui when Gui::draw() is called. It is needed by some implementations of Graphics to perform preparations before drawing. An example of such an implementation is the OpenGLGraphics.

NOTE: You will never need to call this function yourself, unless you use a Graphics object outside of Guichan.

See also
endDraw, Gui::draw

Reimplemented from Graphics.

Definition at line 968 of file nullopenglgraphics.cpp.

References pushClipArea().

Referenced by Actions::doSit().

969 {
970  pushClipArea(Rect(0, 0, 640, 480));
971 }
Definition: rect.h:72
void pushClipArea(const Rect &area)

◆ bindTexture()

void NullOpenGLGraphics::bindTexture ( const GLenum  target,
const GLuint  texture 
)
static

Definition at line 1121 of file nullopenglgraphics.cpp.

References mTextureBinded.

Referenced by drawImageInline(), drawPatternInline(), drawRescaledImage(), drawRescaledPattern(), drawTileCollection(), and drawTileVertexes().

1123 {
1124  if (mTextureBinded != texture)
1125  mTextureBinded = texture;
1126 }
static GLuint mTextureBinded

◆ calcImageRect()

void NullOpenGLGraphics::calcImageRect ( ImageVertexes *const  vert,
int  x,
int  y,
int  w,
int  h,
const ImageRect imgRect 
)
inlineprivate

Definition at line 1214 of file nullopenglgraphics.cpp.

Referenced by calcWindow().

◆ calcPattern() [1/2]

void NullOpenGLGraphics::calcPattern ( ImageVertexes *const  vert,
const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
) const
virtual

Implements Graphics.

Definition at line 586 of file nullopenglgraphics.cpp.

References calcPatternInline(), x, and y.

590 {
591  calcPatternInline(vert, image, x, y, w, h);
592 }
void calcPatternInline(ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const A_INLINE

◆ calcPattern() [2/2]

void NullOpenGLGraphics::calcPattern ( ImageCollection *const  vert,
const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
) const
virtual

Implements Graphics.

Definition at line 771 of file nullopenglgraphics.cpp.

References calcPatternInline(), ImageVertexes::image, x, and y.

775 {
776  if (vertCol == nullptr || image == nullptr)
777  return;
778  ImageVertexes *vert = nullptr;
779  if (vertCol->currentGLImage != image->mGLImage)
780  {
781  vert = new ImageVertexes;
782  vertCol->currentGLImage = image->mGLImage;
783  vertCol->currentVert = vert;
784  vert->image = image;
785  vertCol->draws.push_back(vert);
786  }
787  else
788  {
789  vert = vertCol->currentVert;
790  }
791 
792  calcPatternInline(vert, image, x, y, w, h);
793 }
const Image * image
Definition: imagevertexes.h:47
void calcPatternInline(ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const A_INLINE
GLuint mGLImage
Definition: image.h:182

◆ calcPatternInline()

void NullOpenGLGraphics::calcPatternInline ( ImageVertexes *const  vert,
const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
) const
inlineprivate

Definition at line 594 of file nullopenglgraphics.cpp.

References OpenGLGraphicsVertexes::continueFloatTexArray(), OpenGLGraphicsVertexes::continueIntTexArray(), OpenGLGraphicsVertexes::continueIntVertArray(), OpenGLGraphicsVertexes::continueVp(), mMaxVertices, OpenGLImageHelper::mTextureType, OpenGLGraphicsVertexes::switchFloatTexArray(), OpenGLGraphicsVertexes::switchIntTexArray(), OpenGLGraphicsVertexes::switchIntVertArray(), OpenGLGraphicsVertexes::switchVp(), x, and y.

Referenced by calcPattern().

600 {
601  if (image == nullptr || vert == nullptr)
602  return;
603 
604  const SDL_Rect &imageRect = image->mBounds;
605  const int iw = imageRect.w;
606  const int ih = imageRect.h;
607 
608  if (iw == 0 || ih == 0)
609  return;
610 
611  const int srcX = imageRect.x;
612  const int srcY = imageRect.y;
613  const float tw = static_cast<float>(image->mTexWidth);
614  const float th = static_cast<float>(image->mTexHeight);
615 
616  const unsigned int vLimit = mMaxVertices * 4;
617 
618  OpenGLGraphicsVertexes &ogl = vert->ogl;
619  unsigned int vp = ogl.continueVp();
620 
621  // Draw a set of textured rectangles
622  if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
623  {
624  const float texX1 = static_cast<float>(srcX) / tw;
625  const float texY1 = static_cast<float>(srcY) / th;
626 
627  GLfloat *floatTexArray = ogl.continueFloatTexArray();
628  GLint *intVertArray = ogl.continueIntVertArray();
629 
630  for (int py = 0; py < h; py += ih)
631  {
632  const int height = (py + ih >= h) ? h - py : ih;
633  const int dstY = y + py;
634  const float texY2 = static_cast<float>(srcY + height) / th;
635  for (int px = 0; px < w; px += iw)
636  {
637  const int width = (px + iw >= w) ? w - px : iw;
638  const int dstX = x + px;
639  const float texX2 = static_cast<float>(srcX + width) / tw;
640 
641  floatTexArray[vp + 0] = texX1;
642  floatTexArray[vp + 1] = texY1;
643 
644  floatTexArray[vp + 2] = texX2;
645  floatTexArray[vp + 3] = texY1;
646 
647  floatTexArray[vp + 4] = texX2;
648  floatTexArray[vp + 5] = texY2;
649 
650  floatTexArray[vp + 6] = texX1;
651  floatTexArray[vp + 7] = texY2;
652 
653  intVertArray[vp + 0] = dstX;
654  intVertArray[vp + 1] = dstY;
655 
656  intVertArray[vp + 2] = dstX + width;
657  intVertArray[vp + 3] = dstY;
658 
659  intVertArray[vp + 4] = dstX + width;
660  intVertArray[vp + 5] = dstY + height;
661 
662  intVertArray[vp + 6] = dstX;
663  intVertArray[vp + 7] = dstY + height;
664 
665  vp += 8;
666  if (vp >= vLimit)
667  {
668  floatTexArray = ogl.switchFloatTexArray();
669  intVertArray = ogl.switchIntVertArray();
670  ogl.switchVp(vp);
671  vp = 0;
672  }
673  }
674  }
675  }
676  else
677  {
678  GLint *intTexArray = ogl.continueIntTexArray();
679  GLint *intVertArray = ogl.continueIntVertArray();
680 
681  for (int py = 0; py < h; py += ih)
682  {
683  const int height = (py + ih >= h) ? h - py : ih;
684  const int dstY = y + py;
685  for (int px = 0; px < w; px += iw)
686  {
687  const int width = (px + iw >= w) ? w - px : iw;
688  const int dstX = x + px;
689 
690  intTexArray[vp + 0] = srcX;
691  intTexArray[vp + 1] = srcY;
692 
693  intTexArray[vp + 2] = srcX + width;
694  intTexArray[vp + 3] = srcY;
695 
696  intTexArray[vp + 4] = srcX + width;
697  intTexArray[vp + 5] = srcY + height;
698 
699  intTexArray[vp + 6] = srcX;
700  intTexArray[vp + 7] = srcY + height;
701 
702  intVertArray[vp + 0] = dstX;
703  intVertArray[vp + 1] = dstY;
704 
705  intVertArray[vp + 2] = dstX + width;
706  intVertArray[vp + 3] = dstY;
707 
708  intVertArray[vp + 4] = dstX + width;
709  intVertArray[vp + 5] = dstY + height;
710 
711  intVertArray[vp + 6] = dstX;
712  intVertArray[vp + 7] = dstY + height;
713 
714  vp += 8;
715  if (vp >= vLimit)
716  {
717  intTexArray = ogl.switchIntTexArray();
718  intVertArray = ogl.switchIntVertArray();
719  ogl.switchVp(vp);
720  vp = 0;
721  }
722  }
723  }
724  }
725  ogl.switchVp(vp);
726 }
int mTexHeight
Definition: image.h:184
SDL_Rect mBounds
Definition: image.h:210
OpenGLGraphicsVertexes ogl
Definition: imagevertexes.h:49
int mTexWidth
Definition: image.h:183

◆ calcTileCollection()

void NullOpenGLGraphics::calcTileCollection ( ImageCollection *const  vertCol,
const Image *const  image,
int  x,
int  y 
)
virtual

Implements Graphics.

Definition at line 728 of file nullopenglgraphics.cpp.

References calcTileVertexesInline(), ImageVertexes::image, x, and y.

732 {
733  if (vertCol == nullptr || image == nullptr)
734  return;
735  if (vertCol->currentGLImage != image->mGLImage)
736  {
737  ImageVertexes *const vert = new ImageVertexes;
738  vertCol->currentGLImage = image->mGLImage;
739  vertCol->currentVert = vert;
740  vert->image = image;
741  vertCol->draws.push_back(vert);
742  calcTileVertexesInline(vert, image, x, y);
743  }
744  else
745  {
746  calcTileVertexesInline(vertCol->currentVert, image, x, y);
747  }
748 }
void calcTileVertexesInline(ImageVertexes *const vert, const Image *const image, int x, int y) const A_INLINE
const Image * image
Definition: imagevertexes.h:47
ImageVertexesVector draws
ImageVertexes * currentVert
GLuint mGLImage
Definition: image.h:182

◆ calcTileVertexes()

void NullOpenGLGraphics::calcTileVertexes ( ImageVertexes *const  vert,
const Image *const  image,
int  x,
int  y 
) const
virtual

Implements Graphics.

Definition at line 795 of file nullopenglgraphics.cpp.

References calcTileVertexesInline().

798 {
799  calcTileVertexesInline(vert, image, dstX, dstY);
800 }
void calcTileVertexesInline(ImageVertexes *const vert, const Image *const image, int x, int y) const A_INLINE

◆ calcTileVertexesInline()

void NullOpenGLGraphics::calcTileVertexesInline ( ImageVertexes *const  vert,
const Image *const  image,
int  x,
int  y 
) const
inlineprivate

Definition at line 802 of file nullopenglgraphics.cpp.

References OpenGLGraphicsVertexes::continueFloatTexArray(), OpenGLGraphicsVertexes::continueIntTexArray(), OpenGLGraphicsVertexes::continueIntVertArray(), OpenGLGraphicsVertexes::continueVp(), mMaxVertices, OpenGLImageHelper::mTextureType, OpenGLGraphicsVertexes::switchFloatTexArray(), OpenGLGraphicsVertexes::switchIntTexArray(), OpenGLGraphicsVertexes::switchIntVertArray(), and OpenGLGraphicsVertexes::switchVp().

Referenced by calcTileCollection(), and calcTileVertexes().

808 {
809  const SDL_Rect &imageRect = image->mBounds;
810  const int w = imageRect.w;
811  const int h = imageRect.h;
812 
813  if (w == 0 || h == 0)
814  return;
815 
816  const int srcX = imageRect.x;
817  const int srcY = imageRect.y;
818 
819  const float tw = static_cast<float>(image->mTexWidth);
820  const float th = static_cast<float>(image->mTexHeight);
821 
822  const unsigned int vLimit = mMaxVertices * 4;
823 
824  OpenGLGraphicsVertexes &ogl = vert->ogl;
825 
826 // STD_VECTOR<int> *vps = ogl.getVp();
827  unsigned int vp = ogl.continueVp();
828 
829  // Draw a set of textured rectangles
830  if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
831  {
832  const float texX1 = static_cast<float>(srcX) / tw;
833  const float texY1 = static_cast<float>(srcY) / th;
834 
835  const float texX2 = static_cast<float>(srcX + w) / tw;
836  const float texY2 = static_cast<float>(srcY + h) / th;
837 
838  GLfloat *const floatTexArray = ogl.continueFloatTexArray();
839  GLint *const intVertArray = ogl.continueIntVertArray();
840 
841  floatTexArray[vp + 0] = texX1;
842  floatTexArray[vp + 1] = texY1;
843 
844  floatTexArray[vp + 2] = texX2;
845  floatTexArray[vp + 3] = texY1;
846 
847  floatTexArray[vp + 4] = texX2;
848  floatTexArray[vp + 5] = texY2;
849 
850  floatTexArray[vp + 6] = texX1;
851  floatTexArray[vp + 7] = texY2;
852 
853  intVertArray[vp + 0] = dstX;
854  intVertArray[vp + 1] = dstY;
855 
856  intVertArray[vp + 2] = dstX + w;
857  intVertArray[vp + 3] = dstY;
858 
859  intVertArray[vp + 4] = dstX + w;
860  intVertArray[vp + 5] = dstY + h;
861 
862  intVertArray[vp + 6] = dstX;
863  intVertArray[vp + 7] = dstY + h;
864 
865  vp += 8;
866  if (vp >= vLimit)
867  {
868  ogl.switchFloatTexArray();
869  ogl.switchIntVertArray();
870  ogl.switchVp(vp);
871  vp = 0;
872  }
873  }
874  else
875  {
876  GLint *const intTexArray = ogl.continueIntTexArray();
877  GLint *const intVertArray = ogl.continueIntVertArray();
878 
879  intTexArray[vp + 0] = srcX;
880  intTexArray[vp + 1] = srcY;
881 
882  intTexArray[vp + 2] = srcX + w;
883  intTexArray[vp + 3] = srcY;
884 
885  intTexArray[vp + 4] = srcX + w;
886  intTexArray[vp + 5] = srcY + h;
887 
888  intTexArray[vp + 6] = srcX;
889  intTexArray[vp + 7] = srcY + h;
890 
891  intVertArray[vp + 0] = dstX;
892  intVertArray[vp + 1] = dstY;
893 
894  intVertArray[vp + 2] = dstX + w;
895  intVertArray[vp + 3] = dstY;
896 
897  intVertArray[vp + 4] = dstX + w;
898  intVertArray[vp + 5] = dstY + h;
899 
900  intVertArray[vp + 6] = dstX;
901  intVertArray[vp + 7] = dstY + h;
902 
903  vp += 8;
904  if (vp >= vLimit)
905  {
906  ogl.switchIntTexArray();
907  ogl.switchIntVertArray();
908  ogl.switchVp(vp);
909  vp = 0;
910  }
911  }
912  ogl.switchVp(vp);
913 }
int mTexHeight
Definition: image.h:184
SDL_Rect mBounds
Definition: image.h:210
OpenGLGraphicsVertexes ogl
Definition: imagevertexes.h:49
int mTexWidth
Definition: image.h:183

◆ calcWindow()

void NullOpenGLGraphics::calcWindow ( ImageCollection *const  vertCol,
const int  x,
const int  y,
const int  w,
const int  h,
const ImageRect imgRect 
)
virtual

Implements Graphics.

Definition at line 932 of file nullopenglgraphics.cpp.

References calcImageRect(), ImageVertexes::image, Image::mGLImage, x, and y.

937 {
938  ImageVertexes *vert = nullptr;
939  Image *const image = imgRect.grid[4];
940  if (image == nullptr)
941  return;
942  if (vertCol->currentGLImage != image->mGLImage)
943  {
944  vert = new ImageVertexes;
945  vertCol->currentGLImage = image->mGLImage;
946  vertCol->currentVert = vert;
947  vert->image = image;
948  vertCol->draws.push_back(vert);
949  }
950  else
951  {
952  vert = vertCol->currentVert;
953  }
954  calcImageRect(vert, x, y, w, h, imgRect);
955 }
const Image * image
Definition: imagevertexes.h:47
ImageVertexesVector draws
ImageVertexes * currentVert
Image * grid[9]
Definition: imagerect.h:41
void calcImageRect(ImageVertexes *const vert, int x, int y, int w, int h, const ImageRect &imgRect) A_INLINE
GLuint mGLImage
Definition: image.h:182
Definition: image.h:61

◆ clearScreen()

void NullOpenGLGraphics::clearScreen ( ) const
virtual

Reimplemented from Graphics.

Definition at line 1223 of file nullopenglgraphics.cpp.

References debugBindTexture(), Logger::log(), logger, restrict, and restrict2.

1224 {
1225 }

◆ completeCache()

void NullOpenGLGraphics::completeCache ( )
virtual

Implements Graphics.

Definition at line 215 of file nullopenglgraphics.cpp.

216 {
217 }

◆ copyImage()

void NullOpenGLGraphics::copyImage ( const Image *const  image,
int  dstX,
int  dstY 
)
virtual

Implements Graphics.

Definition at line 173 of file nullopenglgraphics.cpp.

References drawImageInline().

175 {
176  drawImageInline(image, dstX, dstY);
177 }
void drawImageInline(const Image *const image, int dstX, int dstY) A_INLINE

◆ debugBindTexture()

void NullOpenGLGraphics::debugBindTexture ( const Image *const  image)
protected

◆ deleteArrays()

void NullOpenGLGraphics::deleteArrays ( )
virtual

Reimplemented from Graphics.

Definition at line 92 of file nullopenglgraphics.cpp.

93 {
94 }

◆ deleteArraysInternal()

void NullOpenGLGraphics::deleteArraysInternal ( )
protected

◆ disableTexturingAndBlending()

void NullOpenGLGraphics::disableTexturingAndBlending ( )
protected

Definition at line 1044 of file nullopenglgraphics.cpp.

References Graphics::mAlpha, mColorAlpha, mTexture, and mTextureBinded.

Referenced by drawLine(), drawNet(), drawPoint(), and drawRectangle().

1045 {
1046  mTextureBinded = 0;
1047  if (mAlpha && !mColorAlpha)
1048  mAlpha = false;
1049  else if (!mAlpha && mColorAlpha)
1050  mAlpha = true;
1051 
1052  if (mTexture)
1053  mTexture = false;
1054 }
bool mAlpha
Definition: graphics.h:537
static GLuint mTextureBinded

◆ drawImage()

void NullOpenGLGraphics::drawImage ( const Image *const  image,
int  dstX,
int  dstY 
)
virtual

Blits an image onto the screen.

Returns
true if the image was blitted properly false otherwise.

Implements Graphics.

Definition at line 167 of file nullopenglgraphics.cpp.

References drawImageInline().

169 {
170  drawImageInline(image, dstX, dstY);
171 }
void drawImageInline(const Image *const image, int dstX, int dstY) A_INLINE

◆ drawImageCached()

void NullOpenGLGraphics::drawImageCached ( const Image *const  image,
int  x,
int  y 
)
virtual

Implements Graphics.

Definition at line 199 of file nullopenglgraphics.cpp.

203 {
204 }

◆ drawImageInline()

void NullOpenGLGraphics::drawImageInline ( const Image *const  image,
int  dstX,
int  dstY 
)
inlineprivate

Definition at line 179 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawQuad(), enableTexturingAndBlending(), FUNC_BLOCK, OpenGLImageHelper::mTextureType, and setColorAlpha().

Referenced by copyImage(), drawImage(), and drawRescaledImage().

181 {
182  FUNC_BLOCK("Graphics::drawImage", 1)
183  if (image == nullptr)
184  return;
185 
186  setColorAlpha(image->mAlpha);
187 #ifdef DEBUG_BIND_TEXTURE
188  debugBindTexture(image);
189 #endif // DEBUG_BIND_TEXTURE
190 
193 
194  const SDL_Rect &imageRect = image->mBounds;
195  drawQuad(image, imageRect.x, imageRect.y, dstX, dstY,
196  imageRect.w, imageRect.h);
197 }
void debugBindTexture(const Image *const image)
if(!vert) return
static void bindTexture(const GLenum target, const GLuint texture)
bool mAlpha
Definition: graphics.h:537
void setColorAlpha(const float alpha) A_INLINE
static void drawQuad(const Image *const image, const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height)
#define FUNC_BLOCK(name, id)
Definition: perfomance.h:80
GLuint mGLImage
Definition: image.h:182
SDL_Rect mBounds
Definition: image.h:210

◆ drawImageRect()

void NullOpenGLGraphics::drawImageRect ( int  x,
int  y,
int  w,
int  h,
const ImageRect imgRect 
)
virtual

Draws a rectangle using images. 4 corner images, 4 side images and 1 image for the inside.

Implements Graphics.

Definition at line 1206 of file nullopenglgraphics.cpp.

◆ drawLine()

void NullOpenGLGraphics::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual

Ddraws a line.

Parameters
x1The first x coordinate.
y1The first y coordinate.
x2The second x coordinate.
y2The second y coordinate.

Implements Graphics.

Definition at line 1011 of file nullopenglgraphics.cpp.

References disableTexturingAndBlending(), drawLineArrayf(), mFloatTexArray, and restoreColor().

1013 {
1015  restoreColor();
1016 
1017  mFloatTexArray[0] = static_cast<float>(x1) + 0.5F;
1018  mFloatTexArray[1] = static_cast<float>(y1) + 0.5F;
1019  mFloatTexArray[2] = static_cast<float>(x2) + 0.5F;
1020  mFloatTexArray[3] = static_cast<float>(y2) + 0.5F;
1021 
1022  drawLineArrayf(4);
1023 }
void drawLineArrayf(const int size) A_INLINE
void restoreColor() A_INLINE

◆ drawLineArrayf()

void NullOpenGLGraphics::drawLineArrayf ( const int  size)
inline

Definition at line 1176 of file nullopenglgraphics.cpp.

Referenced by drawLine(), and drawNet().

1178 {
1179 #ifdef DEBUG_DRAW_CALLS
1180  mDrawCalls ++;
1181 #endif // DEBUG_DRAW_CALLS
1182 }

◆ drawLineArrayi()

void NullOpenGLGraphics::drawLineArrayi ( const int  size)
inline

Definition at line 1168 of file nullopenglgraphics.cpp.

1170 {
1171 #ifdef DEBUG_DRAW_CALLS
1172  mDrawCalls ++;
1173 #endif // DEBUG_DRAW_CALLS
1174 }

◆ drawNet()

void NullOpenGLGraphics::drawNet ( const int  x1,
const int  y1,
const int  x2,
const int  y2,
const int  width,
const int  height 
)
virtual

Reimplemented from Graphics.

Definition at line 1070 of file nullopenglgraphics.cpp.

References disableTexturingAndBlending(), drawLineArrayf(), mFloatTexArray, mMaxVertices, restoreColor(), x, and y.

1073 {
1074  unsigned int vp = 0;
1075  const unsigned int vLimit = mMaxVertices * 4;
1076 
1078  restoreColor();
1079 
1080  const float xf1 = static_cast<float>(x1);
1081  const float xf2 = static_cast<float>(x2);
1082  const float yf1 = static_cast<float>(y1);
1083  const float yf2 = static_cast<float>(y2);
1084 
1085  for (int y = y1; y < y2; y += height)
1086  {
1087  mFloatTexArray[vp + 0] = xf1;
1088  mFloatTexArray[vp + 1] = static_cast<float>(y);
1089 
1090  mFloatTexArray[vp + 2] = xf2;
1091  mFloatTexArray[vp + 3] = static_cast<float>(y);
1092 
1093  vp += 4;
1094  if (vp >= vLimit)
1095  {
1096  drawLineArrayf(vp);
1097  vp = 0;
1098  }
1099  }
1100 
1101  for (int x = x1; x < x2; x += width)
1102  {
1103  mFloatTexArray[vp + 0] = static_cast<float>(x);
1104  mFloatTexArray[vp + 1] = yf1;
1105 
1106  mFloatTexArray[vp + 2] = static_cast<float>(x);
1107  mFloatTexArray[vp + 3] = yf2;
1108 
1109  vp += 4;
1110  if (vp >= vLimit)
1111  {
1112  drawLineArrayf(vp);
1113  vp = 0;
1114  }
1115  }
1116 
1117  if (vp > 0)
1118  drawLineArrayf(vp);
1119 }
void drawLineArrayf(const int size) A_INLINE
void restoreColor() A_INLINE

◆ drawPattern()

void NullOpenGLGraphics::drawPattern ( const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
)
virtual

Implements Graphics.

Definition at line 250 of file nullopenglgraphics.cpp.

References drawPatternInline(), x, and y.

253 {
254  drawPatternInline(image, x, y, w, h);
255 }
void drawPatternInline(const Image *const image, const int x, const int y, const int w, const int h) A_INLINE

◆ drawPatternCached()

void NullOpenGLGraphics::drawPatternCached ( const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
)
virtual

Implements Graphics.

Definition at line 206 of file nullopenglgraphics.cpp.

212 {
213 }

◆ drawPatternInline()

void NullOpenGLGraphics::drawPatternInline ( const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h 
)
inline

Definition at line 257 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawQuadArrayfi(), drawQuadArrayii(), enableTexturingAndBlending(), FUNC_BLOCK, mFloatTexArray, mIntTexArray, mIntVertArray, mMaxVertices, OpenGLImageHelper::mTextureType, setColorAlpha(), x, and y.

Referenced by drawPattern().

260 {
261  FUNC_BLOCK("Graphics::drawPattern", 1)
262  if (image == nullptr)
263  return;
264 
265  const SDL_Rect &imageRect = image->mBounds;
266  const int srcX = imageRect.x;
267  const int srcY = imageRect.y;
268  const int iw = imageRect.w;
269  const int ih = imageRect.h;
270 
271  if (iw == 0 || ih == 0)
272  return;
273 
274  const float tw = static_cast<float>(image->mTexWidth);
275  const float th = static_cast<float>(image->mTexHeight);
276 
277  setColorAlpha(image->mAlpha);
278 
279 #ifdef DEBUG_BIND_TEXTURE
280  debugBindTexture(image);
281 #endif // DEBUG_BIND_TEXTURE
282 
284 
286 
287  unsigned int vp = 0;
288  const unsigned int vLimit = mMaxVertices * 4;
289  // Draw a set of textured rectangles
290  if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
291  {
292  const float texX1 = static_cast<float>(srcX) / tw;
293  const float texY1 = static_cast<float>(srcY) / th;
294 
295  for (int py = 0; py < h; py += ih)
296  {
297  const int height = (py + ih >= h) ? h - py : ih;
298  const int dstY = y + py;
299  const float texY2 = static_cast<float>(srcY + height) / th;
300  for (int px = 0; px < w; px += iw)
301  {
302  const int width = (px + iw >= w) ? w - px : iw;
303  const int dstX = x + px;
304 
305  const float texX2 = static_cast<float>(srcX + width) / tw;
306 
307  mFloatTexArray[vp + 0] = texX1;
308  mFloatTexArray[vp + 1] = texY1;
309 
310  mFloatTexArray[vp + 2] = texX2;
311  mFloatTexArray[vp + 3] = texY1;
312 
313  mFloatTexArray[vp + 4] = texX2;
314  mFloatTexArray[vp + 5] = texY2;
315 
316  mFloatTexArray[vp + 6] = texX1;
317  mFloatTexArray[vp + 7] = texY2;
318 
319  mIntVertArray[vp + 0] = dstX;
320  mIntVertArray[vp + 1] = dstY;
321 
322  mIntVertArray[vp + 2] = dstX + width;
323  mIntVertArray[vp + 3] = dstY;
324 
325  mIntVertArray[vp + 4] = dstX + width;
326  mIntVertArray[vp + 5] = dstY + height;
327 
328  mIntVertArray[vp + 6] = dstX;
329  mIntVertArray[vp + 7] = dstY + height;
330 
331  vp += 8;
332  if (vp >= vLimit)
333  {
334  drawQuadArrayfi(vp);
335  vp = 0;
336  }
337  }
338  }
339  if (vp > 0)
340  drawQuadArrayfi(vp);
341  }
342  else
343  {
344  for (int py = 0; py < h; py += ih)
345  {
346  const int height = (py + ih >= h) ? h - py : ih;
347  const int dstY = y + py;
348  for (int px = 0; px < w; px += iw)
349  {
350  const int width = (px + iw >= w) ? w - px : iw;
351  const int dstX = x + px;
352 
353  mIntTexArray[vp + 0] = srcX;
354  mIntTexArray[vp + 1] = srcY;
355 
356  mIntTexArray[vp + 2] = srcX + width;
357  mIntTexArray[vp + 3] = srcY;
358 
359  mIntTexArray[vp + 4] = srcX + width;
360  mIntTexArray[vp + 5] = srcY + height;
361 
362  mIntTexArray[vp + 6] = srcX;
363  mIntTexArray[vp + 7] = srcY + height;
364 
365  mIntVertArray[vp + 0] = dstX;
366  mIntVertArray[vp + 1] = dstY;
367 
368  mIntVertArray[vp + 2] = dstX + width;
369  mIntVertArray[vp + 3] = dstY;
370 
371  mIntVertArray[vp + 4] = dstX + width;
372  mIntVertArray[vp + 5] = dstY + height;
373 
374  mIntVertArray[vp + 6] = dstX;
375  mIntVertArray[vp + 7] = dstY + height;
376 
377  vp += 8;
378  if (vp >= vLimit)
379  {
380  drawQuadArrayii(vp);
381  vp = 0;
382  }
383  }
384  }
385  if (vp > 0)
386  drawQuadArrayii(vp);
387  }
388 }
void drawQuadArrayii(const int size) A_INLINE
void debugBindTexture(const Image *const image)
if(!vert) return
static void bindTexture(const GLenum target, const GLuint texture)
void drawQuadArrayfi(const int size) A_INLINE
bool mAlpha
Definition: graphics.h:537
void setColorAlpha(const float alpha) A_INLINE
#define FUNC_BLOCK(name, id)
Definition: perfomance.h:80
GLuint mGLImage
Definition: image.h:182

◆ drawPoint()

void NullOpenGLGraphics::drawPoint ( int  x,
int  y 
)
virtual

Draws a single point/pixel.

Parameters
xThe x coordinate.
yThe y coordinate.

Implements Graphics.

Definition at line 1005 of file nullopenglgraphics.cpp.

References disableTexturingAndBlending(), and restoreColor().

1006 {
1008  restoreColor();
1009 }
void restoreColor() A_INLINE

◆ drawQuadArrayfi() [1/2]

void NullOpenGLGraphics::drawQuadArrayfi ( const int  size)
inline

Definition at line 1128 of file nullopenglgraphics.cpp.

Referenced by drawPatternInline(), drawRescaledPattern(), and drawVertexes().

1130 {
1131 #ifdef DEBUG_DRAW_CALLS
1132  mDrawCalls ++;
1133 #endif // DEBUG_DRAW_CALLS
1134 }

◆ drawQuadArrayfi() [2/2]

void NullOpenGLGraphics::drawQuadArrayfi ( const GLint *const  intVertArray,
const GLfloat *const  floatTexArray,
const int  size 
)
inline

Definition at line 1136 of file nullopenglgraphics.cpp.

1142 {
1143 #ifdef DEBUG_DRAW_CALLS
1144  mDrawCalls ++;
1145 #endif // DEBUG_DRAW_CALLS
1146 }

◆ drawQuadArrayii() [1/2]

void NullOpenGLGraphics::drawQuadArrayii ( const int  size)
inline

Definition at line 1148 of file nullopenglgraphics.cpp.

Referenced by drawPatternInline(), drawRescaledPattern(), and drawVertexes().

1150 {
1151 #ifdef DEBUG_DRAW_CALLS
1152  mDrawCalls ++;
1153 #endif // DEBUG_DRAW_CALLS
1154 }

◆ drawQuadArrayii() [2/2]

void NullOpenGLGraphics::drawQuadArrayii ( const GLint *const  intVertArray,
const GLint *const  intTexArray,
const int  size 
)
inline

Definition at line 1156 of file nullopenglgraphics.cpp.

1162 {
1163 #ifdef DEBUG_DRAW_CALLS
1164  mDrawCalls ++;
1165 #endif // DEBUG_DRAW_CALLS
1166 }

◆ drawRectangle() [1/2]

void NullOpenGLGraphics::drawRectangle ( const Rect rect,
const bool  filled 
)

Definition at line 1056 of file nullopenglgraphics.cpp.

References BLOCK_END, BLOCK_START, disableTexturingAndBlending(), and restoreColor().

1058 {
1059  BLOCK_START("Graphics::drawRectangle")
1061  restoreColor();
1062 
1063 #ifdef DEBUG_DRAW_CALLS
1064  mDrawCalls ++;
1065 #endif // DEBUG_DRAW_CALLS
1066 
1067  BLOCK_END("Graphics::drawRectangle")
1068 }
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
void restoreColor() A_INLINE

◆ drawRectangle() [2/2]

void NullOpenGLGraphics::drawRectangle ( const Rect rectangle)
virtual

Draws a simple, non-filled, rectangle with a one pixel width.

Parameters
rectangleThe rectangle to draw.

Implements Graphics.

Definition at line 1025 of file nullopenglgraphics.cpp.

Referenced by fillRectangle().

1026 {
1027  drawRectangle(rect, false);
1028 }
void drawRectangle(const Rect &rect)

◆ drawRescaledImage()

void NullOpenGLGraphics::drawRescaledImage ( const Image *const  image,
int  dstX,
int  dstY,
const int  desiredWidth,
const int  desiredHeight 
)
virtual

Draws a resclaled version of the image

Implements Graphics.

Definition at line 219 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawImageInline(), drawRescaledQuad(), enableTexturingAndBlending(), FUNC_BLOCK, OpenGLImageHelper::mTextureType, and setColorAlpha().

223 {
224  FUNC_BLOCK("Graphics::drawRescaledImage", 1)
225  if (image == nullptr)
226  return;
227 
228  const SDL_Rect &imageRect = image->mBounds;
229 
230  // Just draw the image normally when no resizing is necessary,
231  if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
232  {
233  drawImageInline(image, dstX, dstY);
234  return;
235  }
236 
237  setColorAlpha(image->mAlpha);
238 #ifdef DEBUG_BIND_TEXTURE
239  debugBindTexture(image);
240 #endif // DEBUG_BIND_TEXTURE
241 
244 
245  // Draw a textured quad.
246  drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
247  imageRect.w, imageRect.h, desiredWidth, desiredHeight);
248 }
void debugBindTexture(const Image *const image)
if(!vert) return
static void bindTexture(const GLenum target, const GLuint texture)
float mAlpha
Definition: image.h:212
void setColorAlpha(const float alpha) A_INLINE
#define FUNC_BLOCK(name, id)
Definition: perfomance.h:80
GLuint mGLImage
Definition: image.h:182
static void drawRescaledQuad(const Image *const image, const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, const int desiredHeight)
void drawImageInline(const Image *const image, int dstX, int dstY) A_INLINE

◆ drawRescaledPattern()

void NullOpenGLGraphics::drawRescaledPattern ( const Image *const  image,
const int  x,
const int  y,
const int  w,
const int  h,
const int  scaledWidth,
const int  scaledHeight 
)
virtual

Draw a pattern based on a rescaled version of the given image...

Implements Graphics.

Definition at line 390 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawQuadArrayfi(), drawQuadArrayii(), enableTexturingAndBlending(), mFloatTexArray, mIntTexArray, mIntVertArray, mMaxVertices, OpenGLImageHelper::mTextureType, setColorAlpha(), x, and y.

395 {
396  if (image == nullptr)
397  return;
398 
399  if (scaledWidth == 0 || scaledHeight == 0)
400  return;
401 
402  const SDL_Rect &imageRect = image->mBounds;
403  const int iw = imageRect.w;
404  const int ih = imageRect.h;
405  if (iw == 0 || ih == 0)
406  return;
407 
408  const int srcX = imageRect.x;
409  const int srcY = imageRect.y;
410 
411  setColorAlpha(image->mAlpha);
412 
413 #ifdef DEBUG_BIND_TEXTURE
414  debugBindTexture(image);
415 #endif // DEBUG_BIND_TEXTURE
416 
418 
420 
421  unsigned int vp = 0;
422  const unsigned int vLimit = mMaxVertices * 4;
423 
424  // Draw a set of textured rectangles
425  if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
426  {
427  const float tw = static_cast<float>(image->mTexWidth);
428  const float th = static_cast<float>(image->mTexHeight);
429 
430  const float texX1 = static_cast<float>(srcX) / tw;
431  const float texY1 = static_cast<float>(srcY) / th;
432 
433  const float tFractionW = iw / tw;
434  const float tFractionH = ih / th;
435 
436  for (int py = 0; py < h; py += scaledHeight)
437  {
438  const int height = (py + scaledHeight >= h)
439  ? h - py : scaledHeight;
440  const int dstY = y + py;
441  const float visibleFractionH = static_cast<float>(height)
442  / scaledHeight;
443  const float texY2 = texY1 + tFractionH * visibleFractionH;
444  for (int px = 0; px < w; px += scaledWidth)
445  {
446  const int width = (px + scaledWidth >= w)
447  ? w - px : scaledWidth;
448  const int dstX = x + px;
449  const float visibleFractionW = static_cast<float>(width)
450  / scaledWidth;
451  const float texX2 = texX1 + tFractionW * visibleFractionW;
452 
453  mFloatTexArray[vp + 0] = texX1;
454  mFloatTexArray[vp + 1] = texY1;
455 
456  mFloatTexArray[vp + 2] = texX2;
457  mFloatTexArray[vp + 3] = texY1;
458 
459  mFloatTexArray[vp + 4] = texX2;
460  mFloatTexArray[vp + 5] = texY2;
461 
462  mFloatTexArray[vp + 6] = texX1;
463  mFloatTexArray[vp + 7] = texY2;
464 
465  mIntVertArray[vp + 0] = dstX;
466  mIntVertArray[vp + 1] = dstY;
467 
468  mIntVertArray[vp + 2] = dstX + width;
469  mIntVertArray[vp + 3] = dstY;
470 
471  mIntVertArray[vp + 4] = dstX + width;
472  mIntVertArray[vp + 5] = dstY + height;
473 
474  mIntVertArray[vp + 6] = dstX;
475  mIntVertArray[vp + 7] = dstY + height;
476 
477  vp += 8;
478  if (vp >= vLimit)
479  {
480  drawQuadArrayfi(vp);
481  vp = 0;
482  }
483  }
484  }
485  if (vp > 0)
486  drawQuadArrayfi(vp);
487  }
488  else
489  {
490  const float scaleFactorW = static_cast<float>(scaledWidth) / iw;
491  const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
492 
493  for (int py = 0; py < h; py += scaledHeight)
494  {
495  const int height = (py + scaledHeight >= h)
496  ? h - py : scaledHeight;
497  const int dstY = y + py;
498  const int scaledY = srcY + height / scaleFactorH;
499  for (int px = 0; px < w; px += scaledWidth)
500  {
501  const int width = (px + scaledWidth >= w)
502  ? w - px : scaledWidth;
503  const int dstX = x + px;
504  const int scaledX = srcX + width / scaleFactorW;
505 
506  mIntTexArray[vp + 0] = srcX;
507  mIntTexArray[vp + 1] = srcY;
508 
509  mIntTexArray[vp + 2] = scaledX;
510  mIntTexArray[vp + 3] = srcY;
511 
512  mIntTexArray[vp + 4] = scaledX;
513  mIntTexArray[vp + 5] = scaledY;
514 
515  mIntTexArray[vp + 6] = srcX;
516  mIntTexArray[vp + 7] = scaledY;
517 
518  mIntVertArray[vp + 0] = dstX;
519  mIntVertArray[vp + 1] = dstY;
520 
521  mIntVertArray[vp + 2] = dstX + width;
522  mIntVertArray[vp + 3] = dstY;
523 
524  mIntVertArray[vp + 4] = dstX + width;
525  mIntVertArray[vp + 5] = dstY + height;
526 
527  mIntVertArray[vp + 6] = dstX;
528  mIntVertArray[vp + 7] = dstY + height;
529 
530  vp += 8;
531  if (vp >= vLimit)
532  {
533  drawQuadArrayii(vp);
534  vp = 0;
535  }
536  }
537  }
538  if (vp > 0)
539  drawQuadArrayii(vp);
540  }
541 }
void drawQuadArrayii(const int size) A_INLINE
void debugBindTexture(const Image *const image)
static void bindTexture(const GLenum target, const GLuint texture)
void drawQuadArrayfi(const int size) A_INLINE
int mTexHeight
Definition: image.h:184
float mAlpha
Definition: image.h:212
void setColorAlpha(const float alpha) A_INLINE
GLuint mGLImage
Definition: image.h:182
SDL_Rect mBounds
Definition: image.h:210
int mTexWidth
Definition: image.h:183

◆ drawTileCollection()

void NullOpenGLGraphics::drawTileCollection ( const ImageCollection *const  vertCol)
virtual

Implements Graphics.

Definition at line 750 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawVertexes(), enableTexturingAndBlending(), ImageVertexes::image, Image::mAlpha, Image::mGLImage, OpenGLImageHelper::mTextureType, ImageVertexes::ogl, and setColorAlpha().

752 {
753  const ImageVertexesVector &draws = vertCol->draws;
754  const ImageCollectionCIter it_end = draws.end();
755  for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
756  {
757  const ImageVertexes *const vert = *it;
758  const Image *const image = vert->image;
759 
760  setColorAlpha(image->mAlpha);
761 #ifdef DEBUG_BIND_TEXTURE
762  debugBindTexture(image);
763 #endif // DEBUG_BIND_TEXTURE
764 
767  drawVertexes(vert->ogl);
768  }
769 }
std::vector< ImageVertexes * > ImageVertexesVector
Definition: imagevertexes.h:55
const Image * image
Definition: imagevertexes.h:47
void debugBindTexture(const Image *const image)
static void bindTexture(const GLenum target, const GLuint texture)
ImageVertexesVector draws
ImageVertexesVector::const_iterator ImageCollectionCIter
Definition: imagevertexes.h:57
float mAlpha
Definition: image.h:212
void setColorAlpha(const float alpha) A_INLINE
void drawVertexes(const OpenGLGraphicsVertexes &ogl) A_INLINE
GLuint mGLImage
Definition: image.h:182
Definition: image.h:61
OpenGLGraphicsVertexes ogl
Definition: imagevertexes.h:49

◆ drawTileVertexes()

void NullOpenGLGraphics::drawTileVertexes ( const ImageVertexes *const  vert)
virtual

Implements Graphics.

Definition at line 915 of file nullopenglgraphics.cpp.

References bindTexture(), debugBindTexture(), drawVertexes(), enableTexturingAndBlending(), Image::mAlpha, Image::mGLImage, OpenGLImageHelper::mTextureType, and setColorAlpha().

917 {
918  if (vert == nullptr)
919  return;
920  const Image *const image = vert->image;
921 
922  setColorAlpha(image->mAlpha);
923 #ifdef DEBUG_BIND_TEXTURE
924  debugBindTexture(image);
925 #endif // DEBUG_BIND_TEXTURE
926 
929  drawVertexes(vert->ogl);
930 }
const Image * image
Definition: imagevertexes.h:47
void debugBindTexture(const Image *const image)
static void bindTexture(const GLenum target, const GLuint texture)
float mAlpha
Definition: image.h:212
void setColorAlpha(const float alpha) A_INLINE
void drawVertexes(const OpenGLGraphicsVertexes &ogl) A_INLINE
GLuint mGLImage
Definition: image.h:182
Definition: image.h:61
OpenGLGraphicsVertexes ogl
Definition: imagevertexes.h:49

◆ drawVertexes()

void NullOpenGLGraphics::drawVertexes ( const OpenGLGraphicsVertexes ogl)
inline

Definition at line 543 of file nullopenglgraphics.cpp.

References drawQuadArrayfi(), drawQuadArrayii(), and OpenGLImageHelper::mTextureType.

Referenced by drawTileCollection(), and drawTileVertexes().

546 {
547  const STD_VECTOR<GLint*> &intVertPool = ogl.mIntVertPool;
548  STD_VECTOR<GLint*>::const_iterator iv;
549  const STD_VECTOR<GLint*>::const_iterator iv_end = intVertPool.end();
550  const STD_VECTOR<int> &vp = ogl.mVp;
551  STD_VECTOR<int>::const_iterator ivp;
552  const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
553 
554  // Draw a set of textured rectangles
555  if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
556  {
557  const STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
558  STD_VECTOR<GLfloat*>::const_iterator ft;
559  const STD_VECTOR<GLfloat*>::const_iterator
560  ft_end = floatTexPool.end();
561 
562  for (iv = intVertPool.begin(), ft = floatTexPool.begin(),
563  ivp = vp.begin();
564  iv != iv_end && ft != ft_end && ivp != ivp_end;
565  ++ iv, ++ ft, ++ ivp)
566  {
567  drawQuadArrayfi(*iv, *ft, *ivp);
568  }
569  }
570  else
571  {
572  const STD_VECTOR<GLint*> &intTexPool = ogl.mIntTexPool;
573  STD_VECTOR<GLint*>::const_iterator it;
574  const STD_VECTOR<GLint*>::const_iterator it_end = intTexPool.end();
575 
576  for (iv = intVertPool.begin(), it = intTexPool.begin(),
577  ivp = vp.begin();
578  iv != iv_end && it != it_end && ivp != ivp_end;
579  ++ iv, ++ it, ++ ivp)
580  {
581  drawQuadArrayii(*iv, *it, *ivp);
582  }
583  }
584 }
void drawQuadArrayii(const int size) A_INLINE
std::vector< GLint * > mIntVertPool
void drawQuadArrayfi(const int size) A_INLINE
std::vector< GLint * > mIntTexPool
std::vector< GLfloat * > mFloatTexPool

◆ dumpSettings()

void NullOpenGLGraphics::dumpSettings ( )
static

Definition at line 1184 of file nullopenglgraphics.cpp.

1185 {
1186 }

◆ enableTexturingAndBlending()

void NullOpenGLGraphics::enableTexturingAndBlending ( )
protected

Definition at line 1035 of file nullopenglgraphics.cpp.

References Graphics::mAlpha, and mTexture.

Referenced by drawImageInline(), drawPatternInline(), drawRescaledImage(), drawRescaledPattern(), drawTileCollection(), and drawTileVertexes().

1036 {
1037  if (!mTexture)
1038  mTexture = true;
1039 
1040  if (!mAlpha)
1041  mAlpha = true;
1042 }
bool mAlpha
Definition: graphics.h:537

◆ endDraw()

void NullOpenGLGraphics::endDraw ( )
virtual

Deinitializes drawing. Called by the Gui when a Gui::draw() is done. done. It should reset any state changes made by beginDraw().

NOTE: You will never need to call this function yourself, unless you use a Graphics object outside of Guichan.

See also
beginDraw, Gui::draw

Reimplemented from Graphics.

Definition at line 973 of file nullopenglgraphics.cpp.

References popClipArea().

974 {
975  popClipArea();
976 }

◆ fillRectangle()

void NullOpenGLGraphics::fillRectangle ( const Rect rect)
virtual

Implements Graphics.

Definition at line 1030 of file nullopenglgraphics.cpp.

References drawRectangle().

1031 {
1032  drawRectangle(rect, true);
1033 }
void drawRectangle(const Rect &rect)

◆ getMemoryUsage()

int NullOpenGLGraphics::getMemoryUsage ( )

◆ initArrays()

void NullOpenGLGraphics::initArrays ( const int  vertCount)
virtual

Reimplemented from Graphics.

Definition at line 73 of file nullopenglgraphics.cpp.

References mFloatTexArray, mIntTexArray, mIntVertArray, mMaxVertices, and vertexBufSize.

74 {
75  mMaxVertices = vertCount;
76  if (mMaxVertices < 500)
77  mMaxVertices = 500;
78  else if (mMaxVertices > 1024)
79  mMaxVertices = 1024;
80 
81  // need alocate small size, after if limit reached reallocate to double size
83  const size_t sz = mMaxVertices * 4 + 30;
84  if (mFloatTexArray == nullptr)
85  mFloatTexArray = new GLfloat[sz];
86  if (mIntTexArray == nullptr)
87  mIntTexArray = new GLint[sz];
88  if (mIntVertArray == nullptr)
89  mIntVertArray = new GLint[sz];
90 }
unsigned int vertexBufSize

◆ isAllowScale()

bool NullOpenGLGraphics::isAllowScale ( ) const
inlinevirtual

Reimplemented from Graphics.

Definition at line 40 of file nullopenglgraphics.h.

55  : public Graphics

◆ popClipArea()

void NullOpenGLGraphics::popClipArea ( )
virtual

Removes the top most clip area from the stack.

Exceptions
Exceptionif the stack is empty.

Reimplemented from Graphics.

Definition at line 997 of file nullopenglgraphics.cpp.

References MStack< T >::empty(), Graphics::mClipStack, and Graphics::popClipArea().

Referenced by endDraw().

998 {
1000 
1001  if (mClipStack.empty())
1002  return;
1003 }
virtual void popClipArea()
Definition: graphics.cpp:738
MStack< ClipRect > mClipStack
Definition: graphics.h:520
bool empty() const
Definition: mstack.h:87

◆ pushClipArea()

void NullOpenGLGraphics::pushClipArea ( const Rect area)
virtual

Pushes a clip area onto the stack. The x and y coordinates in the rectangle is relative to the last pushed clip area. If the new area falls outside the current clip area, it will be clipped as necessary.

If a clip area is outside of the top clip area a clip area with zero width and height will be pushed.

Parameters
areaThe clip area to be pushed onto the stack.

Reimplemented from Graphics.

Definition at line 978 of file nullopenglgraphics.cpp.

References MStack< T >::empty(), Graphics::mClipStack, Graphics::pushClipArea(), MStack< T >::top(), ClipRect::xOffset, and ClipRect::yOffset.

Referenced by beginDraw().

979 {
980  int transX = 0;
981  int transY = 0;
982 
983  if (!mClipStack.empty())
984  {
985  const ClipRect &clipArea = mClipStack.top();
986  transX = -clipArea.xOffset;
987  transY = -clipArea.yOffset;
988  }
989 
991 
992  const ClipRect &clipArea = mClipStack.top();
993  transX += clipArea.xOffset;
994  transY += clipArea.yOffset;
995 }
int yOffset
Definition: cliprect.h:126
int xOffset
Definition: cliprect.h:121
MStack< ClipRect > mClipStack
Definition: graphics.h:520
virtual void pushClipArea(const Rect &area)
Definition: graphics.cpp:676
T & top() const
Definition: mstack.h:72
bool empty() const
Definition: mstack.h:87

◆ restoreColor()

void NullOpenGLGraphics::restoreColor ( )
inlineprivate

Definition at line 1197 of file nullopenglgraphics.cpp.

References mByteColor, Graphics::mColor, and mIsByteColor.

Referenced by drawLine(), drawNet(), drawPoint(), and drawRectangle().

1198 {
1199  if (mIsByteColor && mByteColor == mColor)
1200  return;
1201 
1202  mIsByteColor = true;
1203  mByteColor = mColor;
1204 }
Color mColor
Definition: graphics.h:552

◆ setColor()

void NullOpenGLGraphics::setColor ( const Color color)
inlinevirtual

Reimplemented from Graphics.

Definition at line 27 of file nullopenglgraphics.h.

55  : public Graphics

◆ setColorAlpha()

void NullOpenGLGraphics::setColorAlpha ( const float  alpha)
inlineprivate

Definition at line 1188 of file nullopenglgraphics.cpp.

References mFloatColor, and mIsByteColor.

Referenced by drawImageInline(), drawPatternInline(), drawRescaledImage(), drawRescaledPattern(), drawTileCollection(), and drawTileVertexes().

1189 {
1190  if (!mIsByteColor && mFloatColor == alpha)
1191  return;
1192 
1193  mIsByteColor = false;
1194  mFloatColor = alpha;
1195 }

◆ setVideoMode()

bool NullOpenGLGraphics::setVideoMode ( const int  w,
const int  h,
const int  scale,
const int  bpp,
const bool  fs,
const bool  hwaccel,
const bool  resize,
const bool  noFrame,
const bool  allowHighDPI 
)
virtual

Try to create a window with the given settings.

Implements Graphics.

Definition at line 96 of file nullopenglgraphics.cpp.

References A_NONNULL, A_UNUSED, drawQuad(), restrict, Graphics::setMainFlags(), and Graphics::setOpenGLMode().

104 {
105  setMainFlags(w, h,
106  scale,
107  bpp,
108  fs,
109  hwaccel,
110  resize,
111  noFrame,
112  allowHighDPI);
113 
114  return setOpenGLMode();
115 }
void setMainFlags(const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)
Definition: graphics.cpp:181
bool setOpenGLMode()
Definition: graphics.cpp:282

◆ updateScreen()

void NullOpenGLGraphics::updateScreen ( )
virtual

Updates the screen. This is done by either copying the buffer to the screen or swapping pages.

Implements Graphics.

Definition at line 957 of file nullopenglgraphics.cpp.

References BLOCK_END, and BLOCK_START.

958 {
959  BLOCK_START("Graphics::updateScreen")
960 #ifdef DEBUG_DRAW_CALLS
961  mLastDrawCalls = mDrawCalls;
962  mDrawCalls = 0;
963 #endif // DEBUG_DRAW_CALLS
964 
965  BLOCK_END("Graphics::updateScreen")
966 }
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79

◆ updateTextureFormat()

void NullOpenGLGraphics::updateTextureFormat ( )

Field Documentation

◆ mByteColor

Color NullOpenGLGraphics::mByteColor
private

Definition at line 100 of file nullopenglgraphics.h.

Referenced by restoreColor().

◆ mColorAlpha

bool NullOpenGLGraphics::mColorAlpha
private

Definition at line 103 of file nullopenglgraphics.h.

Referenced by disableTexturingAndBlending().

◆ mFbo

FBOInfo NullOpenGLGraphics::mFbo
private

Definition at line 108 of file nullopenglgraphics.h.

◆ mFloatColor

float NullOpenGLGraphics::mFloatColor
private

Definition at line 101 of file nullopenglgraphics.h.

Referenced by setColorAlpha().

◆ mFloatTexArray

GLfloat* NullOpenGLGraphics::mFloatTexArray
private

◆ mIntTexArray

GLint* NullOpenGLGraphics::mIntTexArray
private

◆ mIntVertArray

GLint* NullOpenGLGraphics::mIntVertArray
private

◆ mIsByteColor

bool NullOpenGLGraphics::mIsByteColor
private

Definition at line 99 of file nullopenglgraphics.h.

Referenced by restoreColor(), and setColorAlpha().

◆ mMaxVertices

int NullOpenGLGraphics::mMaxVertices
private

◆ mTexture

bool NullOpenGLGraphics::mTexture
private

Definition at line 97 of file nullopenglgraphics.h.

Referenced by disableTexturingAndBlending(), and enableTexturingAndBlending().

◆ mTextureBinded

GLuint NullOpenGLGraphics::mTextureBinded = 0
static

Definition at line 49 of file nullopenglgraphics.h.

Referenced by bindTexture(), and disableTexturingAndBlending().


The documentation for this class was generated from the following files: