OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
CStdNoGfx Class Reference

#include <C4DrawT.h>

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

Public Types

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

Public Member Functions

 CStdNoGfx ()
 
virtual bool UpdateClipper () override
 
virtual bool OnResolutionChanged (unsigned int, unsigned int) override
 
virtual bool PrepareMaterial (StdMeshMatManager &mat_manager, StdMeshMaterialLoader &loader, StdMeshMaterial &mat) override
 
virtual bool PrepareRendering (C4Surface *) override
 
virtual bool EnsureMainContextSelected () override
 
virtual bool PrepareSpriteShader (C4Shader &shader, const char *name, int ssc, C4GroupSet *pGroups, const char *const *additionalDefines, const char *const *additionalSlices) override
 
virtual void FillBG (DWORD dwClr=0) override
 
virtual void PerformMesh (StdMeshInstance &, float, float, float, float, DWORD, C4BltTransform *pTransform) override
 
virtual bool RestoreDeviceObjects () override
 
virtual bool InvalidateDeviceObjects () override
 
virtual bool DeviceReady () override
 
virtual void PerformMultiPix (C4Surface *, const C4BltVertex *, unsigned int, C4ShaderCall *) override
 
virtual void PerformMultiLines (C4Surface *, const C4BltVertex *, unsigned int, float, C4ShaderCall *) override
 
virtual void PerformMultiTris (C4Surface *, const C4BltVertex *, unsigned int, const C4BltTransform *, C4TexRef *, C4TexRef *, C4TexRef *, DWORD, C4ShaderCall *) override
 
bool Init (C4AbstractApp *pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
 
virtual void Clear ()
 
virtual void Default ()
 
virtual CStdGLCtxCreateContext (C4Window *, C4AbstractApp *)
 
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)
 
bool GetSurfaceSize (C4Surface *sfcSurface, int &iWdt, int &iHgt)
 
void Grayscale (C4Surface *sfcSfc, int32_t iOffset=0)
 
void LockingPrimary ()
 
void PrimaryUnlocked ()
 
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)
 
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)
 
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)
 
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)
 

Public Attributes

C4AbstractApppApp
 
bool Active
 
float gamma [C4MaxGammaRamps][3]
 
float gammaOut [3]
 
int MaxTexSize
 
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
 

Detailed Description

Definition at line 23 of file C4DrawT.h.

Member Enumeration Documentation

anonymous enum
inherited
Enumerator
DEFAULT_MESSAGE_COLOR 

Definition at line 167 of file C4Draw.h.

enum C4Draw::DrawOperation
inherited
Enumerator
OP_POINTS 
OP_TRIANGLES 

Definition at line 87 of file C4Draw.h.

Constructor & Destructor Documentation

CStdNoGfx::CStdNoGfx ( )

Definition at line 20 of file C4DrawT.cpp.

References C4Draw::Default().

21 {
22  Default();
23 }
virtual void Default()
Definition: C4Draw.cpp:172

Here is the call graph for this function:

Member Function Documentation

void C4Draw::ActivateBlitModulation ( DWORD  dwWithClr)
inlineinherited

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)
inherited

Definition at line 775 of file C4Draw.cpp.

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

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

Definition at line 230 of file C4Draw.cpp.

231 {
232  return true;
233 }
void C4Draw::ApplyZoom ( float &  X,
float &  Y 
)
inherited

Definition at line 787 of file C4Draw.cpp.

References C4Draw::Zoom, C4Draw::ZoomX, and C4Draw::ZoomY.

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

788 {
789  X = (X - ZoomX) * Zoom + ZoomX;
790  Y = (Y - ZoomY) * Zoom + ZoomY;
791 }
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 
)
inherited

Definition at line 304 of file C4Draw.cpp.

References C4Draw::BlitUnscaled(), and C4Surface::Scale.

Referenced by C4Draw::BlitLandscape(), C4Draw::BlitSimple(), C4Draw::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().

307 {
308  return BlitUnscaled(sfcSource, fx * sfcSource->Scale, fy * sfcSource->Scale, fwdt * sfcSource->Scale, fhgt * sfcSource->Scale,
309  sfcTarget, tx, ty, twdt, thgt, fSrcColKey, pTransform);
310 }
int Scale
Definition: C4Surface.h:68
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:312

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 
)
inherited

Definition at line 427 of file C4Draw.cpp.

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

Referenced by C4Draw::BlitUnscaled().

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

Definition at line 254 of file C4Draw.cpp.

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

Referenced by C4Landscape::Draw().

