OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Draw Class Referenceabstract

#include <C4Draw.h>

Inheritance diagram for C4Draw:
[legend]
Collaboration diagram for C4Draw:
[legend]

Public Types

enum  DrawOperation { OP_POINTS, OP_TRIANGLES }
 
enum  { DEFAULT_MESSAGE_COLOR = 0xffffffff }
 

Public Member Functions

 C4Draw ()=default
 
virtual ~C4Draw ()
 
bool Init (C4AbstractApp *pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
 
virtual void Clear ()
 
virtual void Default ()
 
virtual CStdGLCtxCreateContext (C4Window *, C4AbstractApp *)
 
virtual bool OnResolutionChanged (unsigned int iXRes, unsigned int iYRes)=0
 
bool GetPrimaryClipper (int &rX1, int &rY1, int &rX2, int &rY2)
 
bool SetPrimaryClipper (int iX1, int iY1, int iX2, int iY2)
 
bool SubPrimaryClipper (int iX1, int iY1, int iX2, int iY2)
 
C4Rect GetClipRect () const
 
C4Rect GetOutRect () const
 
bool StorePrimaryClipper ()
 
bool RestorePrimaryClipper ()
 
bool NoPrimaryClipper ()
 
bool ApplyPrimaryClipper (C4Surface *sfcSurface)
 
bool DetachPrimaryClipper (C4Surface *sfcSurface)
 
virtual bool UpdateClipper ()=0
 
bool GetSurfaceSize (C4Surface *sfcSurface, int &iWdt, int &iHgt)
 
void Grayscale (C4Surface *sfcSfc, int32_t iOffset=0)
 
void LockingPrimary ()
 
void PrimaryUnlocked ()
 
virtual bool PrepareMaterial (StdMeshMatManager &mat_manager, StdMeshMaterialLoader &loader, StdMeshMaterial &mat)=0
 
virtual bool PrepareRendering (C4Surface *sfcToSurface)=0
 
virtual bool EnsureMainContextSelected ()=0
 
virtual bool PrepareSpriteShader (C4Shader &shader, const char *name, int ssc, C4GroupSet *pGroups, const char *const *additionalDefines, const char *const *additionalSlices)=0
 
virtual void BlitLandscape (C4Surface *sfcSource, float fx, float fy, C4Surface *sfcTarget, float tx, float ty, float wdt, float hgt)
 
void Blit8Fast (CSurface8 *sfcSource, int fx, int fy, C4Surface *sfcTarget, int tx, int ty, int wdt, int hgt)
 
bool Blit (C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
 
bool BlitUnscaled (C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
 
bool RenderMesh (StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
 
virtual void PerformMesh (StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)=0
 
bool Blit8 (C4Surface *sfcSource, int fx, int fy, int fwdt, int fhgt, C4Surface *sfcTarget, int tx, int ty, int twdt, int thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
 
bool BlitSimple (C4Surface *sfcSource, int fx, int fy, int fwdt, int fhgt, C4Surface *sfcTarget, int tx, int ty, int twdt, int thgt, bool fTransparency=true)
 
bool BlitSurface (C4Surface *sfcSurface, C4Surface *sfcTarget, int tx, int ty, bool fBlitBase)
 
bool BlitSurfaceTile (C4Surface *sfcSurface, C4Surface *sfcTarget, float iToX, float iToY, float iToWdt, float iToHgt, float iOffsetX, float iOffsetY, C4ShaderCall *shader_call)
 
virtual void FillBG (DWORD dwClr=0)=0
 
bool TextOut (const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
 
bool StringOut (const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
 
virtual void PerformMultiPix (C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, C4ShaderCall *shader_call)=0
 
virtual void PerformMultiLines (C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
 
virtual void PerformMultiTris (C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, const C4BltTransform *pTransform, C4TexRef *pTex, C4TexRef *pOverlay, C4TexRef *pNormal, DWORD dwOverlayClrMod, C4ShaderCall *shader_call)=0
 
void DrawBoxDw (C4Surface *sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr)
 
void DrawBoxFade (C4Surface *sfcDest, float iX, float iY, float iWdt, float iHgt, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall *shader_call)
 
void DrawPatternedCircle (C4Surface *sfcDest, int x, int y, int r, BYTE col, C4Pattern &Pattern, CStdPalette &rPal)
 
void DrawFrameDw (C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
 
void DrawQuadDw (C4Surface *sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall *shader_call)
 
void DrawPix (C4Surface *sfcDest, float tx, float ty, DWORD dwCol)
 
void DrawLineDw (C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
 
void DrawCircleDw (C4Surface *sfcTarget, float cx, float cy, float r, DWORD dwClr, float width=1.0f)
 
void SetGamma (float r, float g, float b, int32_t iRampIndex)
 
void ResetGamma ()
 
DWORD ApplyGammaTo (DWORD dwClr)
 
void ActivateBlitModulation (DWORD dwWithClr)
 
void DeactivateBlitModulation ()
 
bool GetBlitModulation (DWORD &rdwColor)
 
void SetBlitMode (DWORD dwBlitMode)
 
void ResetBlitMode ()
 
void SetFoW (const C4FoWRegion *fow)
 
const C4FoWRegionGetFoW () const
 
void SetZoom (float X, float Y, float Zoom)
 
void SetZoom (const ZoomData &zoom)
 
void GetZoom (ZoomData *r)
 
void ApplyZoom (float &X, float &Y)
 
void RemoveZoom (float &X, float &Y)
 
void SetMeshTransform (const StdMeshMatrix *Transform)
 
void SetPerspective (bool fSet)
 
virtual bool RestoreDeviceObjects ()=0
 
virtual bool InvalidateDeviceObjects ()=0
 
virtual bool DeviceReady ()=0
 

Public Attributes

C4AbstractApppApp
 
bool Active
 
float gamma [C4MaxGammaRamps][3]
 
float gammaOut [3]
 
int MaxTexSize {0}
 
C4ScriptUniform scriptUniform
 
float Zoom
 

Static Public Attributes

static constexpr int COLOR_DEPTH = 32
 
static constexpr int COLOR_DEPTH_BYTES = COLOR_DEPTH / 8
 

Protected Member Functions

bool StringOut (const char *szText, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, C4Markup &Markup, CStdFont *pFont, float fZoom)
 
bool CreatePrimaryClipper (unsigned int iXRes, unsigned int iYRes)
 
virtual bool Error (const char *szMsg)
 

Protected Attributes

float fClipX1
 
float fClipY1
 
float fClipX2
 
float fClipY2
 
float fStClipX1
 
float fStClipY1
 
float fStClipX2
 
float fStClipY2
 
int32_t iClipX1
 
int32_t iClipY1
 
int32_t iClipX2
 
int32_t iClipY2
 
bool ClipAll
 
bool PrimaryLocked
 
C4SurfaceRenderTarget
 
bool BlitModulated
 
DWORD BlitModulateClr
 
DWORD dwBlitMode
 
const C4FoWRegionpFoW
 
float ZoomX
 
float ZoomY
 
const StdMeshMatrix * MeshTransform
 
bool fUsePerspective
 

Friends

class C4Surface
 
class C4TexRef
 
class C4Pattern
 

Detailed Description

Definition at line 84 of file C4Draw.h.

Member Enumeration Documentation

anonymous enum
Enumerator
DEFAULT_MESSAGE_COLOR 

Definition at line 167 of file C4Draw.h.

Enumerator
OP_POINTS 
OP_TRIANGLES 

Definition at line 87 of file C4Draw.h.

Constructor & Destructor Documentation

C4Draw::C4Draw ( )
default
virtual C4Draw::~C4Draw ( )
inlinevirtual

Definition at line 93 of file C4Draw.h.

93 { pDraw=nullptr; }
C4Draw * pDraw
Definition: C4Draw.cpp:42

Member Function Documentation

void C4Draw::ActivateBlitModulation ( DWORD  dwWithClr)
inline

Definition at line 188 of file C4Draw.h.

Referenced by C4Sky::Draw(), C4Landscape::Draw(), C4MouseControl::Draw(), C4GraphicsOverlay::Draw(), C4GUI::Dialog::Draw(), C4GUI::Tabular::Sheet::DrawCaption(), C4Viewport::DrawMenu(), C4GraphicsOverlay::DrawPicture(), CStdFont::DrawText(), and C4Object::PrepareDrawing().

188 { BlitModulated=true; BlitModulateClr=dwWithClr; } // modulate following blits with a given color
DWORD BlitModulateClr
Definition: C4Draw.h:109
bool BlitModulated
Definition: C4Draw.h:108

Here is the caller graph for this function:

DWORD C4Draw::ApplyGammaTo ( DWORD  dwClr)

Definition at line 772 of file C4Draw.cpp.

References C4RGB, gammaOut, GetBlueValue, GetGreenValue, and GetRedValue.

773 {
774  return C4RGB(int(pow(float(GetRedValue(dwClr)) / 255.0f, gammaOut[0]) * 255.0),
775  int(pow(float(GetGreenValue(dwClr)) / 255.0f, gammaOut[1]) * 255.0),
776  int(pow(float(GetBlueValue(dwClr)) / 255.0f, gammaOut[2]) * 255.0));
777 }
#define GetGreenValue(rgb)
Definition: StdColors.h:28
float gammaOut[3]
Definition: C4Draw.h:98
#define GetRedValue(rgb)
Definition: StdColors.h:29
#define GetBlueValue(rgb)
Definition: StdColors.h:27
#define C4RGB(r, g, b)
Definition: StdColors.h:26
bool C4Draw::ApplyPrimaryClipper ( C4Surface sfcSurface)

Definition at line 227 of file C4Draw.cpp.

228 {
229  return true;
230 }
void C4Draw::ApplyZoom ( float &  X,
float &  Y 
)

Definition at line 784 of file C4Draw.cpp.

References Zoom, ZoomX, and ZoomY.

Referenced by Blit8Fast(), BlitUnscaled(), C4LandscapeRenderGL::Draw(), C4GUI::Window::Draw(), and C4GUI::Edit::DrawElement().

785 {
786  X = (X - ZoomX) * Zoom + ZoomX;
787  Y = (Y - ZoomY) * Zoom + ZoomY;
788 }
float ZoomY
Definition: C4Draw.h:112
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
#define X(sdl, oc)

Here is the caller graph for this function:

bool C4Draw::Blit ( C4Surface sfcSource,
float  fx,
float  fy,
float  fwdt,
float  fhgt,
C4Surface sfcTarget,
float  tx,
float  ty,
float  twdt,
float  thgt,
bool  fSrcColKey = false,
const C4BltTransform pTransform = nullptr 
)

Definition at line 301 of file C4Draw.cpp.

References BlitUnscaled(), and C4Surface::Scale.

Referenced by BlitLandscape(), BlitSimple(), BlitSurface(), C4FacetSurface::CopyFromSfcMaxSize(), C4Facet::Draw(), C4Object::Draw(), C4Object::DrawFaceImpl(), C4Facet::DrawFullScreen(), C4Facet::DrawT(), CStdFont::DrawText(), C4Object::DrawTopFace(), C4Facet::DrawX(), C4Facet::DrawXFloat(), C4Facet::DrawXR(), C4Facet::DrawXT(), C4MapFolderData::Load(), and C4Game::SaveGameTitle().

304 {
305  return BlitUnscaled(sfcSource, fx * sfcSource->Scale, fy * sfcSource->Scale, fwdt * sfcSource->Scale, fhgt * sfcSource->Scale,
306  sfcTarget, tx, ty, twdt, thgt, fSrcColKey, pTransform);
307 }
int Scale
Definition: C4Surface.h:66
bool BlitUnscaled(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:309

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::Blit8 ( C4Surface sfcSource,
int  fx,
int  fy,
int  fwdt,
int  fhgt,
C4Surface sfcTarget,
int  tx,
int  ty,
int  twdt,
int  thgt,
bool  fSrcColKey = false,
const C4BltTransform pTransform = nullptr 
)

Definition at line 424 of file C4Draw.cpp.

References BlitSimple(), C4Surface::BltPix(), C4Surface::Hgt, C4Surface::Lock(), C4BltTransform::SetAsInv(), C4BltTransform::SetMoveScale(), C4BltTransform::TransformPoint(), C4Surface::Unlock(), and C4Surface::Wdt.

Referenced by BlitUnscaled().

427 {
428  if (!pTransform) return BlitSimple(sfcSource, fx, fy, fwdt, fhgt, sfcTarget, tx, ty, twdt, thgt, fSrcColKey!=false);
429  // safety
430  if (!fwdt || !fhgt) return true;
431  // Lock the surfaces
432  if (!sfcSource->Lock())
433  return false;
434  if (!sfcTarget->Lock())
435  { sfcSource->Unlock(); return false; }
436  // transformed, emulated blit
437  // Calculate transform target rect
438  C4BltTransform Transform;
439  Transform.SetMoveScale(tx-(float)fx*twdt/fwdt, ty-(float)fy*thgt/fhgt, (float) twdt/fwdt, (float) thgt/fhgt);
440  Transform *=* pTransform;
441  C4BltTransform TransformBack;
442  TransformBack.SetAsInv(Transform);
443  auto ttx0=(float)tx, tty0=(float)ty, ttx1=(float)(tx+twdt), tty1=(float)(ty+thgt);
444  auto ttx2=(float)ttx0, tty2=(float)tty1, ttx3=(float)ttx1, tty3=(float)tty0;
445  pTransform->TransformPoint(ttx0, tty0);
446  pTransform->TransformPoint(ttx1, tty1);
447  pTransform->TransformPoint(ttx2, tty2);
448  pTransform->TransformPoint(ttx3, tty3);
449  int ttxMin = std::max<int>((int)floor(std::min(std::min(ttx0, ttx1), std::min(ttx2, ttx3))), 0);
450  int ttxMax = std::min<int>((int)ceil(std::max(std::max(ttx0, ttx1), std::max(ttx2, ttx3))), sfcTarget->Wdt);
451  int ttyMin = std::max<int>((int)floor(std::min(std::min(tty0, tty1), std::min(tty2, tty3))), 0);
452  int ttyMax = std::min<int>((int)ceil(std::max(std::max(tty0, tty1), std::max(tty2, tty3))), sfcTarget->Hgt);
453  // blit within target rect
454  for (int y = ttyMin; y < ttyMax; ++y)
455  for (int x = ttxMin; x < ttxMax; ++x)
456  {
457  float ffx=(float)x, ffy=(float)y;
458  TransformBack.TransformPoint(ffx, ffy);
459  int ifx=static_cast<int>(ffx), ify=static_cast<int>(ffy);
460  if (ifx<fx || ify<fy || ifx>=fx+fwdt || ify>=fy+fhgt) continue;
461  sfcTarget->BltPix(x,y, sfcSource, ifx,ify, !!fSrcColKey);
462  }
463  // Unlock the surfaces
464  sfcSource->Unlock();
465  sfcTarget->Unlock();
466  return true;
467 }
void TransformPoint(float &rX, float &rY) const
int Wdt
Definition: C4Surface.h:65
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
int Hgt
Definition: C4Surface.h:65
bool BlitSimple(C4Surface *sfcSource, int fx, int fy, int fwdt, int fhgt, C4Surface *sfcTarget, int tx, int ty, int twdt, int thgt, bool fTransparency=true)
Definition: C4Draw.cpp:469
void SetMoveScale(float dx, float dy, float sx, float sy)
bool BltPix(int iX, int iY, C4Surface *sfcSource, int iSrcX, int iSrcY, bool fTransparency)
Definition: C4Surface.cpp:591
bool SetAsInv(C4BltTransform &rOfTransform)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::Blit8Fast ( CSurface8 sfcSource,
int  fx,
int  fy,
C4Surface sfcTarget,
int  tx,
int  ty,
int  wdt,
int  hgt 
)

Definition at line 251 of file C4Draw.cpp.

References ApplyZoom(), DwTo4UB(), C4Surface::fPrimary, C4BltVertex::ftx, C4BltVertex::fty, CStdPalette::GetClr(), CSurface8::GetPix(), C4Surface::IsRenderTarget(), C4Surface::Lock(), PerformMultiPix(), CSurface8::pPal, C4Surface::Unlock(), and Zoom.

Referenced by C4Landscape::Draw().

253 {
254  // blit 8bit-sfc
255  // lock surfaces
256  assert(sfcTarget->fPrimary);
257  bool fRender = sfcTarget->IsRenderTarget();
258  if (!fRender) if (!sfcTarget->Lock())
259  { return; }
260 
261  float tfx = tx, tfy = ty, twdt = wdt, thgt = hgt;
262  if (Zoom != 1.0)
263  {
264  ApplyZoom(tfx, tfy);
265  twdt *= Zoom;
266  thgt *= Zoom;
267  }
268 
269  // blit 8 bit pix in batches of 1024 pixels
270  static const int BUF_SIZE = 1024;
271  C4BltVertex* vertices = new C4BltVertex[BUF_SIZE];
272  int bufcnt = 0;
273 
274  for (int ycnt=0; ycnt<thgt; ++ycnt)
275  {
276  for (int xcnt=0; xcnt<twdt; ++xcnt)
277  {
278  BYTE byPix = sfcSource->GetPix(fx+wdt*xcnt/twdt, fy+hgt*ycnt/thgt);
279  DWORD dwClr = byPix ? sfcSource->pPal->GetClr(byPix) : 0x00000000;
280 
281  vertices[bufcnt].ftx = (float)(tx + xcnt / Zoom);
282  vertices[bufcnt].fty = (float)(ty + ycnt / Zoom);
283  DwTo4UB(dwClr, vertices[bufcnt].color);
284  ++bufcnt;
285 
286  if(bufcnt == BUF_SIZE)
287  {
288  PerformMultiPix(sfcTarget, vertices, BUF_SIZE, nullptr);
289  bufcnt = 0;
290  }
291  }
292 
293  }
294  if(bufcnt > 0)
295  PerformMultiPix(sfcTarget, vertices, bufcnt, nullptr);
296  delete[] vertices;
297  // unlock
298  if (!fRender) sfcTarget->Unlock();
299 }
float fty
Definition: C4Draw.h:64
void ApplyZoom(float &X, float &Y)
Definition: C4Draw.cpp:784
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
uint8_t BYTE
BYTE GetPix(int iX, int iY) const
Definition: CSurface8.h:49
DWORD GetClr(BYTE byCol)
Definition: StdColors.h:186
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
virtual void PerformMultiPix(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, C4ShaderCall *shader_call)=0
CStdPalette * pPal
Definition: CSurface8.h:31
float Zoom
Definition: C4Draw.h:116
float ftx
Definition: C4Draw.h:64
bool IsRenderTarget()
Definition: C4Surface.cpp:144
bool fPrimary
Definition: C4Surface.h:89
uint32_t DWORD

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::BlitLandscape ( C4Surface sfcSource,
float  fx,
float  fy,
C4Surface sfcTarget,
float  tx,
float  ty,
float  wdt,
float  hgt 
)
virtual

Definition at line 245 of file C4Draw.cpp.

References Blit().

247 {
248  Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt, false);
249 }
bool Blit(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:301

Here is the call graph for this function:

bool C4Draw::BlitSimple ( C4Surface sfcSource,
int  fx,
int  fy,
int  fwdt,
int  fhgt,
C4Surface sfcTarget,
int  tx,
int  ty,
int  twdt,
int  thgt,
bool  fTransparency = true 
)

Definition at line 469 of file C4Draw.cpp.

References Blit(), C4Surface::BltPix(), C4Surface::Hgt, Inside(), C4Surface::IsRenderTarget(), C4Surface::Lock(), C4Surface::Unlock(), and C4Surface::Wdt.

Referenced by Blit8().

472 {
473  // rendertarget?
474  if (sfcTarget->IsRenderTarget())
475  {
476  return Blit(sfcSource, float(fx), float(fy), float(fwdt), float(fhgt), sfcTarget, float(tx), float(ty), float(twdt), float(thgt), true);
477  }
478  // Object is first stretched to dest rect
479  int xcnt,ycnt,tcx,tcy,cpcx,cpcy;
480  if (!fwdt || !fhgt || !twdt || !thgt) return false;
481  // Lock the surfaces
482  if (!sfcSource->Lock())
483  return false;
484  if (!sfcTarget->Lock())
485  { sfcSource->Unlock(); return false; }
486  // Rectangle centers
487  tcx=twdt/2; tcy=thgt/2;
488  for (ycnt=0; ycnt<thgt; ycnt++)
489  if (Inside(cpcy=ty+tcy-thgt/2+ycnt,0,sfcTarget->Hgt-1))
490  for (xcnt=0; xcnt<twdt; xcnt++)
491  if (Inside(cpcx=tx+tcx-twdt/2+xcnt,0,sfcTarget->Wdt-1))
492  sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
493  // Unlock the surfaces
494  sfcSource->Unlock();
495  sfcTarget->Unlock();
496  return true;
497 }
int Wdt
Definition: C4Surface.h:65
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
int Hgt
Definition: C4Surface.h:65
bool BltPix(int iX, int iY, C4Surface *sfcSource, int iSrcX, int iSrcY, bool fTransparency)
Definition: C4Surface.cpp:591
bool Blit(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:301
bool IsRenderTarget()
Definition: C4Surface.cpp:144
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::BlitSurface ( C4Surface sfcSurface,
C4Surface sfcTarget,
int  tx,
int  ty,
bool  fBlitBase 
)

Definition at line 517 of file C4Draw.cpp.

References Blit(), C4Surface::Hgt, C4Surface::pMainSfc, and C4Surface::Wdt.

Referenced by C4Surface::Copy().

518 {
519  if (fBlitBase)
520  {
521  Blit(sfcSurface, 0.0f, 0.0f, (float)sfcSurface->Wdt, (float)sfcSurface->Hgt, sfcTarget, float(tx), float(ty), float(sfcSurface->Wdt), float(sfcSurface->Hgt), false);
522  return true;
523  }
524  else
525  {
526  if (!sfcSurface) return false;
527  C4Surface *pSfcBase = sfcSurface->pMainSfc;
528  sfcSurface->pMainSfc = nullptr;
529  Blit(sfcSurface, 0.0f, 0.0f, (float)sfcSurface->Wdt, (float)sfcSurface->Hgt, sfcTarget, float(tx), float(ty), float(sfcSurface->Wdt), float(sfcSurface->Hgt), false);
530  sfcSurface->pMainSfc = pSfcBase;
531  return true;
532  }
533 }
int Wdt
Definition: C4Surface.h:65
int Hgt
Definition: C4Surface.h:65
bool Blit(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:301
C4Surface * pMainSfc
Definition: C4Surface.h:79

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::BlitSurfaceTile ( C4Surface sfcSurface,
C4Surface sfcTarget,
float  iToX,
float  iToY,
float  iToWdt,
float  iToHgt,
float  iOffsetX,
float  iOffsetY,
C4ShaderCall shader_call 
)

Definition at line 535 of file C4Draw.cpp.

References C4SF_Tileable, DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, C4BltVertex::ftz, C4Surface::Hgt, C4Surface::IsRenderTarget(), PerformMultiTris(), C4Surface::texture, C4BltVertex::tx, C4BltVertex::ty, and C4Surface::Wdt.

Referenced by C4UpperBoard::Draw(), C4Sky::Draw(), C4Viewport::Draw(), C4GUI::FullscreenDialog::DrawElement(), and C4ViewportList::DrawFullscreenBackground().

536 {
537  // Only direct rendering from single, tileable, texture
538  if (!sfcTarget->IsRenderTarget()) return false;
539  if ((sfcSurface->texture->iFlags & C4SF_Tileable) == 0) return false;
540 
541  // source surface dimensions
542  const float sourceWdt = sfcSurface->Wdt;
543  const float sourceHgt = sfcSurface->Hgt;
544 
545  // vertex positions
546  C4BltVertex vertices[6];
547  vertices[0].ftx = iToX; vertices[0].fty = iToY; vertices[0].ftz = 0.0f;
548  vertices[0].tx = (0.0f + iOffsetX) / sourceWdt; vertices[0].ty = (0.0f + iOffsetY) / sourceHgt;
549  DwTo4UB(0xffffffff, vertices[0].color);
550  vertices[1].ftx = iToX + iToWdt; vertices[1].fty = iToY; vertices[1].ftz = 0.0f;
551  vertices[1].tx = (iToWdt + iOffsetX) / sourceWdt; vertices[1].ty = (0.0f + iOffsetY) / sourceHgt;
552  DwTo4UB(0xffffffff, vertices[1].color);
553  vertices[2].ftx = iToX + iToWdt; vertices[2].fty = iToY + iToHgt; vertices[2].ftz = 0.0f;
554  vertices[2].tx = (iToWdt + iOffsetX) / sourceWdt; vertices[2].ty = (iToHgt + iOffsetY) / sourceHgt;
555  DwTo4UB(0xffffffff, vertices[2].color);
556  vertices[3].ftx = iToX; vertices[3].fty = iToY + iToHgt; vertices[3].ftz = 0.0f;
557  vertices[3].tx = (0.0f + iOffsetX) / sourceWdt; vertices[3].ty = (iToHgt + iOffsetY) / sourceHgt;
558  DwTo4UB(0xffffffff, vertices[3].color);
559  // duplicate vertices
560  vertices[4] = vertices[0]; vertices[5] = vertices[2];
561 
562  // Draw
563  PerformMultiTris(sfcTarget, vertices, 6, nullptr, sfcSurface->texture.get(), nullptr, nullptr, 0, shader_call);
564  return true;
565 }
float fty
Definition: C4Draw.h:64
float ftz
Definition: C4Draw.h:64
int Wdt
Definition: C4Surface.h:65
float tx
Definition: C4Draw.h:62
float ty
Definition: C4Draw.h:62
int Hgt
Definition: C4Surface.h:65
virtual void PerformMultiTris(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, const C4BltTransform *pTransform, C4TexRef *pTex, C4TexRef *pOverlay, C4TexRef *pNormal, DWORD dwOverlayClrMod, C4ShaderCall *shader_call)=0
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
const int C4SF_Tileable
Definition: C4Surface.h:49
std::unique_ptr< C4TexRef > texture
Definition: C4Surface.h:78
float ftx
Definition: C4Draw.h:64
bool IsRenderTarget()
Definition: C4Surface.cpp:144

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::BlitUnscaled ( C4Surface sfcSource,
float  fx,
float  fy,
float  fwdt,
float  fhgt,
C4Surface sfcTarget,
float  tx,
float  ty,
float  twdt,
float  thgt,
bool  fSrcColKey = false,
const C4BltTransform pTransform = nullptr 
)

Definition at line 309 of file C4Draw.cpp.

References ApplyZoom(), Blit8(), ClipAll, C4Surface::ClrByOwnerClr, DwTo4UB(), C4Surface::fPrimary, C4BltVertex::ftx, C4BltVertex::fty, C4TexRef::iSizeX, C4TexRef::iSizeY, C4Surface::IsRenderTarget(), C4Surface::iTexSize, C4BltTransform::mat, PerformMultiTris(), C4Surface::pMainSfc, C4Surface::pNormalSfc, PrepareRendering(), C4BltTransform::Set(), C4Surface::texture, C4BltVertex::tx, C4BltVertex::ty, Zoom, ZoomX, and ZoomY.

Referenced by Blit(), and C4Facet::DrawTUnscaled().

312 {
313  // safety
314  if (!sfcSource || !sfcTarget || !twdt || !thgt || !fwdt || !fhgt) return false;
315  // emulated blit?
316  if (!sfcTarget->IsRenderTarget())
317  {
318  C4BltTransform t;
319  if(pTransform && Zoom != 1.0)
320  {
321  t.Set(pTransform->mat[0]*Zoom, pTransform->mat[1]*Zoom, pTransform->mat[2]*Zoom + ZoomX*(1-Zoom),
322  pTransform->mat[3]*Zoom, pTransform->mat[4]*Zoom, pTransform->mat[5]*Zoom + ZoomY*(1-Zoom),
323  pTransform->mat[6], pTransform->mat[7], pTransform->mat[8]);
324  pTransform = &t;
325  }
326  else if(Zoom != 1.0)
327  {
328  ApplyZoom(tx, ty);
329  twdt *= Zoom;
330  thgt *= Zoom;
331  }
332 
333  return Blit8(sfcSource, int(fx), int(fy), int(fwdt), int(fhgt), sfcTarget, int(tx), int(ty), int(twdt), int(thgt), fSrcColKey, pTransform);
334  }
335 
336  // calc stretch
337  float scaleX = twdt/fwdt;
338  float scaleY = thgt/fhgt;
339  // bound
340  if (ClipAll) return true;
341  // inside screen?
342  if (twdt<=0 || thgt<=0) return false;
343  // prepare rendering to surface
344  if (!PrepareRendering(sfcTarget)) return false;
345  // texture present?
346  if (!sfcSource->texture)
347  {
348  // primary surface?
349  if (sfcSource->fPrimary)
350  {
351  // blit emulated
352  return Blit8(sfcSource, int(fx), int(fy), int(fwdt), int(fhgt), sfcTarget, int(tx), int(ty), int(twdt), int(thgt), fSrcColKey);
353  }
354  return false;
355  }
356  // blit with basesfc?
357  bool fBaseSfc=false;
358  if (sfcSource->pMainSfc) if (sfcSource->pMainSfc->texture) fBaseSfc = true;
359  // get involved texture offsets
360  int iTexSizeX=sfcSource->iTexSize;
361  int iTexSizeY=sfcSource->iTexSize;
362 
363  C4TexRef *pTex = sfcSource->texture.get();
364  // set up blit data
365  C4BltVertex vertices[6];
366  vertices[0].ftx = tx; vertices[0].fty = ty;
367  vertices[1].ftx = tx + twdt; vertices[1].fty = ty;
368  vertices[2].ftx = tx + twdt; vertices[2].fty = ty + thgt;
369  vertices[3].ftx = tx; vertices[3].fty = ty + thgt;
370  vertices[0].tx = fx / pTex->iSizeX; vertices[0].ty = fy / pTex->iSizeY;
371  vertices[1].tx = (fx + fwdt) / pTex->iSizeX; vertices[1].ty = fy / pTex->iSizeY;
372  vertices[2].tx = (fx + fwdt) / pTex->iSizeX; vertices[2].ty = (fy + fhgt) / pTex->iSizeY;
373  vertices[3].tx = fx / pTex->iSizeX; vertices[3].ty = (fy + fhgt) / pTex->iSizeY;
374  DwTo4UB(0xffffffff, vertices[0].color);
375  DwTo4UB(0xffffffff, vertices[1].color);
376  DwTo4UB(0xffffffff, vertices[2].color);
377  DwTo4UB(0xffffffff, vertices[3].color);
378 
379  // duplicate vertices
380  vertices[4] = vertices[0]; vertices[5] = vertices[2];
381 
382  C4TexRef * pBaseTex = pTex;
383  // is there a base-surface to be blitted first?
384  if (fBaseSfc)
385  {
386  // then get this surface as same offset as from other surface
387  // assuming this is only valid as long as there's no texture management,
388  // organizing partially used textures together!
389  pBaseTex = sfcSource->pMainSfc->texture.get();
390  }
391 
392  C4TexRef* pNormalTex = nullptr;
393  if (sfcSource->pNormalSfc)
394  pNormalTex = sfcSource->pNormalSfc->texture.get();
395 
396  // ClrByOwner is always fully opaque
397  const DWORD dwOverlayClrMod = 0xff000000 | sfcSource->ClrByOwnerClr;
398  PerformMultiTris(sfcTarget, vertices, 6, pTransform, pBaseTex, fBaseSfc ? pTex : nullptr, pNormalTex, dwOverlayClrMod, nullptr);
399  // success
400  return true;
401 }
float fty
Definition: C4Draw.h:64
void ApplyZoom(float &X, float &Y)
Definition: C4Draw.cpp:784
float ZoomY
Definition: C4Draw.h:112
float tx
Definition: C4Draw.h:62
int iSizeY
Definition: C4Surface.h:158
DWORD ClrByOwnerClr
Definition: C4Surface.h:81
float ty
Definition: C4Draw.h:62
virtual void PerformMultiTris(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, const C4BltTransform *pTransform, C4TexRef *pTex, C4TexRef *pOverlay, C4TexRef *pNormal, DWORD dwOverlayClrMod, C4ShaderCall *shader_call)=0
int iSizeX
Definition: C4Surface.h:157
virtual bool PrepareRendering(C4Surface *sfcToSurface)=0
C4Surface * pNormalSfc
Definition: C4Surface.h:80
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
void Set(float fA, float fB, float fC, float fD, float fE, float fF, float fG, float fH, float fI)
int iTexSize
Definition: C4Surface.h:68
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
std::unique_ptr< C4TexRef > texture
Definition: C4Surface.h:78
float ftx
Definition: C4Draw.h:64
bool ClipAll
Definition: C4Draw.h:105
bool IsRenderTarget()
Definition: C4Surface.cpp:144
bool fPrimary
Definition: C4Surface.h:89
bool Blit8(C4Surface *sfcSource, int fx, int fy, int fwdt, int fhgt, C4Surface *sfcTarget, int tx, int ty, int twdt, int thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:424
uint32_t DWORD
C4Surface * pMainSfc
Definition: C4Surface.h:79

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::Clear ( )
virtual

Reimplemented in CStdGL.

Definition at line 184 of file C4Draw.cpp.

References Active, BlitModulated, dwBlitMode, and ResetGamma().

Referenced by CStdGL::Clear().

185 {
186  ResetGamma();
187  Active=BlitModulated=false;
188  dwBlitMode = 0;
189 }
bool Active
Definition: C4Draw.h:96
DWORD dwBlitMode
Definition: C4Draw.h:110
bool BlitModulated
Definition: C4Draw.h:108
void ResetGamma()
Definition: C4Draw.cpp:760

Here is the call graph for this function:

Here is the caller graph for this function:

virtual CStdGLCtx* C4Draw::CreateContext ( C4Window ,
C4AbstractApp  
)
inlinevirtual

Reimplemented in CStdGL.

Definition at line 121 of file C4Draw.h.

121 { return nullptr; }
bool C4Draw::CreatePrimaryClipper ( unsigned int  iXRes,
unsigned int  iYRes 
)
protected

Definition at line 507 of file C4Draw.cpp.

References SetPrimaryClipper(), StorePrimaryClipper(), and Zoom.

Referenced by Init(), and CStdGL::OnResolutionChanged().

508 {
509  // simply setup primary viewport
510  // assume no zoom has been set yet
511  assert(Zoom==1.0f);
512  SetPrimaryClipper(0, 0, iXRes - 1, iYRes - 1);
514  return true;
515 }
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:217
float Zoom
Definition: C4Draw.h:116
bool StorePrimaryClipper()
Definition: C4Draw.cpp:203

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DeactivateBlitModulation ( )
inline

Definition at line 189 of file C4Draw.h.

Referenced by C4Sky::Draw(), C4Landscape::Draw(), C4MouseControl::Draw(), C4GraphicsOverlay::Draw(), C4ParticleList::Draw(), C4GUI::Dialog::Draw(), C4GUI::Tabular::Sheet::DrawCaption(), C4Viewport::DrawMenu(), C4GraphicsOverlay::DrawPicture(), CStdFont::DrawText(), and C4Object::FinishedDrawing().

189 { BlitModulated=false; } // stop color modulation of blits
bool BlitModulated
Definition: C4Draw.h:108

Here is the caller graph for this function:

void C4Draw::Default ( )
virtual

Reimplemented in CStdGL.

Definition at line 169 of file C4Draw.cpp.

References Active, BlitModulated, C4ScriptUniform::Clear(), ClipAll, dwBlitMode, fUsePerspective, MeshTransform, pFoW, RenderTarget, ResetGamma(), scriptUniform, Zoom, ZoomX, and ZoomY.

Referenced by CStdNoGfx::CStdNoGfx(), and CStdGL::Default().

170 {
171  RenderTarget=nullptr;
172  ClipAll=false;
173  Active=false;
174  BlitModulated=false;
175  dwBlitMode = 0;
176  ResetGamma();
177  pFoW = nullptr;
178  ZoomX = 0; ZoomY = 0; Zoom = 1;
179  MeshTransform = nullptr;
180  fUsePerspective = false;
182 }
bool Active
Definition: C4Draw.h:96
float ZoomY
Definition: C4Draw.h:112
C4ScriptUniform scriptUniform
Definition: C4Draw.h:100
bool fUsePerspective
Definition: C4Draw.h:114
const C4FoWRegion * pFoW
Definition: C4Draw.h:111
const StdMeshMatrix * MeshTransform
Definition: C4Draw.h:113
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
C4Surface * RenderTarget
Definition: C4Draw.h:107
DWORD dwBlitMode
Definition: C4Draw.h:110
bool ClipAll
Definition: C4Draw.h:105
bool BlitModulated
Definition: C4Draw.h:108
void ResetGamma()
Definition: C4Draw.cpp:760

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::DetachPrimaryClipper ( C4Surface sfcSurface)

Definition at line 232 of file C4Draw.cpp.

233 {
234  return true;
235 }
virtual bool C4Draw::DeviceReady ( )
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4TexRef::C4TexRef(), and C4Surface::Create().

Here is the caller graph for this function:

void C4Draw::DrawBoxDw ( C4Surface sfcDest,
int  iX1,
int  iY1,
int  iX2,
int  iY2,
DWORD  dwClr 
)

Definition at line 846 of file C4Draw.cpp.

References DrawBoxFade(), C4Surface::IsRenderTarget(), C4Surface::Lock(), C4Surface::SetPixDw(), and C4Surface::Unlock().

Referenced by C4LoaderScreen::Draw(), C4Sky::Draw(), C4MessageBoard::Draw(), C4Viewport::Draw(), C4Def::Draw(), C4ScriptGuiWindow::Draw(), C4GUI::FrameDecoration::Draw(), C4GUI::Dialog::Draw(), C4GUI::Screen::Draw(), C4MenuItem::DrawElement(), C4StartupNetListEntry::DrawElement(), C4GUI::GroupBox::DrawElement(), C4GUI::Edit::DrawElement(), C4GUI::ListBox::DrawElement(), C4GUI::Tabular::DrawElement(), C4GUI::TextWindow::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::ComboBox::DrawElement(), C4GUI::Dialog::DrawElement(), and C4GUI::Screen::DrawToolTip().

847 {
848  if (!sfcDest->IsRenderTarget())
849  {
850  // Box on non-render target: Emulate by setting pixels
851  if (!sfcDest->Lock()) return;
852  for (int y = iY1; y <= iY2; ++y)
853  for (int x = iX1; x <= iX2; ++x)
854  sfcDest->SetPixDw(x,y, dwClr);
855  sfcDest->Unlock();
856  }
857  else
858  {
859  DrawBoxFade(sfcDest, float(iX1), float(iY1), float(iX2 - iX1 + 1), float(iY2 - iY1 + 1), dwClr, dwClr, dwClr, dwClr, nullptr);
860  }
861 }
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
bool SetPixDw(int iX, int iY, DWORD dwCol)
Definition: C4Surface.cpp:576
void DrawBoxFade(C4Surface *sfcDest, float iX, float iY, float iWdt, float iHgt, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:830
bool IsRenderTarget()
Definition: C4Surface.cpp:144

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawBoxFade ( C4Surface sfcDest,
float  iX,
float  iY,
float  iWdt,
float  iHgt,
DWORD  dwClr1,
DWORD  dwClr2,
DWORD  dwClr3,
DWORD  dwClr4,
C4ShaderCall shader_call 
)

Definition at line 830 of file C4Draw.cpp.

References DrawQuadDw().

Referenced by C4Sky::Draw(), and DrawBoxDw().

831 {
832  // set vertex buffer data
833  // vertex order:
834  // 0=upper left dwClr1
835  // 1=lower left dwClr3
836  // 2=lower right dwClr4
837  // 3=upper right dwClr2
838  float vtx[8];
839  vtx[0] = iX ; vtx[1] = iY;
840  vtx[2] = iX ; vtx[3] = iY+iHgt;
841  vtx[4] = iX+iWdt; vtx[5] = iY+iHgt;
842  vtx[6] = iX+iWdt; vtx[7] = iY;
843  DrawQuadDw(sfcDest, vtx, dwClr1, dwClr3, dwClr4, dwClr2, shader_call);
844 }
void DrawQuadDw(C4Surface *sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:659

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawCircleDw ( C4Surface sfcTarget,
float  cx,
float  cy,
float  r,
DWORD  dwClr,
float  width = 1.0f 
)

Definition at line 624 of file C4Draw.cpp.

References DwTo4UB(), and PerformMultiLines().

Referenced by C4EditCursor::Draw().

625 {
626  // Draw as line segments
627  int32_t num_lines = 12 + int32_t(r / 10);
628  std::unique_ptr<C4BltVertex[]> vertices(new C4BltVertex[num_lines * 2]);
629  for (int32_t i = 0; i < num_lines; ++i)
630  {
631  float ang = float(i) * 2 * M_PI / num_lines;
632  int32_t iv = i * 2 + 1;
633  vertices[iv].ftx = cx + sin(ang) * r;
634  vertices[iv].fty = cy + cos(ang) * r;
635  DwTo4UB(dwClr, vertices[iv].color);
636  vertices[(iv + 1) % (num_lines * 2)] = vertices[iv];
637  }
638  PerformMultiLines(sfcTarget, vertices.get(), num_lines * 2, width, nullptr);
639 }
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawFrameDw ( C4Surface sfcDest,
int  x1,
int  y1,
int  x2,
int  y2,
DWORD  dwClr,
float  width = 1.0f 
)

Definition at line 641 of file C4Draw.cpp.

References DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and PerformMultiLines().

Referenced by C4TransferZone::Draw(), C4EditCursor::Draw(), C4PathFinderRay::Draw(), C4Object::Draw(), C4ScriptGuiWindow::Draw(), C4GUI::GroupBox::DrawElement(), C4GUI::Edit::DrawElement(), C4GUI::ComboBox::DrawElement(), C4Menu::DrawFrame(), and C4GUI::Screen::DrawToolTip().

642 {
643  C4BltVertex vertices[8];
644  vertices[0].ftx = x1; vertices[0].fty = y1;
645  vertices[1].ftx = x2; vertices[1].fty = y1;
646  vertices[2] = vertices[1];
647  vertices[3].ftx = x2; vertices[3].fty = y2;
648  vertices[4] = vertices[3];
649  vertices[5].ftx = x1; vertices[5].fty = y2;
650  vertices[6] = vertices[5];
651  vertices[7] = vertices[0];
652 
653  for(auto & vertex : vertices)
654  DwTo4UB(dwClr, vertex.color);
655 
656  PerformMultiLines(sfcDest, vertices, 8, width, nullptr);
657 }
float fty
Definition: C4Draw.h:64
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
float ftx
Definition: C4Draw.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawLineDw ( C4Surface sfcTarget,
float  x1,
float  y1,
float  x2,
float  y2,
DWORD  dwClr,
float  width = 1.0f 
)

Definition at line 614 of file C4Draw.cpp.

References DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and PerformMultiLines().

Referenced by C4EditCursor::Draw(), C4PathFinderRay::Draw(), C4Object::Draw(), C4GUI::Element::Draw3DFrame(), C4Chart::DrawElement(), C4GUI::HorizontalLine::DrawElement(), C4GUI::GroupBox::DrawElement(), C4GUI::ListBox::DrawElement(), and C4GUI::Tabular::DrawElement().

615 {
616  C4BltVertex vertices[2];
617  vertices[0].ftx = x1; vertices[0].fty = y1;
618  vertices[1].ftx = x2; vertices[1].fty = y2;
619  DwTo4UB(dwClr, vertices[0].color);
620  DwTo4UB(dwClr, vertices[1].color);
621  PerformMultiLines(sfcTarget, vertices, 2, width, nullptr);
622 }
float fty
Definition: C4Draw.h:64
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
float ftx
Definition: C4Draw.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawPatternedCircle ( C4Surface sfcDest,
int  x,
int  y,
int  r,
BYTE  col,
C4Pattern Pattern,
CStdPalette rPal 
)

Definition at line 675 of file C4Draw.cpp.

References DrawPix(), C4Surface::IsRenderTarget(), C4Surface::Lock(), C4Pattern::PatternClr(), C4Surface::SetPixDw(), and C4Surface::Unlock().

676 {
677  bool fRenderTarget = sfcDest->IsRenderTarget();
678  if (!fRenderTarget) if (!sfcDest->Lock()) return;
679  for (int ycnt = -r; ycnt < r; ycnt++)
680  {
681  int lwdt = (int)sqrt(float(r * r - ycnt * ycnt));
682  // Set line
683  if (fRenderTarget)
684  {
685  for (int xcnt = x - lwdt; xcnt < x + lwdt; ++xcnt)
686  {
687  DrawPix(sfcDest, xcnt, y + ycnt, Pattern.PatternClr(xcnt, y + ycnt));
688  }
689  }
690  else
691  {
692  for (int xcnt = x - lwdt; xcnt < x + lwdt; ++xcnt)
693  {
694  sfcDest->SetPixDw(xcnt, y + ycnt, Pattern.PatternClr(xcnt, y + ycnt));
695  }
696  }
697  }
698  if (!fRenderTarget) sfcDest->Unlock();
699 }
DWORD PatternClr(unsigned int iX, unsigned int iY) const
Definition: C4Draw.cpp:159
void DrawPix(C4Surface *sfcDest, float tx, float ty, DWORD dwCol)
Definition: C4Draw.cpp:604
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
bool SetPixDw(int iX, int iY, DWORD dwCol)
Definition: C4Surface.cpp:576
bool IsRenderTarget()
Definition: C4Surface.cpp:144

Here is the call graph for this function:

void C4Draw::DrawPix ( C4Surface sfcDest,
float  tx,
float  ty,
DWORD  dwCol 
)

Definition at line 604 of file C4Draw.cpp.

References C4BltVertex::color, DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and PerformMultiPix().

Referenced by DrawPatternedCircle().

605 {
606  // Draw
607  C4BltVertex vtx;
608  vtx.ftx = tx;
609  vtx.fty = ty;
610  DwTo4UB(dwClr, vtx.color);
611  PerformMultiPix(sfcDest, &vtx, 1, nullptr);
612 }
float fty
Definition: C4Draw.h:64
unsigned char color[4]
Definition: C4Draw.h:63
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
virtual void PerformMultiPix(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, C4ShaderCall *shader_call)=0
float ftx
Definition: C4Draw.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DrawQuadDw ( C4Surface sfcTarget,
float *  ipVtx,
DWORD  dwClr1,
DWORD  dwClr2,
DWORD  dwClr3,
DWORD  dwClr4,
C4ShaderCall shader_call 
)

Definition at line 659 of file C4Draw.cpp.

References DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and PerformMultiTris().

Referenced by DrawBoxFade(), and C4GUI::Tabular::DrawElement().

660 {
661  C4BltVertex vertices[6];
662  vertices[0].ftx = ipVtx[0]; vertices[0].fty = ipVtx[1];
663  vertices[1].ftx = ipVtx[2]; vertices[1].fty = ipVtx[3];
664  vertices[2].ftx = ipVtx[4]; vertices[2].fty = ipVtx[5];
665  vertices[3].ftx = ipVtx[6]; vertices[3].fty = ipVtx[7];
666  DwTo4UB(dwClr1, vertices[0].color);
667  DwTo4UB(dwClr2, vertices[1].color);
668  DwTo4UB(dwClr3, vertices[2].color);
669  DwTo4UB(dwClr4, vertices[3].color);
670  vertices[4] = vertices[0];
671  vertices[5] = vertices[2];
672  PerformMultiTris(sfcTarget, vertices, 6, nullptr, nullptr, nullptr, nullptr, 0, shader_call);
673 }
float fty
Definition: C4Draw.h:64
virtual void PerformMultiTris(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, const C4BltTransform *pTransform, C4TexRef *pTex, C4TexRef *pOverlay, C4TexRef *pNormal, DWORD dwOverlayClrMod, C4ShaderCall *shader_call)=0
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
float ftx
Definition: C4Draw.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4Draw::EnsureMainContextSelected ( )
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4FoW::~C4FoW().

Here is the caller graph for this function:

bool C4Draw::Error ( const char *  szMsg)
protectedvirtual

Reimplemented in CStdGL.

Definition at line 500 of file C4Draw.cpp.

References C4AbstractApp::Error(), Log(), and pApp.

Referenced by CStdGL::Error(), and Init().

501 {
502  if (pApp) pApp->Error(szMsg);
503  Log(szMsg); return false;
504 }
void Error(const char *m)
Definition: C4App.h:99
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
C4AbstractApp * pApp
Definition: C4Draw.h:95

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4Draw::FillBG ( DWORD  dwClr = 0)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4LoaderScreen::Draw().

Here is the caller graph for this function:

bool C4Draw::GetBlitModulation ( DWORD rdwColor)
inline

Definition at line 190 of file C4Draw.h.

References BlitModulateClr, and BlitModulated.

Referenced by CStdFont::DrawText().

190 { rdwColor=BlitModulateClr; return BlitModulated; }
DWORD BlitModulateClr
Definition: C4Draw.h:109
bool BlitModulated
Definition: C4Draw.h:108

Here is the caller graph for this function:

C4Rect C4Draw::GetClipRect ( ) const

Definition at line 730 of file C4Draw.cpp.

References C4Surface::Hgt, iClipX1, iClipX2, iClipY1, iClipY2, RenderTarget, and C4Surface::Wdt.

Referenced by C4LandscapeRenderGL::Draw(), CStdGL::PerformMesh(), CStdGL::SetupMultiBlt(), and CStdGL::UpdateClipper().

731 {
732  int iWdt=std::min(iClipX2, RenderTarget->Wdt-1)-iClipX1+1;
733  int iHgt=std::min(iClipY2, RenderTarget->Hgt-1)-iClipY1+1;
734  int iX=iClipX1; if (iX<0) { iWdt+=iX; iX=0; }
735  int iY=iClipY1; if (iY<0) { iHgt+=iY; iY=0; }
736  return C4Rect(iX, iY, iWdt, iHgt);
737 }
int Wdt
Definition: C4Surface.h:65
Definition: C4Rect.h:27
int Hgt
Definition: C4Surface.h:65
int32_t iClipY2
Definition: C4Draw.h:104
C4Surface * RenderTarget
Definition: C4Draw.h:107
int32_t iClipY1
Definition: C4Draw.h:104
int32_t iClipX1
Definition: C4Draw.h:104
int32_t iClipX2
Definition: C4Draw.h:104

Here is the caller graph for this function:

const C4FoWRegion* C4Draw::GetFoW ( ) const
inline

Definition at line 194 of file C4Draw.h.

References pFoW.

Referenced by C4Sky::Draw(), and C4Object::Draw().

194 { return pFoW; }
const C4FoWRegion * pFoW
Definition: C4Draw.h:111

Here is the caller graph for this function:

C4Rect C4Draw::GetOutRect ( ) const

Definition at line 739 of file C4Draw.cpp.

References C4Surface::Hgt, RenderTarget, and C4Surface::Wdt.

Referenced by C4LandscapeRenderGL::Draw(), CStdGL::PerformMesh(), and CStdGL::SetupMultiBlt().

740 {
741  return C4Rect(0, 0, RenderTarget->Wdt, RenderTarget->Hgt);
742 }
int Wdt
Definition: C4Surface.h:65
Definition: C4Rect.h:27
int Hgt
Definition: C4Surface.h:65
C4Surface * RenderTarget
Definition: C4Draw.h:107

Here is the caller graph for this function:

bool C4Draw::GetPrimaryClipper ( int &  rX1,
int &  rY1,
int &  rX2,
int &  rY2 
)

Definition at line 722 of file C4Draw.cpp.

References fClipX1, fClipX2, fClipY1, and fClipY2.

Referenced by C4GUI::Window::Draw(), C4GUI::MultilineLabel::DrawElement(), and C4GUI::Edit::DrawElement().

723 {
724  // Store drawing clip values
725  rX1=fClipX1; rY1=fClipY1; rX2=fClipX2; rY2=fClipY2;
726  // Done
727  return true;
728 }
float fClipY2
Definition: C4Draw.h:102
float fClipY1
Definition: C4Draw.h:102
float fClipX2
Definition: C4Draw.h:102
float fClipX1
Definition: C4Draw.h:102

Here is the caller graph for this function:

bool C4Draw::GetSurfaceSize ( C4Surface sfcSurface,
int &  iWdt,
int &  iHgt 
)

Definition at line 191 of file C4Draw.cpp.

References C4Surface::GetSurfaceSize().

192 {
193  return sfcSurface->GetSurfaceSize(iWdt, iHgt);
194 }
bool GetSurfaceSize(int &irX, int &irY)
Definition: C4Surface.cpp:444

Here is the call graph for this function:

void C4Draw::GetZoom ( ZoomData r)
inline

Definition at line 197 of file C4Draw.h.

References ZoomData::X, ZoomData::Y, ZoomData::Zoom, Zoom, ZoomX, and ZoomY.

Referenced by C4MouseControl::Draw(), C4GUI::CMouse::Draw(), C4Game::DrawCrewOverheadText(), and ZoomDataStackItem::ZoomDataStackItem().

197 { r->Zoom=Zoom; r->X=ZoomX; r->Y=ZoomY; }
float ZoomY
Definition: C4Draw.h:112
float Y
Definition: C4Draw.h:71
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
float X
Definition: C4Draw.h:71
float Zoom
Definition: C4Draw.h:70

Here is the caller graph for this function:

void C4Draw::Grayscale ( C4Surface sfcSfc,
int32_t  iOffset = 0 
)

Definition at line 701 of file C4Draw.cpp.

References a, b, GetBlueValue, GetGreenValue, C4Surface::GetPixDw(), GetRedValue, C4Surface::Hgt, C4Surface::Lock(), RGBA(), C4Surface::SetPixDw(), C4Surface::Unlock(), and C4Surface::Wdt.

Referenced by C4FacetSurface::Grayscale().

702 {
703  // safety
704  if (!sfcSfc) return;
705  // change colors
706  int xcnt,ycnt,wdt=sfcSfc->Wdt,hgt=sfcSfc->Hgt;
707  // Lock surface
708  if (!sfcSfc->Lock()) return;
709  for (ycnt=0; ycnt<hgt; ycnt++)
710  {
711  for (xcnt=0; xcnt<wdt; xcnt++)
712  {
713  DWORD dwColor = sfcSfc->GetPixDw(xcnt,ycnt,false);
714  uint32_t r = GetRedValue(dwColor), g = GetGreenValue(dwColor), b = GetBlueValue(dwColor), a = dwColor >> 24;
715  int32_t gray = Clamp<int32_t>((r + g + b) / 3 + iOffset, 0, 255);
716  sfcSfc->SetPixDw(xcnt, ycnt, RGBA(gray, gray, gray, a));
717  }
718  }
719  sfcSfc->Unlock();
720 }
int Wdt
Definition: C4Surface.h:65
#define GetGreenValue(rgb)
Definition: StdColors.h:28
#define b
bool Lock()
Definition: C4Surface.cpp:453
bool Unlock()
Definition: C4Surface.cpp:464
#define a
#define GetRedValue(rgb)
Definition: StdColors.h:29
int Hgt
Definition: C4Surface.h:65
#define GetBlueValue(rgb)
Definition: StdColors.h:27
bool SetPixDw(int iX, int iY, DWORD dwCol)
Definition: C4Surface.cpp:576
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:491
uint32_t RGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
Definition: StdColors.h:22
uint32_t DWORD

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::Init ( C4AbstractApp pApp,
unsigned int  iXRes,
unsigned int  iYRes,
unsigned int  iMonitor 
)

Definition at line 815 of file C4Draw.cpp.

References C4Surface, CreatePrimaryClipper(), Error(), pApp, C4Window::pSurface, C4AbstractApp::pWindow, and RestoreDeviceObjects().

Referenced by DDrawInit().

816 {
817  this->pApp = pApp;
818 
819  pApp->pWindow->pSurface = new C4Surface(pApp, pApp->pWindow);
820 
821  if (!RestoreDeviceObjects())
822  return false;
823 
824  if (!CreatePrimaryClipper(iXRes, iYRes))
825  return Error(" Clipper failure.");
826 
827  return true;
828 }
virtual bool RestoreDeviceObjects()=0
C4Surface * pSurface
Definition: C4Window.h:274
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes)
Definition: C4Draw.cpp:507
virtual bool Error(const char *szMsg)
Definition: C4Draw.cpp:500
friend class C4Surface
Definition: C4Draw.h:213
C4Window * pWindow
Definition: C4App.h:80
C4AbstractApp * pApp
Definition: C4Draw.h:95

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4Draw::InvalidateDeviceObjects ( )
pure virtual

Implemented in CStdGL, and CStdNoGfx.

void C4Draw::LockingPrimary ( )
inline

Definition at line 138 of file C4Draw.h.

138 { PrimaryLocked=true; }
bool PrimaryLocked
Definition: C4Draw.h:106
bool C4Draw::NoPrimaryClipper ( )

Definition at line 237 of file C4Draw.cpp.

References SetPrimaryClipper().

Referenced by CStdGL::Clear(), C4Viewport::Draw(), C4Landscape::DrawChunks(), C4GUI::Edit::DrawElement(), and C4Landscape::P::MapToSurface().

238 {
239  // apply maximum clipper
240  SetPrimaryClipper(0,0,439832,439832);
241  // Done
242  return true;
243 }
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:217

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4Draw::OnResolutionChanged ( unsigned int  iXRes,
unsigned int  iYRes 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4Application::OnResolutionChanged().

Here is the caller graph for this function:

virtual void C4Draw::PerformMesh ( StdMeshInstance instance,
float  tx,
float  ty,
float  twdt,
float  thgt,
DWORD  dwPlayerColor,
C4BltTransform pTransform 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by RenderMesh().

Here is the caller graph for this function:

virtual void C4Draw::PerformMultiLines ( C4Surface sfcTarget,
const C4BltVertex vertices,
unsigned int  n_vertices,
float  width,
C4ShaderCall shader_call 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4PXSSystem::Draw(), DrawCircleDw(), DrawFrameDw(), C4Object::DrawLine(), DrawLineDw(), and C4EditCursor::DrawSelectMark().

Here is the caller graph for this function:

virtual void C4Draw::PerformMultiPix ( C4Surface sfcTarget,
const C4BltVertex vertices,
unsigned int  n_vertices,
C4ShaderCall shader_call 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by Blit8Fast(), C4PXSSystem::Draw(), and DrawPix().

Here is the caller graph for this function:

virtual void C4Draw::PerformMultiTris ( C4Surface sfcTarget,
const C4BltVertex vertices,
unsigned int  n_vertices,
const C4BltTransform pTransform,
C4TexRef pTex,
C4TexRef pOverlay,
C4TexRef pNormal,
DWORD  dwOverlayClrMod,
C4ShaderCall shader_call 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by BlitSurfaceTile(), BlitUnscaled(), C4PXSSystem::Draw(), and DrawQuadDw().

Here is the caller graph for this function:

virtual bool C4Draw::PrepareMaterial ( StdMeshMatManager mat_manager,
StdMeshMaterialLoader loader,
StdMeshMaterial mat 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by StdMeshMatManager::Parse().

Here is the caller graph for this function:

virtual bool C4Draw::PrepareRendering ( C4Surface sfcToSurface)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by BlitUnscaled(), C4Viewport::Execute(), RenderMesh(), and StringOut().

Here is the caller graph for this function:

virtual bool C4Draw::PrepareSpriteShader ( C4Shader shader,
const char *  name,
int  ssc,
C4GroupSet pGroups,
const char *const *  additionalDefines,
const char *const *  additionalSlices 
)
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by C4Sky::Init().

Here is the caller graph for this function:

void C4Draw::PrimaryUnlocked ( )
inline

Definition at line 139 of file C4Draw.h.

139 { PrimaryLocked=false; }
bool PrimaryLocked
Definition: C4Draw.h:106
void C4Draw::RemoveZoom ( float &  X,
float &  Y 
)

Definition at line 790 of file C4Draw.cpp.

References Zoom, ZoomX, and ZoomY.

791 {
792  X = (X - ZoomX) / Zoom + ZoomX;
793  Y = (Y - ZoomY) / Zoom + ZoomY;
794 }
float ZoomY
Definition: C4Draw.h:112
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
#define X(sdl, oc)
bool C4Draw::RenderMesh ( StdMeshInstance instance,
C4Surface sfcTarget,
float  tx,
float  ty,
float  twdt,
float  thgt,
DWORD  dwPlayerColor,
C4BltTransform pTransform 
)

Definition at line 403 of file C4Draw.cpp.

References C4Surface::IsRenderTarget(), MeshTransform, PerformMesh(), PrepareRendering(), StdMeshInstance::ReorderFaces(), and StdMeshInstance::UpdateBoneTransforms().

Referenced by C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), and C4Object::DrawFaceImpl().

404 {
405  // TODO: Emulate rendering
406  if (!sfcTarget->IsRenderTarget()) return false;
407 
408  // TODO: Clip
409 
410  // prepare rendering to surface
411  if (!PrepareRendering(sfcTarget)) return false;
412  // Update bone matrices and vertex data (note this also updates attach transforms and child transforms)
413  instance.UpdateBoneTransforms();
414  // Order faces according to MeshTransformation (note pTransform does not affect Z coordinate, so does not need to be taken into account for correct ordering)
415  StdMeshMatrix mat = StdMeshMatrix::Identity();
416  if(MeshTransform) mat = *MeshTransform * mat;
417  instance.ReorderFaces(&mat);
418  // Render mesh
419  PerformMesh(instance, tx, ty, twdt, thgt, dwPlayerColor, pTransform);
420  // success
421  return true;
422 }
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)=0
const StdMeshMatrix * MeshTransform
Definition: C4Draw.h:113
virtual bool PrepareRendering(C4Surface *sfcToSurface)=0
void ReorderFaces(StdMeshMatrix *global_trans)
Definition: StdMesh.cpp:1550
bool UpdateBoneTransforms()
Definition: StdMesh.cpp:1469
bool IsRenderTarget()
Definition: C4Surface.cpp:144

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::ResetBlitMode ( )
inline
void C4Draw::ResetGamma ( )

Definition at line 760 of file C4Draw.cpp.

References gamma, and gammaOut.

Referenced by Clear(), Default(), and C4Game::SetDefaultGamma().

761 {
762  for (auto & i : gamma) {
763  i[0] = 1.0f;
764  i[1] = 1.0f;
765  i[2] = 1.0f;
766  }
767  gammaOut[0] = 1.0f;
768  gammaOut[1] = 1.0f;
769  gammaOut[2] = 1.0f;
770 }
float gammaOut[3]
Definition: C4Draw.h:98
float gamma[C4MaxGammaRamps][3]
Definition: C4Draw.h:97

Here is the caller graph for this function:

virtual bool C4Draw::RestoreDeviceObjects ( )
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by Init().

Here is the caller graph for this function:

bool C4Draw::RestorePrimaryClipper ( )

Definition at line 210 of file C4Draw.cpp.

References fStClipX1, fStClipX2, fStClipY1, fStClipY2, and SetPrimaryClipper().

Referenced by C4ScriptGuiWindow::DrawChildren(), C4MenuItem::DrawElement(), C4GUI::WoodenLabel::DrawElement(), C4GUI::ComboBox::DrawElement(), and C4FoWRegion::Render().

211 {
212  // Restore primary clipper
214  return true;
215 }
float fStClipY1
Definition: C4Draw.h:103
float fStClipX2
Definition: C4Draw.h:103
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:217
float fStClipY2
Definition: C4Draw.h:103
float fStClipX1
Definition: C4Draw.h:103

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::SetBlitMode ( DWORD  dwBlitMode)
inline

Definition at line 191 of file C4Draw.h.

References C4GFXBLIT_ALL.

Referenced by C4MouseControl::Draw(), C4GraphicsOverlay::Draw(), C4GUI::Tabular::Sheet::DrawCaption(), C4GUI::Button::DrawElement(), C4GUI::IconButton::DrawElement(), C4GUI::ArrowButton::DrawElement(), C4GUI::CheckBox::DrawElement(), C4GUI::ContextButton::DrawElement(), C4GUI::ComboBox::DrawElement(), C4EditCursor::DrawObject(), C4GraphicsOverlay::DrawPicture(), and C4Object::PrepareDrawing().

191 { this->dwBlitMode=dwBlitMode & C4GFXBLIT_ALL; } // set blit mode extra flags (additive blits, mod2-modulation, etc.)
#define C4GFXBLIT_ALL
Definition: C4Surface.h:32
DWORD dwBlitMode
Definition: C4Draw.h:110

Here is the caller graph for this function:

void C4Draw::SetFoW ( const C4FoWRegion fow)
inline

Definition at line 193 of file C4Draw.h.

Referenced by C4Viewport::Draw(), and C4Object::Draw().

193 { pFoW = fow; }
const C4FoWRegion * pFoW
Definition: C4Draw.h:111

Here is the caller graph for this function:

void C4Draw::SetGamma ( float  r,
float  g,
float  b,
int32_t  iRampIndex 
)

Definition at line 744 of file C4Draw.cpp.

References b, gamma, and gammaOut.

Referenced by C4Game::SetDefaultGamma(), and C4Weather::SetSeasonGamma().

745 {
746  // Set
747  gamma[iRampIndex][0] = r;
748  gamma[iRampIndex][1] = g;
749  gamma[iRampIndex][2] = b;
750  // Recalculate resulting gamma. Note that we flip gamma direction here,
751  // because higher gammaOut means darker.
752  gammaOut[0] = gammaOut[1] = gammaOut[2] = 1.0f;
753  for (auto & i : gamma) {
754  gammaOut[0] /= i[0];
755  gammaOut[1] /= i[1];
756  gammaOut[2] /= i[2];
757  }
758 }
#define b
float gammaOut[3]
Definition: C4Draw.h:98
float gamma[C4MaxGammaRamps][3]
Definition: C4Draw.h:97

Here is the caller graph for this function:

void C4Draw::SetMeshTransform ( const StdMeshMatrix *  Transform)
inline

Definition at line 200 of file C4Draw.h.

Referenced by C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), and C4Object::DrawFaceImpl().

200 { MeshTransform = Transform; } // if non-nullptr make sure to keep matrix valid
const StdMeshMatrix * MeshTransform
Definition: C4Draw.h:113

Here is the caller graph for this function:

void C4Draw::SetPerspective ( bool  fSet)
inline

Definition at line 201 of file C4Draw.h.

Referenced by C4DefGraphics::Draw().

201 { fUsePerspective = fSet; }
bool fUsePerspective
Definition: C4Draw.h:114

Here is the caller graph for this function:

bool C4Draw::SetPrimaryClipper ( int  iX1,
int  iY1,
int  iX2,
int  iY2 
)

Definition at line 217 of file C4Draw.cpp.

References fClipX1, fClipX2, fClipY1, fClipY2, iClipX1, iClipX2, iClipY1, iClipY2, and UpdateClipper().

Referenced by CreatePrimaryClipper(), C4Viewport::Draw(), C4GUI::Window::Draw(), C4ScriptGuiWindow::DrawChildren(), C4GUI::WoodenLabel::DrawElement(), C4GUI::Edit::DrawElement(), NoPrimaryClipper(), RestorePrimaryClipper(), and SubPrimaryClipper().

218 {
219  // set clipper
220  fClipX1=iX1; fClipY1=iY1; fClipX2=iX2; fClipY2=iY2;
221  iClipX1=iX1; iClipY1=iY1; iClipX2=iX2; iClipY2=iY2;
222  UpdateClipper();
223  // Done
224  return true;
225 }
float fClipY2
Definition: C4Draw.h:102
float fClipY1
Definition: C4Draw.h:102
int32_t iClipY2
Definition: C4Draw.h:104
float fClipX2
Definition: C4Draw.h:102
int32_t iClipY1
Definition: C4Draw.h:104
virtual bool UpdateClipper()=0
int32_t iClipX1
Definition: C4Draw.h:104
float fClipX1
Definition: C4Draw.h:102
int32_t iClipX2
Definition: C4Draw.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::SetZoom ( float  X,
float  Y,
float  Zoom 
)

Definition at line 779 of file C4Draw.cpp.

References X, Zoom, ZoomX, and ZoomY.

Referenced by C4Viewport::Draw(), C4MouseControl::Draw(), C4GUI::CMouse::Draw(), C4Game::DrawCrewOverheadText(), C4Viewport::DrawMenu(), ZoomDataStackItem::ZoomDataStackItem(), and ZoomDataStackItem::~ZoomDataStackItem().

780 {
781  this->ZoomX = X; this->ZoomY = Y; this->Zoom = Zoom;
782 }
float ZoomY
Definition: C4Draw.h:112
float ZoomX
Definition: C4Draw.h:112
float Zoom
Definition: C4Draw.h:116
#define X(sdl, oc)

Here is the caller graph for this function:

void C4Draw::SetZoom ( const ZoomData zoom)
inline

Definition at line 196 of file C4Draw.h.

References SetZoom(), ZoomData::X, ZoomData::Y, and ZoomData::Zoom.

Referenced by SetZoom().

196 { SetZoom(zoom.X, zoom.Y, zoom.Zoom); }
float Y
Definition: C4Draw.h:71
float X
Definition: C4Draw.h:71
void SetZoom(float X, float Y, float Zoom)
Definition: C4Draw.cpp:779
float Zoom
Definition: C4Draw.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::StorePrimaryClipper ( )

Definition at line 203 of file C4Draw.cpp.

References fClipX1, fClipX2, fClipY1, fClipY2, fStClipX1, fStClipX2, fStClipY1, and fStClipY2.

Referenced by CreatePrimaryClipper(), C4ScriptGuiWindow::DrawChildren(), C4MenuItem::DrawElement(), C4GUI::WoodenLabel::DrawElement(), C4GUI::ComboBox::DrawElement(), and C4FoWRegion::Render().

204 {
205  // Store current primary clipper
207  return true;
208 }
float fClipY2
Definition: C4Draw.h:102
float fClipY1
Definition: C4Draw.h:102
float fStClipY1
Definition: C4Draw.h:103
float fStClipX2
Definition: C4Draw.h:103
float fStClipY2
Definition: C4Draw.h:103
float fClipX2
Definition: C4Draw.h:102
float fStClipX1
Definition: C4Draw.h:103
float fClipX1
Definition: C4Draw.h:102

Here is the caller graph for this function:

bool C4Draw::StringOut ( const char *  szText,
CStdFont rFont,
float  fZoom,
C4Surface sfcDest,
float  iTx,
float  iTy,
DWORD  dwFCol = 0xffffffff,
BYTE  byForm = ALeft,
bool  fDoMarkup = true 
)

Definition at line 576 of file C4Draw.cpp.

Referenced by C4LoaderScreen::Draw(), C4MessageBoard::Draw(), and TextOut().

577 {
578  // init markup
579  C4Markup Markup(true);
580  // output string
581  return StringOut(szText, sfcDest, iTx, iTy, dwFCol, byForm, fDoMarkup, Markup, &rFont, fZoom);
582 }
bool StringOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:576

Here is the caller graph for this function:

bool C4Draw::StringOut ( const char *  szText,
C4Surface sfcDest,
float  iTx,
float  iTy,
DWORD  dwFCol,
BYTE  byForm,
bool  fDoMarkup,
C4Markup Markup,
CStdFont pFont,
float  fZoom 
)
protected

Definition at line 584 of file C4Draw.cpp.

References ACenter, ARight, ClipAll, CStdFont::DrawText(), PrepareRendering(), STDFONT_CENTERED, STDFONT_NOMARKUP, and STDFONT_RIGHTALGN.

585 {
586  // clip
587  if (ClipAll) return true;
588  // safety
589  if (!PrepareRendering(sfcDest)) return false;
590  // convert align
591  int iFlags=0;
592  switch (byForm)
593  {
594  case ACenter: iFlags |= STDFONT_CENTERED; break;
595  case ARight: iFlags |= STDFONT_RIGHTALGN; break;
596  }
597  if (!fDoMarkup) iFlags|=STDFONT_NOMARKUP;
598  // draw text
599  pFont->DrawText(sfcDest, iTx , iTy , dwFCol, szText, iFlags, Markup, fZoom);
600  // done, success
601  return true;
602 }
#define STDFONT_NOMARKUP
Definition: C4FontLoader.h:33
#define STDFONT_CENTERED
Definition: C4FontLoader.h:28
const int ARight
Definition: C4Surface.h:41
virtual bool PrepareRendering(C4Surface *sfcToSurface)=0
const int ACenter
Definition: C4Surface.h:41
void DrawText(C4Surface *sfcDest, float iX, float iY, DWORD dwColor, const char *szText, DWORD dwFlags, C4Markup &Markup, float fZoom)
bool ClipAll
Definition: C4Draw.h:105
#define STDFONT_RIGHTALGN
Definition: C4FontLoader.h:31

Here is the call graph for this function:

bool C4Draw::SubPrimaryClipper ( int  iX1,
int  iY1,
int  iX2,
int  iY2 
)

Definition at line 196 of file C4Draw.cpp.

References iClipX1, iClipX2, iClipY1, iClipY2, and SetPrimaryClipper().

Referenced by C4GUI::Window::Draw(), C4MenuItem::DrawElement(), and C4GUI::ComboBox::DrawElement().

197 {
198  // Set sub primary clipper
199  SetPrimaryClipper(std::max(iX1,iClipX1),std::max(iY1,iClipY1),std::min(iX2,iClipX2),std::min(iY2,iClipY2));
200  return true;
201 }
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:217
int32_t iClipY2
Definition: C4Draw.h:104
int32_t iClipY1
Definition: C4Draw.h:104
int32_t iClipX1
Definition: C4Draw.h:104
int32_t iClipX2
Definition: C4Draw.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::TextOut ( const char *  szText,
CStdFont rFont,
float  fZoom,
C4Surface sfcDest,
float  iTx,
float  iTy,
DWORD  dwFCol = 0xffffffff,
BYTE  byForm = ALeft,
bool  fDoMarkup = true 
)

Definition at line 567 of file C4Draw.cpp.

References CStdFont::GetLineHeight(), SCopySegmentEx(), and StringOut().

Referenced by C4UpperBoard::Draw(), C4LoaderScreen::Draw(), C4GameMessage::Draw(), C4IDList::Draw(), C4Object::Draw(), C4ScriptGuiWindow::Draw(), C4GUI::Tabular::Sheet::DrawCaption(), C4Game::DrawCrewOverheadText(), C4StartupMainDlg::DrawElement(), C4ScoreboardDlg::DrawElement(), C4MenuItem::DrawElement(), C4Chart::DrawElement(), C4GUI::Label::DrawElement(), C4GUI::WoodenLabel::DrawElement(), C4GUI::MultilineLabel::DrawElement(), C4GUI::ProgressBar::DrawElement(), C4GUI::GroupBox::DrawElement(), C4GUI::Button::DrawElement(), C4GUI::IconButton::DrawElement(), C4GUI::FacetButton::DrawElement(), C4GUI::Edit::DrawElement(), C4GUI::CheckBox::DrawElement(), C4GUI::ContextMenu::Entry::DrawElement(), C4GUI::ComboBox::DrawElement(), C4Viewport::DrawMenu(), C4Viewport::DrawPlayerStartup(), C4Network2::DrawStatus(), C4GUI::Screen::DrawToolTip(), C4Facet::DrawValue(), and C4Facet::DrawValue2().

568 {
569  C4Markup Markup(true);
570  static char szLinebuf[2500+1];
571  for (int cnt=0; SCopySegmentEx(szText,cnt,szLinebuf,fDoMarkup ? '|' : '\n','\n',2500); cnt++,iTy+=int(fZoom*rFont.GetLineHeight()))
572  if (!StringOut(szLinebuf,sfcDest,iTx,iTy,dwFCol,byForm,fDoMarkup,Markup,&rFont,fZoom)) return false;
573  return true;
574 }
int GetLineHeight() const
Definition: C4FontLoader.h:125
bool StringOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:576
bool SCopySegmentEx(const char *szString, int iSegment, char *sTarget, char cSep1, char cSep2, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4Draw::UpdateClipper ( )
pure virtual

Implemented in CStdGL, and CStdNoGfx.

Referenced by SetPrimaryClipper().

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4Pattern
friend

Definition at line 215 of file C4Draw.h.

friend class C4Surface
friend

Definition at line 213 of file C4Draw.h.

Referenced by Init().

friend class C4TexRef
friend

Definition at line 214 of file C4Draw.h.

Member Data Documentation

DWORD C4Draw::BlitModulateClr
protected
bool C4Draw::BlitModulated
protected
bool C4Draw::ClipAll
protected

Definition at line 105 of file C4Draw.h.

Referenced by BlitUnscaled(), Default(), StringOut(), and CStdGL::UpdateClipper().

constexpr int C4Draw::COLOR_DEPTH = 32
static
constexpr int C4Draw::COLOR_DEPTH_BYTES = COLOR_DEPTH / 8
static

Definition at line 90 of file C4Draw.h.

Referenced by C4TexRef::C4TexRef(), C4TexRef::Lock(), and C4TexRef::LockForUpdate().

float C4Draw::fClipX1
protected

Definition at line 102 of file C4Draw.h.

Referenced by GetPrimaryClipper(), SetPrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fClipX2
protected

Definition at line 102 of file C4Draw.h.

Referenced by GetPrimaryClipper(), SetPrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fClipY1
protected

Definition at line 102 of file C4Draw.h.

Referenced by GetPrimaryClipper(), SetPrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fClipY2
protected

Definition at line 102 of file C4Draw.h.

Referenced by GetPrimaryClipper(), SetPrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fStClipX1
protected

Definition at line 103 of file C4Draw.h.

Referenced by RestorePrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fStClipX2
protected

Definition at line 103 of file C4Draw.h.

Referenced by RestorePrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fStClipY1
protected

Definition at line 103 of file C4Draw.h.

Referenced by RestorePrimaryClipper(), and StorePrimaryClipper().

float C4Draw::fStClipY2
protected

Definition at line 103 of file C4Draw.h.

Referenced by RestorePrimaryClipper(), and StorePrimaryClipper().

bool C4Draw::fUsePerspective
protected

Definition at line 114 of file C4Draw.h.

Referenced by Default(), and CStdGL::PerformMesh().

float C4Draw::gamma[C4MaxGammaRamps][3]

Definition at line 97 of file C4Draw.h.

Referenced by C4Weather::CompileFunc(), ResetGamma(), and SetGamma().

float C4Draw::gammaOut[3]
int32_t C4Draw::iClipX1
protected

Definition at line 104 of file C4Draw.h.

Referenced by GetClipRect(), SetPrimaryClipper(), and SubPrimaryClipper().

int32_t C4Draw::iClipX2
protected

Definition at line 104 of file C4Draw.h.

Referenced by GetClipRect(), SetPrimaryClipper(), and SubPrimaryClipper().

int32_t C4Draw::iClipY1
protected

Definition at line 104 of file C4Draw.h.

Referenced by GetClipRect(), SetPrimaryClipper(), and SubPrimaryClipper().

int32_t C4Draw::iClipY2
protected

Definition at line 104 of file C4Draw.h.

Referenced by GetClipRect(), SetPrimaryClipper(), and SubPrimaryClipper().

int C4Draw::MaxTexSize {0}
const StdMeshMatrix* C4Draw::MeshTransform
protected

Definition at line 113 of file C4Draw.h.

Referenced by Default(), CStdGL::PerformMesh(), and RenderMesh().

const C4FoWRegion* C4Draw::pFoW
protected

Definition at line 111 of file C4Draw.h.

Referenced by Default(), GetFoW(), CStdGL::GetSpriteShader(), and CStdGL::SetupMultiBlt().

bool C4Draw::PrimaryLocked
protected

Definition at line 106 of file C4Draw.h.

C4ScriptUniform C4Draw::scriptUniform
float C4Draw::ZoomX
protected
float C4Draw::ZoomY
protected

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