_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

video.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1999-2011 by Lutz Sammer, Nehal Mistry, Jimmy Salmon and
14 // Pali Roh├ír
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; only version 2 of the License.
19 //
20 // This program is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU General Public License for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with this program; if not, write to the Free Software
27 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 // 02111-1307, USA.
29 //
30 
31 #ifndef __VIDEO_H__
32 #define __VIDEO_H__
33 
35 
36 #include "SDL.h"
37 #include "shaders.h"
38 #include "guichan.h"
39 
40 #include "color.h"
41 #include "vec2i.h"
42 
43 class CFont;
44 
46 extern SDL_Window *TheWindow;
47 extern SDL_Renderer *TheRenderer;
48 extern SDL_Surface *TheScreen;
49 extern SDL_Texture *TheTexture;
50 
51 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
52 #define RSHIFT 16
53 #define GSHIFT 8
54 #define BSHIFT 0
55 #define ASHIFT 24
56 #define RMASK 0x00ff0000
57 #define GMASK 0x0000ff00
58 #define BMASK 0x000000ff
59 #define AMASK 0xff000000
60 #else
61 #define RSHIFT 8
62 #define GSHIFT 16
63 #define BSHIFT 24
64 #define ASHIFT 0
65 #define RMASK 0x0000ff00
66 #define GMASK 0x00ff0000
67 #define BMASK 0xff000000
68 #define AMASK 0x000000ff
69 #endif
70 
71 using pixelModifier = uint32_t(*)(const uint32_t, const uint32_t, const uint32_t); // type alias
72 
75 {
76 public:
79  static uint32_t CopyWithSrcAlphaKey(const uint32_t srcPixel, const uint32_t dstPixel, const uint32_t reqAlpha)
80  {
81  uint32_t srcAlpha = (srcPixel >> ASHIFT) & 0xFF;
82  if (srcAlpha) {
83  srcAlpha = (srcAlpha * reqAlpha) >> 8;
84  return (srcPixel - (srcPixel & AMASK)) + (srcAlpha << ASHIFT);
85  }
86  return dstPixel;
87  }
89 };
90 
91 class CGraphic : public gcn::Image
92 {
93 public:
94  struct frame_pos_t {
95  short int x;
96  short int y;
97  };
98 
99 protected:
100  CGraphic() : Surface(NULL), SurfaceFlip(NULL), frame_map(NULL),
101  Width(0), Height(0), NumFrames(1), GraphicWidth(0), GraphicHeight(0),
102  Refs(1), Resized(false)
103  {
104  frameFlip_map = NULL;
105  }
107 
108 public:
109  // Draw
110  void DrawClip(int x, int y,
111  SDL_Surface *surface = TheScreen) const;
112  void DrawSub(int gx, int gy, int w, int h, int x, int y,
113  SDL_Surface *surface = TheScreen) const;
114 
115  void DrawSubCustomMod(int gx, int gy, int w, int h, int x, int y,
116  pixelModifier modifier,
117  const uint32_t param,
118  SDL_Surface *surface = TheScreen) const;
119 
120  void DrawSubClip(int gx, int gy, int w, int h, int x, int y,
121  SDL_Surface *surface = TheScreen) const;
122  void DrawSubTrans(int gx, int gy, int w, int h, int x, int y,
123  unsigned char alpha,
124  SDL_Surface *surface = TheScreen) const;
125  void DrawSubClipTrans(int gx, int gy, int w, int h, int x, int y,
126  unsigned char alpha,
127  SDL_Surface *surface = TheScreen) const;
128 
129  void DrawSubClipCustomMod(int gx, int gy, int w, int h, int x, int y,
130  pixelModifier modifier,
131  const uint32_t param,
132  SDL_Surface *surface = TheScreen) const;
133 
134  // Draw frame
135  void DrawFrame(unsigned frame, int x, int y,
136  SDL_Surface *surface = TheScreen) const;
137  void DrawFrameClip(unsigned frame, int x, int y,
138  SDL_Surface *surface = TheScreen) const;
139  void DrawFrameTrans(unsigned frame, int x, int y, int alpha,
140  SDL_Surface *surface = TheScreen) const;
141  void DrawFrameClipTrans(unsigned frame, int x, int y, int alpha,
142  SDL_Surface *surface = TheScreen) const;
143 
144  void DrawFrameClipCustomMod(unsigned frame, int x, int y,
145  pixelModifier modifier,
146  const uint32_t param,
147  SDL_Surface *surface = TheScreen) const;
148 
149  // Draw frame flipped horizontally
150  void DrawFrameX(unsigned frame, int x, int y,
151  SDL_Surface *surface = TheScreen) const;
152  void DrawFrameClipX(unsigned frame, int x, int y,
153  SDL_Surface *surface = TheScreen) const;
154  void DrawFrameTransX(unsigned frame, int x, int y, int alpha,
155  SDL_Surface *surface = TheScreen) const;
156  void DrawFrameClipTransX(unsigned frame, int x, int y, int alpha,
157  SDL_Surface *surface = TheScreen) const;
158 
159 
160  static CGraphic *New(const std::string &file, int w = 0, int h = 0);
161  static CGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
162  static CGraphic *Get(const std::string &file);
163 
164  static void Free(CGraphic *g);
165 
166  void Load(bool grayscale = false);
167  void Flip();
168  void Resize(int w, int h);
169  void SetOriginalSize();
170  bool TransparentPixel(int x, int y);
171  void SetPaletteColor(int idx, int r, int g, int b);
172  void MakeShadow(int xOffset, int yOffset);
173 
174  // minor programmatic editing features
175  void OverlayGraphic(CGraphic *other, bool mask = false);
176 
177  inline bool IsLoaded(bool flipped = false) const { return Surface != NULL && (!flipped || SurfaceFlip != NULL); }
178 
179  //guichan
180  virtual void *_getData() const { return Surface; }
181  virtual int getWidth() const { return Width; }
182  virtual int getHeight() const { return Height; }
183 
184  std::string File;
185  std::string HashFile;
186  SDL_Surface *Surface;
187  SDL_Surface *SurfaceFlip;
190  void GenFramesMap();
191  int Width;
192  int Height;
193  int NumFrames;
196  int Refs;
197  bool Resized;
198 
199  friend class CFont;
200 };
201 
203 {
204 protected:
206  {
207  }
208 
209 public:
210  void DrawPlayerColorFrameClipX(int colorIndex, unsigned frame, int x, int y,
211  SDL_Surface *surface = TheScreen);
212  void DrawPlayerColorFrameClip(int colorIndex, unsigned frame, int x, int y,
213  SDL_Surface *surface = TheScreen);
214 
215  static CPlayerColorGraphic *New(const std::string &file, int w = 0, int h = 0);
216  static CPlayerColorGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
217  static CPlayerColorGraphic *Get(const std::string &file);
218 
219  CPlayerColorGraphic *Clone(bool grayscale = false) const;
220 };
221 
222 #ifdef USE_MNG
223 #ifdef WIN32
224 #ifdef HAVE_STDDEF_H
225 #undef HAVE_STDDEF_H
226 #endif
227 #endif
228 #include <libmng.h>
229 #ifdef WIN32
230 #ifndef HAVE_STDDEF_H
231 #undef HAVE_STDDEF_H
232 #endif
233 #endif
234 
235 class Mng : public gcn::Image
236 {
237  Mng();
238  ~Mng();
239 
240  uint32_t refcnt = 0;
241 
242 public:
243  static Mng *New(const std::string &name);
244  static void Free(Mng *mng);
245  bool Load();
246  void Reset();
247  void Draw(int x, int y);
248 
249  //guichan
250  virtual void *_getData() const;
251  virtual int getWidth() const { return surface->w; }
252  virtual int getHeight() const { return surface->h; }
253  virtual bool isDirty() const { return true; }
254 
255  static uint32_t MaxFPS;
256 
257  mutable bool is_dirty;
258  std::string name;
259  FILE *fd;
260  mng_handle handle;
261  SDL_Surface *surface;
262  unsigned char *buffer;
263  unsigned long ticks;
265 };
266 #else
267 class Mng : public gcn::Image
269 {
270  Mng() {};
271  ~Mng() {};
272 public:
273  static Mng *New(const std::string &name) { return NULL; }
274  static void Free(Mng *mng) {};
275  bool Load() { return false; };
276  void Reset() {};
277  void Draw(int x, int y) {};
278 
279  //guichan
280  virtual void *_getData() const { return NULL; };
281  virtual int getWidth() const { return 0; };
282  virtual int getHeight() const { return 0; };
283  virtual bool isDirty() const { return false; };
284 
285  static inline uint32_t MaxFPS = 15;
286 };
287 #endif
288 
296 
298  void (*ButtonPressed)(unsigned buttons);
300  void (*ButtonReleased)(unsigned buttons);
302  void (*MouseMoved)(const PixelPos &screenPos);
305 
307  void (*KeyPressed)(unsigned keycode, unsigned keychar);
309  void (*KeyReleased)(unsigned keycode, unsigned keychar);
311  void (*KeyRepeated)(unsigned keycode, unsigned keychar);
312 
315 
316 };
317 
318 
319 class CVideo
320 {
321 public:
323 
324  void LockScreen();
325  void UnlockScreen();
326 
327  void ClearScreen();
328  bool ResizeScreen(int width, int height);
329 
330  void DrawPixelClip(Uint32 color, int x, int y);
331  void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha);
332 
333  void DrawVLine(Uint32 color, int x, int y, int height);
334  void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha);
335  void DrawVLineClip(Uint32 color, int x, int y, int height);
336  void DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha);
337 
338  void DrawHLine(Uint32 color, int x, int y, int width);
339  void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha);
340  void DrawHLineClip(Uint32 color, int x, int y, int width);
341  void DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha);
342 
343  void DrawLine(Uint32 color, int sx, int sy, int dx, int dy);
344  void DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
345  void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2);
346  void DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
347 
348  void DrawRectangle(Uint32 color, int x, int y, int w, int h);
349  void DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
350  void DrawRectangleClip(Uint32 color, int x, int y, int w, int h);
351  void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
352 
353  void FillRectangle(Uint32 color, int x, int y, int w, int h);
354  void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
355  void FillRectangleClip(Uint32 color, int x, int y, int w, int h);
356  void FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
357 
358  void DrawCircle(Uint32 color, int x, int y, int r);
359  void DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha);
360  void DrawCircleClip(Uint32 color, int x, int y, int r);
361  void DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha);
362 
363  void DrawEllipseClip(Uint32 color, int x, int y, int rx, int ry);
364 
365  void FillCircle(Uint32 color, int x, int y, int radius);
366  void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha);
367  void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius);
368  void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha);
369 
370  inline Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
371  {
372  return SDL_MapRGB(f, r, g, b);
373  }
374  inline Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
375  {
376  return MapRGB(f, color.R, color.G, color.B);
377  }
378  inline Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
379  {
380  return SDL_MapRGBA(f, r, g, b, a);
381  }
382  inline Uint32 MapRGBA(SDL_PixelFormat *f, const CColor &color)
383  {
384  return MapRGBA(f, color.R, color.G, color.B, color.A);
385  }
386  inline void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
387  {
388  SDL_GetRGB(c, f, r, g, b);
389  }
390  inline void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
391  {
392  SDL_GetRGBA(c, f, r, g, b, a);
393  }
394 
395  int Width;
396  int Height;
400  SDL_Cursor *blankCursor;
401  int Depth;
403 };
404 
405 extern CVideo Video;
406 
414 extern int VideoSyncSpeed;
415 
416 extern int SkipFrames;
417 
419 extern char VideoForceFullScreen;
420 
422 extern double NextFrameTicks;
423 
425 extern unsigned long FrameCounter;
426 
428 extern unsigned long SlowFrameCounter;
429 
432 extern void SetPlayersPalette();
433 
435 extern void VideoCclRegister();
436 
438 extern void InitImageLoaders();
439 
441 extern void DeInitImageLoaders();
442 
444 extern void InitVideo();
445 
447 void DeInitVideo();
448 
450 extern int VideoValidResolution(int w, int h);
451 
453 extern void SetVideoSync();
454 
456 extern void InitLineDraw();
457 
459 extern void Invalidate();
460 
463 extern void InvalidateArea(int x, int y, int w, int h);
464 
467 extern void SetClipping(int left, int top, int right, int bottom);
468 
470 extern void RealizeVideoMemory();
471 
473 extern void SaveScreenshotPNG(const char *name);
474 
476 extern void SaveMapPNG(const char *name);
477 
479 extern void SetCallbacks(const EventCallback *callbacks);
481 extern const EventCallback *GetCallbacks();
482 
484 extern void WaitEventsOneFrame();
485 
487 extern void ToggleFullScreen();
488 
490 extern void PushClipping();
491 
493 extern void PopClipping();
494 
496 extern unsigned long GetTicks();
497 
499 extern const char *SdlKey2Str(int key);
500 
502 extern bool SdlGetGrabMouse();
504 extern void ToggleGrabMouse(int mode);
505 
508 
509 extern Uint32 ColorBlack;
510 extern Uint32 ColorDarkGreen;
511 extern Uint32 ColorLightBlue;
512 extern Uint32 ColorBlue;
513 extern Uint32 ColorOrange;
514 extern Uint32 ColorWhite;
515 extern Uint32 ColorLightGray;
516 extern Uint32 ColorGray;
517 extern Uint32 ColorDarkGray;
518 extern Uint32 ColorRed;
519 extern Uint32 ColorGreen;
520 extern Uint32 ColorYellow;
521 
522 inline Uint32 IndexToColor(unsigned int index) {
523  // FIXME: this only works after video was initialized, so we do it dynamically
524  static const Uint32 ColorValues[] = {ColorRed, ColorYellow, ColorGreen, ColorLightGray,
527  return ColorValues[index];
528 }
529 
530 static const char *ColorNames[] = {"red", "yellow", "green", "light-gray",
531  "gray", "dark-gray", "white", "orange",
532  "light-blue", "blue", "dark-green", "black", NULL};
533 
534 inline int GetColorIndexByName(const char *colorName) {
535  int i = 0;
536  while (ColorNames[i] != NULL) {
537  if (!strcmp(colorName, ColorNames[i])) {
538  return i;
539  }
540  i++;
541  }
542  return -1;
543 }
544 
545 extern void FreeGraphics();
546 
547 //
548 // Color Cycling stuff
549 //
550 
551 extern void VideoPaletteListAdd(SDL_Surface *surface);
552 extern void VideoPaletteListRemove(SDL_Surface *surface);
553 extern void ClearAllColorCyclingRange();
554 extern void AddColorCyclingRange(unsigned int begin, unsigned int end);
555 extern unsigned int SetColorCycleSpeed(unsigned int speed);
556 extern void SetColorCycleAll(bool value);
557 extern void RestoreColorCyclingSurface();
558 
560 extern void ColorCycle();
561 
563 extern void BlitSurfaceAlphaBlending_32bpp(const SDL_Surface *srcSurface, const SDL_Rect *srcRect,
564  SDL_Surface *dstSurface, const SDL_Rect *dstRect, const bool enableMT = true);
565 
567 
568 #endif // !__VIDEO_H__
RealizeVideoMemory
void RealizeVideoMemory()
Realize video memory.
Definition: sdl.cpp:832
CGraphic::DrawSubCustomMod
void DrawSubCustomMod(int gx, int gy, int w, int h, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:118
CGraphic::~CGraphic
~CGraphic()
Definition: video.h:106
ColorLightGray
Uint32 ColorLightGray
Definition: video.cpp:180
CGraphic::SetPaletteColor
void SetPaletteColor(int idx, int r, int g, int b)
Definition: graphic.cpp:1036
CVideo::FullScreen
bool FullScreen
Definition: video.h:402
NextFrameTicks
double NextFrameTicks
Next frame ticks.
Definition: video.cpp:160
CVideo::FillTransRectangle
void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:1022
CGraphic::HashFile
std::string HashFile
Filename.
Definition: video.h:185
CGraphic::ForceNew
static CGraphic * ForceNew(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:495
CGraphic::DrawFrameClipTrans
void DrawFrameClipTrans(unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:284
SetPlayersPalette
void SetPlayersPalette()
Definition: player.cpp:1305
GetColorIndexByName
int GetColorIndexByName(const char *colorName)
Definition: video.h:534
EventCallback::NetworkEvent
void(* NetworkEvent)()
Callback for network event.
Definition: video.h:314
CGraphic::getHeight
virtual int getHeight() const
Definition: video.h:182
CGraphic::DrawFrame
void DrawFrame(unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:255
FrameCounter
unsigned long FrameCounter
Counts frames.
Definition: video.cpp:161
CVideo::WindowWidth
int WindowWidth
Definition: video.h:397
VideoValidResolution
int VideoValidResolution(int w, int h)
Check if a resolution is valid.
Definition: sdl.cpp:514
Mng::getWidth
virtual int getWidth() const
Definition: video.h:251
CVideo::ResizeScreen
bool ResizeScreen(int width, int height)
Definition: video.cpp:267
CGraphic::Free
static void Free(CGraphic *g)
Definition: graphic.cpp:748
CVideo::MapRGB
Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
Definition: video.h:370
TheWindow
SDL_Window * TheWindow
The SDL screen.
Definition: sdl.cpp:91
ColorLightBlue
Uint32 ColorLightBlue
Definition: video.cpp:176
CVideo::VerticalPixelSize
double VerticalPixelSize
Definition: video.h:399
CGraphic::Get
static CGraphic * Get(const std::string &file)
Definition: graphic.cpp:538
CVideo::FillRectangleClip
void FillRectangleClip(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:1026
PushClipping
void PushClipping()
Push current clipping.
Definition: video.cpp:215
EventCallback::ButtonReleased
void(* ButtonReleased)(unsigned buttons)
Callback for mouse button release.
Definition: video.h:300
InitImageLoaders
void InitImageLoaders()
initialize the image loaders part
Definition: video.cpp:319
Mng::Free
static void Free(Mng *mng)
Definition: mng.cpp:240
CGraphic::DrawSubClip
void DrawSubClip(int gx, int gy, int w, int h, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:158
CVideo::DrawEllipseClip
void DrawEllipseClip(Uint32 color, int x, int y, int rx, int ry)
Definition: linedraw.cpp:1052
CVideo::UnlockScreen
void UnlockScreen()
Definition: video.cpp:249
CGraphic::Load
void Load(bool grayscale=false)
Definition: graphic.cpp:659
CColor::G
unsigned char G
Red.
Definition: color.h:61
EventCallback::MouseExit
void(* MouseExit)()
Callback for mouse exit of game window.
Definition: video.h:304
CVideo::DrawTransHLineClip
void DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha)
Definition: linedraw.cpp:979
Mng::_getData
virtual void * _getData() const
Definition: mng.cpp:302
CVideo::DrawCircleClip
void DrawCircleClip(Uint32 color, int x, int y, int r)
Definition: linedraw.cpp:1043
CGraphic::SurfaceFlip
SDL_Surface * SurfaceFlip
Surface.
Definition: video.h:187
CGraphic::frameFlip_map
frame_pos_t * frameFlip_map
Definition: video.h:189
ColorNames
static const char * ColorNames[]
Definition: video.h:530
CGraphic::New
static CGraphic * New(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:421
CVideo::Height
int Height
Definition: video.h:396
CGraphic::DrawFrameClipTransX
void DrawFrameClipTransX(unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:371
CVideo
Definition: video.h:319
GetTicks
unsigned long GetTicks()
Returns the ticks in ms since start.
Definition: video.cpp:314
void
void(CCONV *lazyGlBegin)(GLenum)
CGraphic::Height
int Height
Width of a frame.
Definition: video.h:192
ColorRed
Uint32 ColorRed
Definition: video.cpp:183
CPlayerColorGraphic::CPlayerColorGraphic
CPlayerColorGraphic()
Definition: video.h:205
CGraphic::getWidth
virtual int getWidth() const
Definition: video.h:181
CVideo::WindowHeight
int WindowHeight
Definition: video.h:398
ColorDarkGreen
Uint32 ColorDarkGreen
Definition: video.cpp:175
vec2i.h
CVideo::FillCircleClip
void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius)
Definition: linedraw.cpp:1065
Mng::Load
bool Load()
Definition: mng.cpp:258
EventCallback::MouseMoved
void(* MouseMoved)(const PixelPos &screenPos)
Callback for mouse move.
Definition: video.h:302
ColorBlue
Uint32 ColorBlue
Definition: video.cpp:177
CVideo::DrawLine
void DrawLine(Uint32 color, int sx, int sy, int dx, int dy)
Definition: linedraw.cpp:984
InitVideo
void InitVideo()
initialize the video part
Definition: video.cpp:333
EventCallback::KeyPressed
void(* KeyPressed)(unsigned keycode, unsigned keychar)
Callback for key press.
Definition: video.h:307
CVideo::MapRGBA
Uint32 MapRGBA(SDL_PixelFormat *f, const CColor &color)
Definition: video.h:382
CVideo::DrawCircle
void DrawCircle(Uint32 color, int x, int y, int r)
Definition: linedraw.cpp:1035
CGraphic::TransparentPixel
bool TransparentPixel(int x, int y)
Definition: graphic.cpp:1004
CGraphic::Surface
SDL_Surface * Surface
Filename used in hash.
Definition: video.h:186
CVideo::DrawTransCircle
void DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha)
Definition: linedraw.cpp:1039
ClearAllColorCyclingRange
void ClearAllColorCyclingRange()
Definition: video.cpp:471
ASHIFT
#define ASHIFT
Definition: video.h:55
SaveScreenshotPNG
void SaveScreenshotPNG(const char *name)
Save a screenshot to a PNG file.
Definition: png.cpp:57
SetClipping
void SetClipping(int left, int top, int right, int bottom)
Definition: video.cpp:200
EventCallback::ButtonPressed
void(* ButtonPressed)(unsigned buttons)
Callback for mouse button press.
Definition: video.h:298
CVideo::blankCursor
SDL_Cursor * blankCursor
Definition: video.h:400
gcn::Image
Definition: image.h:76
ToggleFullScreen
void ToggleFullScreen()
Toggle full screen mode.
Definition: sdl.cpp:938
CGraphic::CGraphic
CGraphic()
Definition: video.h:100
SetColorCycleAll
void SetColorCycleAll(bool value)
Definition: video.cpp:494
CPlayerColorGraphic::Clone
CPlayerColorGraphic * Clone(bool grayscale=false) const
Definition: graphic.cpp:520
CPlayerColorGraphic::ForceNew
static CPlayerColorGraphic * ForceNew(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:579
CGraphic::DrawClip
void DrawClip(int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:71
Mng::Draw
void Draw(int x, int y)
Definition: mng.cpp:215
Mng::ticks
unsigned long ticks
Definition: video.h:263
PopClipping
void PopClipping()
Pop current clipping.
Definition: video.cpp:224
CGraphic::IsLoaded
bool IsLoaded(bool flipped=false) const
Definition: video.h:177
ColorWhite
Uint32 ColorWhite
Definition: video.cpp:179
Vec2T< int >
CVideo::DrawVLineClip
void DrawVLineClip(Uint32 color, int x, int y, int height)
Definition: linedraw.cpp:958
CGraphic::DrawSub
void DrawSub(int gx, int gy, int w, int h, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:93
CGraphic::DrawFrameTrans
void DrawFrameTrans(unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:277
CVideo::FillRectangle
void FillRectangle(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:1018
CVideo::FillTransCircle
void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:1061
Mng::iteration
int iteration
Definition: video.h:264
ToggleGrabMouse
void ToggleGrabMouse(int mode)
Toggle mouse grab mode.
Definition: sdl.cpp:924
PixelModifier::CopyWithSrcAlphaKey
static uint32_t CopyWithSrcAlphaKey(const uint32_t srcPixel, const uint32_t dstPixel, const uint32_t reqAlpha)
Definition: video.h:79
EditorCallbacks
EventCallback EditorCallbacks
Game callbacks.
Definition: mainloop.cpp:81
CVideo::DrawHLine
void DrawHLine(Uint32 color, int x, int y, int width)
Definition: linedraw.cpp:967
CVideo::FillCircle
void FillCircle(Uint32 color, int x, int y, int radius)
Definition: linedraw.cpp:1057
CColor
A platform independent color.
Definition: color.h:43
CGraphic::NumFrames
int NumFrames
Height of a frame.
Definition: video.h:193
CGraphic::GraphicHeight
int GraphicHeight
Original graphic width.
Definition: video.h:195
VideoForceFullScreen
char VideoForceFullScreen
Fullscreen or windowed set from commandline.
Definition: video.cpp:158
DeInitVideo
void DeInitVideo()
deinitliaize the video part
Definition: video.cpp:339
CGraphic::frame_pos_t
Definition: video.h:94
shaders.h
CVideo::LockScreen
void LockScreen()
Definition: video.cpp:241
CGraphic::DrawFrameClip
void DrawFrameClip(unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:270
GameCallbacks
EventCallback GameCallbacks
Definition: mainloop.cpp:80
CColor::R
unsigned char R
Definition: color.h:60
GetCallbacks
const EventCallback * GetCallbacks()
Get the current callbacks.
Definition: sdl.cpp:717
CVideo::DrawTransRectangleClip
void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:1013
CVideo::Depth
int Depth
Definition: video.h:401
ColorYellow
Uint32 ColorYellow
Definition: video.cpp:185
VideoCclRegister
void VideoCclRegister()
register lua function
Definition: video.cpp:356
CVideo::DrawVLine
void DrawVLine(Uint32 color, int x, int y, int height)
Definition: linedraw.cpp:950
CGraphic::DrawSubTrans
void DrawSubTrans(int gx, int gy, int w, int h, int x, int y, unsigned char alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:186
guichan.h
CColor::A
unsigned char A
Blue.
Definition: color.h:63
Mng::Reset
void Reset()
Definition: mng.cpp:292
CVideo::GetRGB
void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
Definition: video.h:386
CPlayerColorGraphic::DrawPlayerColorFrameClip
void DrawPlayerColorFrameClip(int colorIndex, unsigned frame, int x, int y, SDL_Surface *surface=TheScreen)
Definition: graphic.cpp:309
Mng::buffer
unsigned char * buffer
Definition: video.h:262
TheScreen
SDL_Surface * TheScreen
Internal screen.
Definition: sdl.cpp:94
CVideo::DrawLineClip
void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2)
Definition: linedraw.cpp:992
ColorCycle
void ColorCycle()
Does ColorCycling..
Definition: video.cpp:544
CVideo::DrawTransRectangle
void DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:1005
CVideo::DrawTransCircleClip
void DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha)
Definition: linedraw.cpp:1047
CGraphic::_getData
virtual void * _getData() const
Definition: video.h:180
SetVideoSync
void SetVideoSync()
Initializes video synchronization.
Definition: sdl.cpp:125
pixelModifier
uint32_t(*)(const uint32_t, const uint32_t, const uint32_t) pixelModifier
Definition: video.h:71
AddColorCyclingRange
void AddColorCyclingRange(unsigned int begin, unsigned int end)
Definition: video.cpp:476
Mng::fd
FILE * fd
Definition: video.h:259
DeInitImageLoaders
void DeInitImageLoaders()
deinitialize the image loaders
Definition: video.cpp:325
CGraphic::SetOriginalSize
void SetOriginalSize()
Definition: graphic.cpp:967
CVideo::GetRGBA
void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Definition: video.h:390
CGraphic::Width
int Width
Definition: video.h:191
CVideo::DrawTransPixelClip
void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
Definition: linedraw.cpp:945
EventCallback
Definition: video.h:295
CGraphic::Refs
int Refs
Original graphic height.
Definition: video.h:196
EventCallback::KeyReleased
void(* KeyReleased)(unsigned keycode, unsigned keychar)
Callback for key release.
Definition: video.h:309
CPlayerColorGraphic::DrawPlayerColorFrameClipX
void DrawPlayerColorFrameClipX(int colorIndex, unsigned frame, int x, int y, SDL_Surface *surface=TheScreen)
Definition: graphic.cpp:400
update-images.w
w
Definition: update-images.py:53
VideoPaletteListAdd
void VideoPaletteListAdd(SDL_Surface *surface)
Definition: video.cpp:441
PixelModifier
Class for modifiers for custom pixel manipulations.
Definition: video.h:74
Mng::handle
mng_handle handle
Definition: video.h:260
CVideo::CVideo
CVideo()
Definition: video.h:322
CVideo::DrawTransHLine
void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha)
Definition: linedraw.cpp:971
CGraphic::DrawFrameTransX
void DrawFrameTransX(unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:358
FreeGraphics
void FreeGraphics()
Definition: graphic.cpp:1246
Mng::getHeight
virtual int getHeight() const
Definition: video.h:252
Mng::New
static Mng * New(const std::string &name)
Definition: mng.cpp:227
ColorOrange
Uint32 ColorOrange
Definition: video.cpp:178
SaveMapPNG
void SaveMapPNG(const char *name)
Save a screenshot to a PNG file.
Definition: png.cpp:67
CGraphic::Flip
void Flip()
Definition: graphic.cpp:776
IndexToColor
Uint32 IndexToColor(unsigned int index)
Definition: video.h:522
CGraphic::DrawSubClipTrans
void DrawSubClipTrans(int gx, int gy, int w, int h, int x, int y, unsigned char alpha, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:211
CGraphic::DrawFrameClipCustomMod
void DrawFrameClipCustomMod(unsigned frame, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:291
CGraphic::frame_pos_t::y
short int y
Definition: video.h:96
Video
CVideo Video
Do SDL hardware unlock.
Definition: video.cpp:155
CGraphic::MakeShadow
void MakeShadow(int xOffset, int yOffset)
Definition: graphic.cpp:1215
CVideo::FillTransRectangleClip
void FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:1030
CVideo::DrawHLineClip
void DrawHLineClip(Uint32 color, int x, int y, int width)
Definition: linedraw.cpp:975
CVideo::FillTransCircleClip
void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:1069
CPlayerColorGraphic::New
static CPlayerColorGraphic * New(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:458
InvalidateArea
void InvalidateArea(int x, int y, int w, int h)
Definition: sdl.cpp:527
CColor::B
unsigned char B
Green.
Definition: color.h:62
CGraphic::OverlayGraphic
void OverlayGraphic(CGraphic *other, bool mask=false)
Definition: graphic.cpp:1047
ColorDarkGray
Uint32 ColorDarkGray
Definition: video.cpp:182
SetCallbacks
void SetCallbacks(const EventCallback *callbacks)
Set the current callbacks.
Definition: sdl.cpp:709
SkipFrames
int SkipFrames
0 disable interrupts
Definition: video.cpp:172
CGraphic::File
std::string File
Definition: video.h:184
RestoreColorCyclingSurface
void RestoreColorCyclingSurface()
Definition: video.cpp:563
CVideo::DrawRectangle
void DrawRectangle(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:1001
CVideo::MapRGBA
Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: video.h:378
TheTexture
SDL_Texture * TheTexture
Internal screen.
Definition: sdl.cpp:93
SdlGetGrabMouse
bool SdlGetGrabMouse()
Check if the mouse is grabbed.
Definition: sdl.cpp:914
CGraphic::frame_map
frame_pos_t * frame_map
Flipped surface.
Definition: video.h:188
CPlayerColorGraphic::Get
static CPlayerColorGraphic * Get(const std::string &file)
Definition: graphic.cpp:557
Mng::surface
SDL_Surface * surface
Definition: video.h:261
CGraphic::Resize
void Resize(int w, int h)
Definition: graphic.cpp:839
CGraphic::DrawFrameClipX
void DrawFrameClipX(unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:342
Mng::name
std::string name
Definition: video.h:258
CVideo::DrawRectangleClip
void DrawRectangleClip(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:1009
Mng::is_dirty
bool is_dirty
Definition: video.h:257
ColorGreen
Uint32 ColorGreen
Definition: video.cpp:184
Mng
Definition: video.h:235
BlitSurfaceAlphaBlending_32bpp
void BlitSurfaceAlphaBlending_32bpp(const SDL_Surface *srcSurface, const SDL_Rect *srcRect, SDL_Surface *dstSurface, const SDL_Rect *dstRect, const bool enableMT=true)
Blit a surface into another with alpha blending.
Definition: video.cpp:366
SdlKey2Str
const char * SdlKey2Str(int key)
Convert a SDLKey to a string.
Definition: sdl.cpp:884
InitLineDraw
void InitLineDraw()
Init line draw.
Definition: linedraw.cpp:922
CGraphic::DrawFrameX
void DrawFrameX(unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:325
CVideo::DrawTransVLineClip
void DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:962
CGraphic::GraphicWidth
int GraphicWidth
Number of frames.
Definition: video.h:194
CGraphic::frame_pos_t::x
short int x
Definition: video.h:95
update-images.h
h
Definition: update-images.py:53
SetColorCycleSpeed
unsigned int SetColorCycleSpeed(unsigned int speed)
Definition: video.cpp:487
Mng::MaxFPS
static uint32_t MaxFPS
Definition: video.h:255
CVideo::DrawTransLineClip
void DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
Definition: linedraw.cpp:996
AMASK
#define AMASK
Definition: video.h:59
CGraphic::Resized
bool Resized
Uses of this graphic.
Definition: video.h:197
color.h
Mng::isDirty
virtual bool isDirty() const
Definition: video.h:253
CGraphic::DrawSubClipCustomMod
void DrawSubClipCustomMod(int gx, int gy, int w, int h, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
Definition: graphic.cpp:236
SlowFrameCounter
unsigned long SlowFrameCounter
Counts quantity of slow frames.
Definition: video.cpp:162
CGraphic::GenFramesMap
void GenFramesMap()
Definition: graphic.cpp:599
CVideo::MapRGB
Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
Definition: video.h:374
CVideo::DrawTransVLine
void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:954
VideoSyncSpeed
int VideoSyncSpeed
Definition: video.cpp:171
ColorGray
Uint32 ColorGray
Definition: video.cpp:181
VideoPaletteListRemove
void VideoPaletteListRemove(SDL_Surface *surface)
Definition: video.cpp:461
CVideo::Width
int Width
Definition: video.h:395
TheRenderer
SDL_Renderer * TheRenderer
Internal screen.
Definition: sdl.cpp:92
WaitEventsOneFrame
void WaitEventsOneFrame()
Process all system events. Returns if the time for a frame is over.
Definition: sdl.cpp:732
ColorBlack
Uint32 ColorBlack
Editor callbacks.
Definition: video.cpp:174
CFont
Font definition.
Definition: font.h:73
CVideo::ClearScreen
void ClearScreen()
Definition: video.cpp:257
CPlayerColorGraphic
Definition: video.h:202
EventCallback::KeyRepeated
void(* KeyRepeated)(unsigned keycode, unsigned keychar)
Callback for key repeated.
Definition: video.h:311
Invalidate
void Invalidate()
Simply invalidates whole window or screen.
Definition: sdl.cpp:541
CVideo::DrawPixelClip
void DrawPixelClip(Uint32 color, int x, int y)
Definition: linedraw.cpp:941
CVideo::DrawTransLine
void DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
Definition: linedraw.cpp:988
CGraphic
Definition: video.h:91
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.