256 {
257  // blit 8bit-sfc
258  // lock surfaces
259  assert(sfcTarget->fPrimary);
260  bool fRender = sfcTarget->IsRenderTarget();
261  if (!fRender) if (!sfcTarget->Lock())
262  { return; }
263 
264  float tfx = tx, tfy = ty, twdt = wdt, thgt = hgt;
265  if (Zoom != 1.0)
266  {
267  ApplyZoom(tfx, tfy);
268  twdt *= Zoom;
269  thgt *= Zoom;
270  }
271 
272  // blit 8 bit pix in batches of 1024 pixels
273  static const int BUF_SIZE = 1024;
274  C4BltVertex* vertices = new C4BltVertex[BUF_SIZE];
275  int bufcnt = 0;
276 
277  for (int ycnt=0; ycnt<thgt; ++ycnt)
278  {
279  for (int xcnt=0; xcnt<twdt; ++xcnt)
280  {
281  BYTE byPix = sfcSource->GetPix(fx+wdt*xcnt/twdt, fy+hgt*ycnt/thgt);
282  DWORD dwClr = byPix ? sfcSource->pPal->GetClr(byPix) : 0x00000000;
283 
284  vertices[bufcnt].ftx = (float)(tx + xcnt / Zoom);
285  vertices[bufcnt].fty = (float)(ty + ycnt / Zoom);
286  DwTo4UB(dwClr, vertices[bufcnt].color);
287  ++bufcnt;
288 
289  if(bufcnt == BUF_SIZE)
290  {
291  PerformMultiPix(sfcTarget, vertices, BUF_SIZE, nullptr);
292  bufcnt = 0;
293  }
294  }
295 
296  }
297  if(bufcnt > 0)
298  PerformMultiPix(sfcTarget, vertices, bufcnt, nullptr);
299  delete[] vertices;
300  // unlock
301  if (!fRender) sfcTarget->Unlock();
302 }
float fty
Definition: C4Draw.h:64
void ApplyZoom(float &X, float &Y)
Definition: C4Draw.cpp:787
bool Lock()
Definition: C4Surface.cpp:463
bool Unlock()
Definition: C4Surface.cpp:474
uint8_t BYTE
BYTE GetPix(int iX, int iY) const
Definition: CSurface8.h:49
DWORD GetClr(BYTE byCol)
Definition: StdColors.h:188
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:154
bool fPrimary
Definition: C4Surface.h:91
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 
)
virtualinherited

Definition at line 248 of file C4Draw.cpp.

References C4Draw::Blit().

250 {
251  Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt, false);
252 }
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:304

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 
)
inherited

Definition at line 472 of file C4Draw.cpp.

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

Referenced by C4Draw::Blit8().

475 {
476  // rendertarget?
477  if (sfcTarget->IsRenderTarget())
478  {
479  return Blit(sfcSource, float(fx), float(fy), float(fwdt), float(fhgt), sfcTarget, float(tx), float(ty), float(twdt), float(thgt), true);
480  }
481  // Object is first stretched to dest rect
482  int xcnt,ycnt,tcx,tcy,cpcx,cpcy;
483  if (!fwdt || !fhgt || !twdt || !thgt) return false;
484  // Lock the surfaces
485  if (!sfcSource->Lock())
486  return false;
487  if (!sfcTarget->Lock())
488  { sfcSource->Unlock(); return false; }
489  // Rectangle centers
490  tcx=twdt/2; tcy=thgt/2;
491  for (ycnt=0; ycnt<thgt; ycnt++)
492  if (Inside(cpcy=ty+tcy-thgt/2+ycnt,0,sfcTarget->Hgt-1))
493  for (xcnt=0; xcnt<twdt; xcnt++)
494  if (Inside(cpcx=tx+tcx-twdt/2+xcnt,0,sfcTarget->Wdt-1))
495  sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
496  // Unlock the surfaces
497  sfcSource->Unlock();
498  sfcTarget->Unlock();
499  return true;
500 }
int Wdt
Definition: C4Surface.h:67
bool Lock()
Definition: C4Surface.cpp:463
bool Unlock()
Definition: C4Surface.cpp:474
int Hgt
Definition: C4Surface.h:67
bool BltPix(int iX, int iY, C4Surface *sfcSource, int iSrcX, int iSrcY, bool fTransparency)
Definition: C4Surface.cpp:601
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:304
bool IsRenderTarget()
Definition: C4Surface.cpp:154
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45

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 
)
inherited

Definition at line 520 of file C4Draw.cpp.

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

Referenced by C4Surface::Copy().

521 {
522  if (fBlitBase)
523  {
524  Blit(sfcSurface, 0.0f, 0.0f, (float)sfcSurface->Wdt, (float)sfcSurface->Hgt, sfcTarget, float(tx), float(ty), float(sfcSurface->Wdt), float(sfcSurface->Hgt), false);
525  return true;
526  }
527  else
528  {
529  if (!sfcSurface) return false;
530  C4Surface *pSfcBase = sfcSurface->pMainSfc;
531  sfcSurface->pMainSfc = nullptr;
532  Blit(sfcSurface, 0.0f, 0.0f, (float)sfcSurface->Wdt, (float)sfcSurface->Hgt, sfcTarget, float(tx), float(ty), float(sfcSurface->Wdt), float(sfcSurface->Hgt), false);
533  sfcSurface->pMainSfc = pSfcBase;
534  return true;
535  }
536 }
int Wdt
Definition: C4Surface.h:67
int Hgt
Definition: C4Surface.h:67
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:304
C4Surface * pMainSfc
Definition: C4Surface.h:81

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 
)
inherited

Definition at line 538 of file C4Draw.cpp.

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

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

539 {
540  // Only direct rendering from single, tileable, texture
541  if (!sfcTarget->IsRenderTarget()) return false;
542  if ((sfcSurface->texture->iFlags & C4SF_Tileable) == 0) return false;
543 
544  // source surface dimensions
545  const float sourceWdt = sfcSurface->Wdt;
546  const float sourceHgt = sfcSurface->Hgt;
547 
548  // vertex positions
549  C4BltVertex vertices[6];
550  vertices[0].ftx = iToX; vertices[0].fty = iToY; vertices[0].ftz = 0.0f;
551  vertices[0].tx = (0.0f + iOffsetX) / sourceWdt; vertices[0].ty = (0.0f + iOffsetY) / sourceHgt;
552  DwTo4UB(0xffffffff, vertices[0].color);
553  vertices[1].ftx = iToX + iToWdt; vertices[1].fty = iToY; vertices[1].ftz = 0.0f;
554  vertices[1].tx = (iToWdt + iOffsetX) / sourceWdt; vertices[1].ty = (0.0f + iOffsetY) / sourceHgt;
555  DwTo4UB(0xffffffff, vertices[1].color);
556  vertices[2].ftx = iToX + iToWdt; vertices[2].fty = iToY + iToHgt; vertices[2].ftz = 0.0f;
557  vertices[2].tx = (iToWdt + iOffsetX) / sourceWdt; vertices[2].ty = (iToHgt + iOffsetY) / sourceHgt;
558  DwTo4UB(0xffffffff, vertices[2].color);
559  vertices[3].ftx = iToX; vertices[3].fty = iToY + iToHgt; vertices[3].ftz = 0.0f;
560  vertices[3].tx = (0.0f + iOffsetX) / sourceWdt; vertices[3].ty = (iToHgt + iOffsetY) / sourceHgt;
561  DwTo4UB(0xffffffff, vertices[3].color);
562  // duplicate vertices
563  vertices[4] = vertices[0]; vertices[5] = vertices[2];
564 
565  // Draw
566  PerformMultiTris(sfcTarget, vertices, 6, nullptr, sfcSurface->texture.get(), nullptr, nullptr, 0, shader_call);
567  return true;
568 }
float fty
Definition: C4Draw.h:64
float ftz
Definition: C4Draw.h:64
int Wdt
Definition: C4Surface.h:67
float tx
Definition: C4Draw.h:62
float ty
Definition: C4Draw.h:62
int Hgt
Definition: C4Surface.h:67
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:51
std::unique_ptr< C4TexRef > texture
Definition: C4Surface.h:80
float ftx
Definition: C4Draw.h:64
bool IsRenderTarget()
Definition: C4Surface.cpp:154

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 
)
inherited

Definition at line 312 of file C4Draw.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::Clear ( )
virtualinherited

Reimplemented in CStdGL.

Definition at line 187 of file C4Draw.cpp.

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

Referenced by CStdGL::Clear().

188 {
189  ResetGamma();
190  Active=BlitModulated=false;
191  dwBlitMode = 0;
192 }
bool Active
Definition: C4Draw.h:96
DWORD dwBlitMode
Definition: C4Draw.h:110
bool BlitModulated
Definition: C4Draw.h:108
void ResetGamma()
Definition: C4Draw.cpp:763

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in CStdGL.

Definition at line 121 of file C4Draw.h.

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

Definition at line 510 of file C4Draw.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::DeactivateBlitModulation ( )
inlineinherited

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 ( )
virtualinherited

Reimplemented in CStdGL.

Definition at line 172 of file C4Draw.cpp.

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

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

173 {
174  RenderTarget=nullptr;
175  ClipAll=false;
176  Active=false;
177  BlitModulated=false;
178  dwBlitMode = 0;
179  ResetGamma();
180  pFoW = nullptr;
181  ZoomX = 0; ZoomY = 0; Zoom = 1;
182  MeshTransform = nullptr;
183  fUsePerspective = false;
185 }
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:763

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Draw::DetachPrimaryClipper ( C4Surface sfcSurface)
inherited

Definition at line 235 of file C4Draw.cpp.

236 {
237  return true;
238 }
virtual bool CStdNoGfx::DeviceReady ( )
inlineoverridevirtual

Implements C4Draw.

Definition at line 37 of file C4DrawT.h.

37 { return true; }
void C4Draw::DrawBoxDw ( C4Surface sfcDest,
int  iX1,
int  iY1,
int  iX2,
int  iY2,
DWORD  dwClr 
)
inherited

Definition at line 849 of file C4Draw.cpp.

References C4Draw::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().

850 {
851  if (!sfcDest->IsRenderTarget())
852  {
853  // Box on non-render target: Emulate by setting pixels
854  if (!sfcDest->Lock()) return;
855  for (int y = iY1; y <= iY2; ++y)
856  for (int x = iX1; x <= iX2; ++x)
857  sfcDest->SetPixDw(x,y, dwClr);
858  sfcDest->Unlock();
859  }
860  else
861  {
862  DrawBoxFade(sfcDest, float(iX1), float(iY1), float(iX2 - iX1 + 1), float(iY2 - iY1 + 1), dwClr, dwClr, dwClr, dwClr, nullptr);
863  }
864 }
bool Lock()
Definition: C4Surface.cpp:463
bool Unlock()
Definition: C4Surface.cpp:474
bool SetPixDw(int iX, int iY, DWORD dwCol)
Definition: C4Surface.cpp:586
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:833
bool IsRenderTarget()
Definition: C4Surface.cpp:154

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 
)
inherited

Definition at line 833 of file C4Draw.cpp.

References C4Draw::DrawQuadDw().

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

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

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 
)
inherited

Definition at line 627 of file C4Draw.cpp.

References DwTo4UB(), and C4Draw::PerformMultiLines().

Referenced by C4EditCursor::Draw().

628 {
629  // Draw as line segments
630  int32_t num_lines = 12 + int32_t(r / 10);
631  std::unique_ptr<C4BltVertex[]> vertices(new C4BltVertex[num_lines * 2]);
632  for (int32_t i = 0; i < num_lines; ++i)
633  {
634  float ang = float(i) * 2 * M_PI / num_lines;
635  int32_t iv = i * 2 + 1;
636  vertices[iv].ftx = cx + sin(ang) * r;
637  vertices[iv].fty = cy + cos(ang) * r;
638  DwTo4UB(dwClr, vertices[iv].color);
639  vertices[(iv + 1) % (num_lines * 2)] = vertices[iv];
640  }
641  PerformMultiLines(sfcTarget, vertices.get(), num_lines * 2, width, nullptr);
642 }
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 
)
inherited

Definition at line 644 of file C4Draw.cpp.

References DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and C4Draw::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().

645 {
646  C4BltVertex vertices[8];
647  vertices[0].ftx = x1; vertices[0].fty = y1;
648  vertices[1].ftx = x2; vertices[1].fty = y1;
649  vertices[2] = vertices[1];
650  vertices[3].ftx = x2; vertices[3].fty = y2;
651  vertices[4] = vertices[3];
652  vertices[5].ftx = x1; vertices[5].fty = y2;
653  vertices[6] = vertices[5];
654  vertices[7] = vertices[0];
655 
656  for(int i = 0; i < 8; ++i)
657  DwTo4UB(dwClr, vertices[i].color);
658 
659  PerformMultiLines(sfcDest, vertices, 8, width, nullptr);
660 }
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 
)
inherited

Definition at line 617 of file C4Draw.cpp.

References DwTo4UB(), C4BltVertex::ftx, C4BltVertex::fty, and C4Draw::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().

618 {
619  C4BltVertex vertices[2];
620  vertices[0].ftx = x1; vertices[0].fty = y1;
621  vertices[1].ftx = x2; vertices[1].fty = y2;
622  DwTo4UB(dwClr, vertices[0].color);
623  DwTo4UB(dwClr, vertices[1].color);
624  PerformMultiLines(sfcTarget, vertices, 2, width, nullptr);
625 }
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 
)
inherited

Definition at line 678 of file C4Draw.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 607 of file C4Draw.cpp.

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

Referenced by C4Draw::DrawPatternedCircle().

608 {
609  // Draw
610  C4BltVertex vtx;
611  vtx.ftx = tx;
612  vtx.fty = ty;
613  DwTo4UB(dwClr, vtx.color);
614  PerformMultiPix(sfcDest, &vtx, 1, nullptr);
615 }
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 
)
inherited

Definition at line 662 of file C4Draw.cpp.

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

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

663 {
664  C4BltVertex vertices[6];
665  vertices[0].ftx = ipVtx[0]; vertices[0].fty = ipVtx[1];
666  vertices[1].ftx = ipVtx[2]; vertices[1].fty = ipVtx[3];
667  vertices[2].ftx = ipVtx[4]; vertices[2].fty = ipVtx[5];
668  vertices[3].ftx = ipVtx[6]; vertices[3].fty = ipVtx[7];
669  DwTo4UB(dwClr1, vertices[0].color);
670  DwTo4UB(dwClr2, vertices[1].color);
671  DwTo4UB(dwClr3, vertices[2].color);
672  DwTo4UB(dwClr4, vertices[3].color);
673  vertices[4] = vertices[0];
674  vertices[5] = vertices[2];
675  PerformMultiTris(sfcTarget, vertices, 6, nullptr, nullptr, nullptr, nullptr, 0, shader_call);
676 }
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 CStdNoGfx::EnsureMainContextSelected ( )
inlineoverridevirtual

Implements C4Draw.

Definition at line 31 of file C4DrawT.h.

31 { return true; }
bool C4Draw::Error ( const char *  szMsg)
protectedvirtualinherited

Reimplemented in CStdGL.

Definition at line 503 of file C4Draw.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void CStdNoGfx::FillBG ( DWORD  dwClr = 0)
inlineoverridevirtual

Implements C4Draw.

Definition at line 33 of file C4DrawT.h.

33 { }
bool C4Draw::GetBlitModulation ( DWORD rdwColor)
inlineinherited

Definition at line 190 of file C4Draw.h.

References C4Draw::BlitModulateClr, and C4Draw::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
inherited

Definition at line 733 of file C4Draw.cpp.

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

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

734 {
735  int iWdt=std::min(iClipX2, RenderTarget->Wdt-1)-iClipX1+1;
736  int iHgt=std::min(iClipY2, RenderTarget->Hgt-1)-iClipY1+1;
737  int iX=iClipX1; if (iX<0) { iWdt+=iX; iX=0; }
738  int iY=iClipY1; if (iY<0) { iHgt+=iY; iY=0; }
739  return C4Rect(iX, iY, iWdt, iHgt);
740 }
int Wdt
Definition: C4Surface.h:67
Definition: C4Rect.h:29
int Hgt
Definition: C4Surface.h:67
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
inlineinherited

Definition at line 194 of file C4Draw.h.

References C4Draw::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
inherited

Definition at line 742 of file C4Draw.cpp.

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

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

743 {
744  return C4Rect(0, 0, RenderTarget->Wdt, RenderTarget->Hgt);
745 }
int Wdt
Definition: C4Surface.h:67
Definition: C4Rect.h:29
int Hgt
Definition: C4Surface.h:67
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 
)
inherited

Definition at line 725 of file C4Draw.cpp.

References C4Draw::fClipX1, C4Draw::fClipX2, C4Draw::fClipY1, and C4Draw::fClipY2.

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

726 {
727  // Store drawing clip values
728  rX1=fClipX1; rY1=fClipY1; rX2=fClipX2; rY2=fClipY2;
729  // Done
730  return true;
731 }
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 
)
inherited

Definition at line 194 of file C4Draw.cpp.

References C4Surface::GetSurfaceSize().

195 {
196  return sfcSurface->GetSurfaceSize(iWdt, iHgt);
197 }
bool GetSurfaceSize(int &irX, int &irY)
Definition: C4Surface.cpp:454

Here is the call graph for this function:

void C4Draw::GetZoom ( ZoomData r)
inlineinherited

Definition at line 197 of file C4Draw.h.

References ZoomData::X, ZoomData::Y, ZoomData::Zoom, C4Draw::Zoom, C4Draw::ZoomX, and C4Draw::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 
)
inherited

Definition at line 704 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().

705 {
706  // safety
707  if (!sfcSfc) return;
708  // change colors
709  int xcnt,ycnt,wdt=sfcSfc->Wdt,hgt=sfcSfc->Hgt;
710  // Lock surface
711  if (!sfcSfc->Lock()) return;
712  for (ycnt=0; ycnt<hgt; ycnt++)
713  {
714  for (xcnt=0; xcnt<wdt; xcnt++)
715  {
716  DWORD dwColor = sfcSfc->GetPixDw(xcnt,ycnt,false);
717  uint32_t r = GetRedValue(dwColor), g = GetGreenValue(dwColor), b = GetBlueValue(dwColor), a = dwColor >> 24;
718  int32_t gray = Clamp<int32_t>((r + g + b) / 3 + iOffset, 0, 255);
719  sfcSfc->SetPixDw(xcnt, ycnt, RGBA(gray, gray, gray, a));
720  }
721  }
722  sfcSfc->Unlock();
723 }
int Wdt
Definition: C4Surface.h:67
#define GetGreenValue(rgb)
Definition: StdColors.h:30
#define b
bool Lock()
Definition: C4Surface.cpp:463
bool Unlock()
Definition: C4Surface.cpp:474
#define a
#define GetRedValue(rgb)
Definition: StdColors.h:31
int Hgt
Definition: C4Surface.h:67
#define GetBlueValue(rgb)
Definition: StdColors.h:29
bool SetPixDw(int iX, int iY, DWORD dwCol)
Definition: C4Surface.cpp:586
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:501
uint32_t RGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
Definition: StdColors.h:24
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 
)
inherited

Definition at line 818 of file C4Draw.cpp.

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

Referenced by DDrawInit().

819 {
820  this->pApp = pApp;
821 
822  pApp->pWindow->pSurface = new C4Surface(pApp, pApp->pWindow);
823 
824  if (!RestoreDeviceObjects())
825  return false;
826 
827  if (!CreatePrimaryClipper(iXRes, iYRes))
828  return Error(" Clipper failure.");
829 
830  return true;
831 }
virtual bool RestoreDeviceObjects()=0
C4Surface * pSurface
Definition: C4Window.h:279
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes)
Definition: C4Draw.cpp:510
virtual bool Error(const char *szMsg)
Definition: C4Draw.cpp:503
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 CStdNoGfx::InvalidateDeviceObjects ( )
inlineoverridevirtual

Implements C4Draw.

Definition at line 36 of file C4DrawT.h.

36 { return true; }
void C4Draw::LockingPrimary ( )
inlineinherited

Definition at line 138 of file C4Draw.h.

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

Definition at line 240 of file C4Draw.cpp.

References C4Draw::SetPrimaryClipper().

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

241 {
242  // apply maximum clipper
243  SetPrimaryClipper(0,0,439832,439832);
244  // Done
245  return true;
246 }
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:220

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool CStdNoGfx::OnResolutionChanged ( unsigned int  ,
unsigned int   
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 28 of file C4DrawT.h.

28 { return true; }
virtual void CStdNoGfx::PerformMesh ( StdMeshInstance ,
float  ,
float  ,
float  ,
float  ,
DWORD  ,
C4BltTransform pTransform 
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 34 of file C4DrawT.h.

34 { }
virtual void CStdNoGfx::PerformMultiLines ( C4Surface ,
const C4BltVertex ,
unsigned int  ,
float  ,
C4ShaderCall  
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 40 of file C4DrawT.h.

40 {}
virtual void CStdNoGfx::PerformMultiPix ( C4Surface ,
const C4BltVertex ,
unsigned int  ,
C4ShaderCall  
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 39 of file C4DrawT.h.

39 {}
virtual void CStdNoGfx::PerformMultiTris ( C4Surface ,
const C4BltVertex ,
unsigned int  ,
const C4BltTransform ,
C4TexRef ,
C4TexRef ,
C4TexRef ,
DWORD  ,
C4ShaderCall  
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 41 of file C4DrawT.h.

41 {}
bool CStdNoGfx::PrepareMaterial ( StdMeshMatManager mat_manager,
StdMeshMaterialLoader loader,
StdMeshMaterial mat 
)
overridevirtual

Implements C4Draw.

Definition at line 32 of file C4DrawT.cpp.

References StdMeshMaterial::BestTechniqueIndex.

33 {
34  mat.BestTechniqueIndex=0; return true;
35 }
virtual bool CStdNoGfx::PrepareRendering ( C4Surface )
inlineoverridevirtual

Implements C4Draw.

Definition at line 30 of file C4DrawT.h.

30 { return true; }
virtual bool CStdNoGfx::PrepareSpriteShader ( C4Shader shader,
const char *  name,
int  ssc,
C4GroupSet pGroups,
const char *const *  additionalDefines,
const char *const *  additionalSlices 
)
inlineoverridevirtual

Implements C4Draw.

Definition at line 32 of file C4DrawT.h.

32 { return true; }
void C4Draw::PrimaryUnlocked ( )
inlineinherited

Definition at line 139 of file C4Draw.h.

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

Definition at line 793 of file C4Draw.cpp.

References C4Draw::Zoom, C4Draw::ZoomX, and C4Draw::ZoomY.

794 {
795  X = (X - ZoomX) / Zoom + ZoomX;
796  Y = (Y - ZoomY) / Zoom + ZoomY;
797 }
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 
)
inherited

Definition at line 406 of file C4Draw.cpp.

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

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

407 {
408  // TODO: Emulate rendering
409  if (!sfcTarget->IsRenderTarget()) return false;
410 
411  // TODO: Clip
412 
413  // prepare rendering to surface
414  if (!PrepareRendering(sfcTarget)) return false;
415  // Update bone matrices and vertex data (note this also updates attach transforms and child transforms)
416  instance.UpdateBoneTransforms();
417  // Order faces according to MeshTransformation (note pTransform does not affect Z coordinate, so does not need to be taken into account for correct ordering)
418  StdMeshMatrix mat = StdMeshMatrix::Identity();
419  if(MeshTransform) mat = *MeshTransform * mat;
420  instance.ReorderFaces(&mat);
421  // Render mesh
422  PerformMesh(instance, tx, ty, twdt, thgt, dwPlayerColor, pTransform);
423  // success
424  return true;
425 }
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:1566
bool UpdateBoneTransforms()
Definition: StdMesh.cpp:1484
bool IsRenderTarget()
Definition: C4Surface.cpp:154

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Draw::ResetBlitMode ( )
inlineinherited
void C4Draw::ResetGamma ( )
inherited

Definition at line 763 of file C4Draw.cpp.

References C4MaxGammaRamps, C4Draw::gamma, and C4Draw::gammaOut.

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

764 {
765  for (int i = 0; i < C4MaxGammaRamps; i++) {
766  gamma[i][0] = 1.0f;
767  gamma[i][1] = 1.0f;
768  gamma[i][2] = 1.0f;
769  }
770  gammaOut[0] = 1.0f;
771  gammaOut[1] = 1.0f;
772  gammaOut[2] = 1.0f;
773 }
float gammaOut[3]
Definition: C4Draw.h:98
const int C4MaxGammaRamps
Definition: C4Constants.h:35
float gamma[C4MaxGammaRamps][3]
Definition: C4Draw.h:97

Here is the caller graph for this function:

bool CStdNoGfx::RestoreDeviceObjects ( )
overridevirtual

Implements C4Draw.

Definition at line 25 of file C4DrawT.cpp.

References Log(), and C4Draw::MaxTexSize.

26 {
27  Log("Graphics disabled.");
28  MaxTexSize = 2147483647;
29  return true;
30 }
int MaxTexSize
Definition: C4Draw.h:99
bool Log(const char *szMessage)
Definition: C4Log.cpp:195

Here is the call graph for this function:

bool C4Draw::RestorePrimaryClipper ( )
inherited

Definition at line 213 of file C4Draw.cpp.

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

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

214 {
215  // Restore primary clipper
217  return true;
218 }
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:220
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)
inlineinherited

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:34
DWORD dwBlitMode
Definition: C4Draw.h:110

Here is the caller graph for this function:

void C4Draw::SetFoW ( const C4FoWRegion fow)
inlineinherited

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 
)
inherited

Definition at line 747 of file C4Draw.cpp.

References b, C4MaxGammaRamps, C4Draw::gamma, and C4Draw::gammaOut.

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

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

Here is the caller graph for this function:

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

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)
inlineinherited

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 
)
inherited

Definition at line 220 of file C4Draw.cpp.

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

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

221 {
222  // set clipper
223  fClipX1=iX1; fClipY1=iY1; fClipX2=iX2; fClipY2=iY2;
224  iClipX1=iX1; iClipY1=iY1; iClipX2=iX2; iClipY2=iY2;
225  UpdateClipper();
226  // Done
227  return true;
228 }
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 
)
inherited

Definition at line 782 of file C4Draw.cpp.

References X, C4Draw::Zoom, C4Draw::ZoomX, and C4Draw::ZoomY.

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

783 {
784  this->ZoomX = X; this->ZoomY = Y; this->Zoom = Zoom;
785 }
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)
inlineinherited

Definition at line 196 of file C4Draw.h.

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

Referenced by C4Draw::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:782
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 ( )
inherited

Definition at line 206 of file C4Draw.cpp.

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

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

207 {
208  // Store current primary clipper
210  return true;
211 }
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 
)
inherited

Definition at line 579 of file C4Draw.cpp.

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

580 {
581  // init markup
582  C4Markup Markup(true);
583  // output string
584  return StringOut(szText, sfcDest, iTx, iTy, dwFCol, byForm, fDoMarkup, Markup, &rFont, fZoom);
585 }
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:579

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 
)
protectedinherited

Definition at line 587 of file C4Draw.cpp.

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

588 {
589  // clip
590  if (ClipAll) return true;
591  // safety
592  if (!PrepareRendering(sfcDest)) return false;
593  // convert align
594  int iFlags=0;
595  switch (byForm)
596  {
597  case ACenter: iFlags |= STDFONT_CENTERED; break;
598  case ARight: iFlags |= STDFONT_RIGHTALGN; break;
599  }
600  if (!fDoMarkup) iFlags|=STDFONT_NOMARKUP;
601  // draw text
602  pFont->DrawText(sfcDest, iTx , iTy , dwFCol, szText, iFlags, Markup, fZoom);
603  // done, success
604  return true;
605 }
#define STDFONT_NOMARKUP
Definition: C4FontLoader.h:36
#define STDFONT_CENTERED
Definition: C4FontLoader.h:31
const int ARight
Definition: C4Surface.h:43
virtual bool PrepareRendering(C4Surface *sfcToSurface)=0
const int ACenter
Definition: C4Surface.h:43
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:34

Here is the call graph for this function:

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

Definition at line 199 of file C4Draw.cpp.

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

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

200 {
201  // Set sub primary clipper
202  SetPrimaryClipper(std::max(iX1,iClipX1),std::max(iY1,iClipY1),std::min(iX2,iClipX2),std::min(iY2,iClipY2));
203  return true;
204 }
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:220
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 
)
inherited

Definition at line 570 of file C4Draw.cpp.

References CStdFont::GetLineHeight(), SCopySegmentEx(), and C4Draw::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().

571 {
572  C4Markup Markup(true);
573  static char szLinebuf[2500+1];
574  for (int cnt=0; SCopySegmentEx(szText,cnt,szLinebuf,fDoMarkup ? '|' : '\n','\n',2500); cnt++,iTy+=int(fZoom*rFont.GetLineHeight()))
575  if (!StringOut(szLinebuf,sfcDest,iTx,iTy,dwFCol,byForm,fDoMarkup,Markup,&rFont,fZoom)) return false;
576  return true;
577 }
int GetLineHeight() const
Definition: C4FontLoader.h:132
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:579
bool SCopySegmentEx(const char *szString, int iSegment, char *sTarget, char cSep1, char cSep2, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:269

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool CStdNoGfx::UpdateClipper ( )
inlineoverridevirtual

Implements C4Draw.

Definition at line 27 of file C4DrawT.h.

27 { return true; }

Member Data Documentation

DWORD C4Draw::BlitModulateClr
protectedinherited
bool C4Draw::BlitModulated
protectedinherited
bool C4Draw::ClipAll
protectedinherited
constexpr int C4Draw::COLOR_DEPTH = 32
staticinherited
constexpr int C4Draw::COLOR_DEPTH_BYTES = COLOR_DEPTH / 8
staticinherited

Definition at line 90 of file C4Draw.h.

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

float C4Draw::fClipX1
protectedinherited
float C4Draw::fClipX2
protectedinherited
float C4Draw::fClipY1
protectedinherited
float C4Draw::fClipY2
protectedinherited
float C4Draw::fStClipX1
protectedinherited

Definition at line 103 of file C4Draw.h.

Referenced by C4Draw::RestorePrimaryClipper(), and C4Draw::StorePrimaryClipper().

float C4Draw::fStClipX2
protectedinherited

Definition at line 103 of file C4Draw.h.

Referenced by C4Draw::RestorePrimaryClipper(), and C4Draw::StorePrimaryClipper().

float C4Draw::fStClipY1
protectedinherited

Definition at line 103 of file C4Draw.h.

Referenced by C4Draw::RestorePrimaryClipper(), and C4Draw::StorePrimaryClipper().

float C4Draw::fStClipY2
protectedinherited

Definition at line 103 of file C4Draw.h.

Referenced by C4Draw::RestorePrimaryClipper(), and C4Draw::StorePrimaryClipper().

bool C4Draw::fUsePerspective
protectedinherited

Definition at line 114 of file C4Draw.h.

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

float C4Draw::gamma[C4MaxGammaRamps][3]
inherited

Definition at line 97 of file C4Draw.h.

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

float C4Draw::gammaOut[3]
inherited
int32_t C4Draw::iClipX1
protectedinherited
int32_t C4Draw::iClipX2
protectedinherited
int32_t C4Draw::iClipY1
protectedinherited
int32_t C4Draw::iClipY2
protectedinherited
int C4Draw::MaxTexSize
inherited
const StdMeshMatrix* C4Draw::MeshTransform
protectedinherited

Definition at line 113 of file C4Draw.h.

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

const C4FoWRegion* C4Draw::pFoW
protectedinherited
bool C4Draw::PrimaryLocked
protectedinherited

Definition at line 106 of file C4Draw.h.

C4ScriptUniform C4Draw::scriptUniform
inherited
float C4Draw::ZoomX
protectedinherited
float C4Draw::ZoomY
protectedinherited

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