_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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 
38 #ifdef USE_GLES
39 #include "GLES/gl.h"
40 #endif
41 
42 #ifdef USE_OPENGL
43 #include "SDL_opengl.h"
44 #endif
45 
46 #include "guichan.h"
47 
48 #include "color.h"
49 #include "vec2i.h"
50 
51 class CFont;
52 
53 #if defined(USE_OPENGL) || defined(USE_GLES)
54 extern char ForceUseOpenGL;
55 extern bool UseOpenGL;
56 extern bool ZoomNoResize;
57 #endif
58 
59 class CGraphic : public gcn::Image
60 {
61 
62  struct frame_pos_t {
63  short int x;
64  short int y;
65  };
66 
67 protected:
68  CGraphic() : Surface(NULL), SurfaceFlip(NULL), frame_map(NULL),
69  Width(0), Height(0), NumFrames(1), GraphicWidth(0), GraphicHeight(0),
70  Refs(1), Resized(false)
71 #if defined(USE_OPENGL) || defined(USE_GLES)
72  , TextureWidth(0.f), TextureHeight(0.f), Textures(NULL), NumTextures(0)
73 #endif
74  {
75  frameFlip_map = NULL;
76  }
77  ~CGraphic() {}
78 
79 public:
80  // Draw
81  void DrawClip(int x, int y) const;
82  void DrawSub(int gx, int gy, int w, int h, int x, int y) const;
83  void DrawSubClip(int gx, int gy, int w, int h, int x, int y) const;
84  void DrawSubTrans(int gx, int gy, int w, int h, int x, int y,
85  unsigned char alpha) const;
86  void DrawSubClipTrans(int gx, int gy, int w, int h, int x, int y,
87  unsigned char alpha) const;
88 
89  // Draw frame
90  void DrawFrame(unsigned frame, int x, int y) const;
91 #if defined(USE_OPENGL) || defined(USE_GLES)
92  void DoDrawFrameClip(GLuint *textures, unsigned frame, int x, int y) const;
93 #endif
94  void DrawFrameClip(unsigned frame, int x, int y) const;
95  void DrawFrameTrans(unsigned frame, int x, int y, int alpha) const;
96  void DrawFrameClipTrans(unsigned frame, int x, int y, int alpha) const;
97 
98  // Draw frame flipped horizontally
99  void DrawFrameX(unsigned frame, int x, int y) const;
100 #if defined(USE_OPENGL) || defined(USE_GLES)
101  void DoDrawFrameClipX(GLuint *textures, unsigned frame, int x, int y) const;
102 #endif
103  void DrawFrameClipX(unsigned frame, int x, int y) const;
104  void DrawFrameTransX(unsigned frame, int x, int y, int alpha) const;
105  void DrawFrameClipTransX(unsigned frame, int x, int y, int alpha) const;
106 
107 
108  static CGraphic *New(const std::string &file, int w = 0, int h = 0);
109  static CGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
110 
111  static void Free(CGraphic *g);
112 
113  void Load(bool grayscale = false);
114  void Flip();
115  void UseDisplayFormat();
116  void Resize(int w, int h);
117  void SetOriginalSize();
118  bool TransparentPixel(int x, int y);
119  void MakeShadow();
120 
121  inline bool IsLoaded() const { return Surface != NULL; }
122 
123  //guichan
124  virtual void *_getData() const { return Surface; }
125  virtual int getWidth() const { return Width; }
126  virtual int getHeight() const { return Height; }
127 
128  std::string File;
129  std::string HashFile;
130  SDL_Surface *Surface;
131  SDL_Surface *SurfaceFlip;
132  frame_pos_t *frame_map;
133  frame_pos_t *frameFlip_map;
134  void GenFramesMap();
135  int Width;
136  int Height;
137  int NumFrames;
140  int Refs;
141  bool Resized;
142 
143 #if defined(USE_OPENGL) || defined(USE_GLES)
144  GLfloat TextureWidth;
145  GLfloat TextureHeight;
146  GLuint *Textures;
148 #endif
149 
150  friend class CFont;
151 };
152 
154 {
155 protected:
157  {
158 #if defined(USE_OPENGL) || defined(USE_GLES)
159  memset(PlayerColorTextures, 0, sizeof(PlayerColorTextures));
160 #endif
161  }
162 
163 public:
164  void DrawPlayerColorFrameClipX(int player, unsigned frame, int x, int y);
165  void DrawPlayerColorFrameClip(int player, unsigned frame, int x, int y);
166 
167  static CPlayerColorGraphic *New(const std::string &file, int w = 0, int h = 0);
168  static CPlayerColorGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
169 
170  CPlayerColorGraphic *Clone(bool grayscale = false) const;
171 
172 #if defined(USE_OPENGL) || defined(USE_GLES)
174 #endif
175 };
176 
177 #ifdef USE_MNG
178 #include <libmng.h>
179 
180 class Mng
181 {
182 public:
183  Mng();
184  ~Mng();
185  int Load(const std::string &name);
186  void Reset();
187  void Draw(int x, int y);
188 
189  std::string name;
190  FILE *fd;
191  mng_handle handle;
192  SDL_Surface *surface;
193  unsigned char *buffer;
194  unsigned long ticks;
196 #if defined(USE_OPENGL) || defined(USE_GLES)
197  GLfloat texture_width;
198  GLfloat texture_height;
199  GLuint texture_name;
200 #endif
201 };
202 #endif
203 
211 
213  void (*ButtonPressed)(unsigned buttons);
215  void (*ButtonReleased)(unsigned buttons);
217  void (*MouseMoved)(const PixelPos &screenPos);
219  void (*MouseExit)();
220 
222  void (*KeyPressed)(unsigned keycode, unsigned keychar);
224  void (*KeyReleased)(unsigned keycode, unsigned keychar);
226  void (*KeyRepeated)(unsigned keycode, unsigned keychar);
227 
229  void (*NetworkEvent)();
230 
231 };
232 
233 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
234 #define RSHIFT 0
235 #define GSHIFT 8
236 #define BSHIFT 16
237 #define ASHIFT 24
238 #define RMASK 0x000000ff
239 #define GMASK 0x0000ff00
240 #define BMASK 0x00ff0000
241 #define AMASK 0xff000000
242 #else
243 #define RSHIFT 24
244 #define GSHIFT 16
245 #define BSHIFT 8
246 #define ASHIFT 0
247 #define RMASK 0xff000000
248 #define GMASK 0x00ff0000
249 #define BMASK 0x0000ff00
250 #define AMASK 0x000000ff
251 #endif
252 
253 
254 class CVideo
255 {
256 public:
257  CVideo() : Width(0), Height(0), Depth(0), FullScreen(false) {}
258 
259  void LockScreen();
260  void UnlockScreen();
261 
262  void ClearScreen();
263  bool ResizeScreen(int width, int height);
264 
265  void DrawPixelClip(Uint32 color, int x, int y);
266  void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha);
267 
268  void DrawVLine(Uint32 color, int x, int y, int height);
269  void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha);
270  void DrawVLineClip(Uint32 color, int x, int y, int height);
271  void DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha);
272 
273  void DrawHLine(Uint32 color, int x, int y, int width);
274  void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha);
275  void DrawHLineClip(Uint32 color, int x, int y, int width);
276  void DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha);
277 
278  void DrawLine(Uint32 color, int sx, int sy, int dx, int dy);
279  void DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
280  void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2);
281  void DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
282 
283  void DrawRectangle(Uint32 color, int x, int y, int w, int h);
284  void DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
285  void DrawRectangleClip(Uint32 color, int x, int y, int w, int h);
286  void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
287 
288  void FillRectangle(Uint32 color, int x, int y, int w, int h);
289  void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
290  void FillRectangleClip(Uint32 color, int x, int y, int w, int h);
291  void FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
292 
293  void DrawCircle(Uint32 color, int x, int y, int r);
294  void DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha);
295  void DrawCircleClip(Uint32 color, int x, int y, int r);
296  void DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha);
297 
298  void FillCircle(Uint32 color, int x, int y, int radius);
299  void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha);
300  void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius);
301  void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha);
302 
303  inline Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
304  {
305 #if defined(USE_OPENGL) || defined(USE_GLES)
306  if (UseOpenGL) {
307  return MapRGBA(f, r, g, b, 0xFF);
308  } else
309 #endif
310  {
311  return SDL_MapRGB(f, r, g, b);
312  }
313  }
314  inline Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
315  {
316  return MapRGB(f, color.R, color.G, color.B);
317  }
318  inline Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
319  {
320 #if defined(USE_OPENGL) || defined(USE_GLES)
321  if (UseOpenGL) {
322  return ((r << RSHIFT) | (g << GSHIFT) | (b << BSHIFT) | (a << ASHIFT));
323  } else
324 #endif
325  {
326  return SDL_MapRGBA(f, r, g, b, a);
327  }
328  }
329  inline Uint32 MapRGBA(SDL_PixelFormat *f, const CColor &color)
330  {
331  return MapRGBA(f, color.R, color.G, color.B, color.A);
332  }
333  inline void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
334  {
335 #if defined(USE_OPENGL) || defined(USE_GLES)
336  if (UseOpenGL) {
337  *r = (c >> RSHIFT) & 0xff;
338  *g = (c >> GSHIFT) & 0xff;
339  *b = (c >> BSHIFT) & 0xff;
340  } else
341 #endif
342  {
343  SDL_GetRGB(c, f, r, g, b);
344  }
345  }
346  inline void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
347  {
348 #if defined(USE_OPENGL) || defined(USE_GLES)
349  if (UseOpenGL) {
350  *r = (c >> RSHIFT) & 0xff;
351  *g = (c >> GSHIFT) & 0xff;
352  *b = (c >> BSHIFT) & 0xff;
353  *a = (c >> ASHIFT) & 0xff;
354  } else
355 #endif
356  {
357  SDL_GetRGBA(c, f, r, g, b, a);
358  }
359  }
360 
361  int Width;
362  int Height;
363 #if defined(USE_OPENGL) || defined(USE_GLES)
366 #endif
367 #if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
368  SDL_Cursor *blankCursor;
369 #endif
370  int Depth;
372 };
373 
374 extern CVideo Video;
375 
383 extern int VideoSyncSpeed;
384 
385 extern int SkipFrames;
386 
388 extern char VideoForceFullScreen;
389 
391 extern double NextFrameTicks;
392 
394 extern unsigned long FrameCounter;
395 
397 extern unsigned long SlowFrameCounter;
398 
401 extern void SetPlayersPalette();
402 
404 extern SDL_Surface *TheScreen;
405 
406 #if defined(USE_OPENGL) || defined(USE_GLES)
407 extern GLint GLMaxTextureSize;
410 extern GLint GLMaxTextureSizeOverride;
414 extern bool UseGLTextureCompression;
415 #endif
416 
418 extern void VideoCclRegister();
419 
421 extern void InitVideo();
422 
424 void DeInitVideo();
425 
427 extern int VideoValidResolution(int w, int h);
428 
430 extern int LoadGraphicPNG(CGraphic *g);
431 
432 #if defined(USE_OPENGL) || defined(USE_GLES)
433 
435 extern void MakeTexture(CGraphic *graphic);
437 extern void MakePlayerColorTexture(CPlayerColorGraphic *graphic, int player);
438 
440 extern void ValidateOpenGLScreen();
441 
443 extern void FreeOpenGLGraphics();
445 extern void ReloadGraphics();
447 extern void ReloadOpenGL();
448 
449 #endif
450 
452 extern void SetVideoSync();
453 
455 extern void InitLineDraw();
456 
458 extern void Invalidate();
459 
462 extern void InvalidateArea(int x, int y, int w, int h);
463 
466 extern void SetClipping(int left, int top, int right, int bottom);
467 
469 extern void RealizeVideoMemory();
470 
472 extern void SaveScreenshotPNG(const char *name);
473 
475 extern void SaveMapPNG(const char *name);
476 
478 extern void SetCallbacks(const EventCallback *callbacks);
480 extern const EventCallback *GetCallbacks();
481 
483 extern void WaitEventsOneFrame();
484 
486 extern void ToggleFullScreen();
487 
489 extern void PushClipping();
490 
492 extern void PopClipping();
493 
495 extern unsigned long GetTicks();
496 
498 extern const char *SdlKey2Str(int key);
499 
501 extern bool SdlGetGrabMouse();
503 extern void ToggleGrabMouse(int mode);
504 
507 
508 extern Uint32 ColorBlack;
509 extern Uint32 ColorDarkGreen;
510 extern Uint32 ColorLightBlue;
511 extern Uint32 ColorBlue;
512 extern Uint32 ColorOrange;
513 extern Uint32 ColorWhite;
514 extern Uint32 ColorLightGray;
515 extern Uint32 ColorGray;
516 extern Uint32 ColorDarkGray;
517 extern Uint32 ColorRed;
518 extern Uint32 ColorGreen;
519 extern Uint32 ColorYellow;
520 
521 #if defined(USE_OPENGL) || defined(USE_GLES)
522 void DrawTexture(const CGraphic *g, GLuint *textures, int sx, int sy,
523  int ex, int ey, int x, int y, int flip);
524 #endif
525 
526 #ifdef DEBUG
527 extern void FreeGraphics();
528 #endif
529 
530 
531 // ARB_texture_compression
532 #ifdef USE_OPENGL
533 extern PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB;
534 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
535 extern PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB;
536 extern PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB;
537 extern PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB;
538 extern PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB;
539 extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
540 #endif
541 
542 //
543 // Color Cycling stuff
544 //
545 
546 extern void VideoPaletteListAdd(SDL_Surface *surface);
547 extern void VideoPaletteListRemove(SDL_Surface *surface);
548 extern void ClearAllColorCyclingRange();
549 extern void AddColorCyclingRange(unsigned int begin, unsigned int end);
550 extern void SetColorCycleAll(bool value);
551 extern void RestoreColorCyclingSurface();
552 
554 extern void ColorCycle();
555 
557 
558 #endif // !__VIDEO_H__
void ReloadGraphics()
Reload OpenGL graphics.
Definition: graphic.cpp:819
void DrawTexture(const CGraphic *g, GLuint *textures, int sx, int sy, int ex, int ey, int x, int y, int flip)
Definition: sprite.cpp:80
static CPlayerColorGraphic * ForceNew(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:572
int Height
Definition: video.h:362
int LoadGraphicPNG(CGraphic *g)
Load graphic from PNG file.
Definition: png.cpp:88
int NumFrames
Height of a frame.
Definition: video.h:137
void DrawSubClip(int gx, int gy, int w, int h, int x, int y) const
Definition: graphic.cpp:112
void DrawRectangleClip(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:2106
void DrawFrameClipTrans(unsigned frame, int x, int y, int alpha) const
Definition: graphic.cpp:246
Mng()
Definition: mng.cpp:212
#define BSHIFT
Definition: video.h:236
void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius)
Definition: linedraw.cpp:2241
Definition: video.h:210
void DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:1982
bool GLTextureCompressionSupported
Is OpenGL texture compression supported.
Definition: sdl.cpp:123
void DrawLine(Uint32 color, int sx, int sy, int dx, int dy)
Definition: linedraw.cpp:2039
void SetCallbacks(const EventCallback *callbacks)
Set the current callbacks.
Definition: sdl.cpp:912
Definition: video.h:153
Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
Definition: video.h:314
GLint GLMaxTextureSize
Max texture size supported on the video card.
Definition: sdl.cpp:121
frame_pos_t * frameFlip_map
Definition: video.h:133
int Load(const std::string &name)
Definition: mng.cpp:311
void ClearScreen()
Definition: video.cpp:274
void PopClipping()
Pop current clipping.
Definition: video.cpp:241
#define RSHIFT
Definition: video.h:234
void DrawPixelClip(Uint32 color, int x, int y)
Definition: linedraw.cpp:1926
double NextFrameTicks
Next frame ticks.
Definition: video.cpp:177
Uint32 ColorDarkGreen
Definition: video.cpp:192
A platform independent color.
Definition: color.h:39
mng_handle handle
Definition: video.h:191
void ValidateOpenGLScreen()
Regenerate Window screen if needed.
Definition: sdl.cpp:901
Definition: video.h:254
void RestoreColorCyclingSurface()
Definition: video.cpp:476
void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:1960
Definition: image.h:76
int Width
Definition: video.h:361
void DoDrawFrameClip(GLuint *textures, unsigned frame, int x, int y) const
Definition: graphic.cpp:192
#define ASHIFT
Definition: video.h:237
Uint32 ColorLightGray
Definition: video.cpp:197
void(* NetworkEvent)()
Callback for network event.
Definition: video.h:229
void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2140
char ForceUseOpenGL
Definition: video.cpp:170
virtual void * _getData() const
Definition: video.h:124
bool SdlGetGrabMouse()
Check if the mouse is grabbed.
Definition: sdl.cpp:1079
unsigned char B
Green.
Definition: color.h:55
void ClearAllColorCyclingRange()
Definition: video.cpp:395
void DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
Definition: linedraw.cpp:2050
void DrawVLineClip(Uint32 color, int x, int y, int height)
Definition: linedraw.cpp:1971
std::string File
Definition: video.h:128
static CGraphic * ForceNew(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:526
void FillCircle(Uint32 color, int x, int y, int radius)
Definition: linedraw.cpp:2219
void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2117
static CPlayerColorGraphic * New(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:489
void SetOriginalSize()
Definition: graphic.cpp:1330
void FillRectangleClip(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:2151
void DrawSubTrans(int gx, int gy, int w, int h, int x, int y, unsigned char alpha) const
Definition: graphic.cpp:131
#define PlayerMax
Definition: stratagus.h:158
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB
Definition: sdl.cpp:144
void RealizeVideoMemory()
Realize video memory.
Definition: sdl.cpp:991
void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
Definition: video.h:333
void LockScreen()
Definition: video.cpp:258
void MakeTexture(CGraphic *graphic)
Make an OpenGL texture.
Definition: graphic.cpp:1166
void Reset()
Definition: mng.cpp:343
unsigned long GetTicks()
Returns the ticks in ms since start.
Definition: video.cpp:321
bool ZoomNoResize
Use OpenGL.
Definition: video.cpp:172
void DrawFrameTrans(unsigned frame, int x, int y, int alpha) const
Definition: graphic.cpp:230
FILE * fd
Definition: video.h:190
unsigned char R
Definition: color.h:53
void DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2095
void WaitEventsOneFrame()
Process all system events. Returns if the time for a frame is over.
Definition: sdl.cpp:935
int Depth
Actual height of the window.
Definition: video.h:370
void(* KeyRepeated)(unsigned keycode, unsigned keychar)
Callback for key repeated.
Definition: video.h:226
void DrawVLine(Uint32 color, int x, int y, int height)
Definition: linedraw.cpp:1949
void DrawClip(int x, int y) const
Definition: graphic.cpp:68
Uint32 ColorRed
Definition: video.cpp:200
void(* KeyReleased)(unsigned keycode, unsigned keychar)
Callback for key release.
Definition: video.h:224
~Mng()
Definition: mng.cpp:224
SDL_Surface * SurfaceFlip
Surface.
Definition: video.h:131
void DeInitVideo()
deinitliaize the video part
Definition: video.cpp:335
unsigned long ticks
Definition: video.h:194
Uint32 ColorBlue
Definition: video.cpp:194
SDL_Surface * surface
Definition: video.h:192
GLfloat TextureWidth
Image has been resized.
Definition: video.h:144
void DrawFrameClipTransX(unsigned frame, int x, int y, int alpha) const
Definition: graphic.cpp:387
void DrawCircleClip(Uint32 color, int x, int y, int r)
Definition: linedraw.cpp:2196
EventCallback GameCallbacks
Definition: mainloop.cpp:66
void DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha)
Definition: linedraw.cpp:2207
void Load(bool grayscale=false)
Definition: graphic.cpp:667
void(* ButtonPressed)(unsigned buttons)
Callback for mouse button press.
Definition: video.h:213
int SkipFrames
0 disable interrupts
Definition: video.cpp:189
void DrawSub(int gx, int gy, int w, int h, int x, int y) const
Definition: graphic.cpp:88
void InvalidateArea(int x, int y, int w, int h)
Definition: sdl.cpp:781
void UseDisplayFormat()
Definition: graphic.cpp:955
void(* KeyPressed)(unsigned keycode, unsigned keychar)
Callback for key press.
Definition: video.h:222
void MakeShadow()
Definition: graphic.cpp:1412
void SaveScreenshotPNG(const char *name)
Save a screenshot to a PNG file.
Definition: png.cpp:291
Uint32 MapRGBA(SDL_PixelFormat *f, const CColor &color)
Definition: video.h:329
void Invalidate()
Simply invalidates whole window or screen.
Definition: sdl.cpp:800
bool UseOpenGL
Definition: video.cpp:171
void SetVideoSync()
Initializes video synchronization.
Definition: sdl.cpp:162
void SetPlayersPalette()
Definition: player.cpp:1215
void DrawFrameTransX(unsigned frame, int x, int y, int alpha) const
Definition: graphic.cpp:366
void DrawFrameX(unsigned frame, int x, int y) const
Definition: graphic.cpp:294
void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Definition: video.h:346
Definition: video.h:59
void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
Definition: linedraw.cpp:1937
#define GSHIFT
Definition: video.h:235
int VideoValidResolution(int w, int h)
Check if a resolution is valid.
Definition: sdl.cpp:763
void DrawPlayerColorFrameClipX(int player, unsigned frame, int x, int y)
Definition: graphic.cpp:423
void(* MouseExit)()
Callback for mouse exit of game window.
Definition: video.h:219
void Draw(int x, int y)
Definition: mng.cpp:248
Font definition.
Definition: font.h:73
int iteration
Definition: video.h:195
void DrawCircle(Uint32 color, int x, int y, int r)
Definition: linedraw.cpp:2174
void DoDrawFrameClipX(GLuint *textures, unsigned frame, int x, int y) const
Definition: graphic.cpp:311
GLuint texture_name
Height of the texture.
Definition: video.h:199
bool Resized
Uses of this graphic.
Definition: video.h:141
EventCallback EditorCallbacks
Game callbacks.
Definition: mainloop.cpp:67
void DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha)
Definition: linedraw.cpp:2185
void ToggleGrabMouse(int mode)
Toggle mouse grab mode.
Definition: sdl.cpp:1089
void FreeOpenGLGraphics()
Free OpenGL graphics.
Definition: graphic.cpp:798
int ViewportWidth
Definition: video.h:364
void MakePlayerColorTexture(CPlayerColorGraphic *graphic, int player)
Make an OpenGL texture of the player color pixels only.
Definition: graphic.cpp:1181
bool UseGLTextureCompression
Use OpenGL texture compression.
Definition: sdl.cpp:124
int Width
Definition: video.h:135
void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:2252
int VideoSyncSpeed
Definition: video.cpp:188
GLfloat texture_width
Definition: video.h:197
Uint32 ColorGray
Definition: video.cpp:198
GLint GLMaxTextureSizeOverride
User-specified limit for GLMaxTextureSize.
Definition: sdl.cpp:122
int Height
Width of a frame.
Definition: video.h:136
std::string name
Definition: video.h:189
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB
Definition: sdl.cpp:149
void InitVideo()
initialize the video part
Definition: video.cpp:329
void FillRectangle(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:2129
void(* ButtonReleased)(unsigned buttons)
Callback for mouse button release.
Definition: video.h:215
void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:2230
Uint32 ColorDarkGray
Definition: video.cpp:199
SDL_Surface * TheScreen
The SDL screen.
Definition: sdl.cpp:115
void DrawSubClipTrans(int gx, int gy, int w, int h, int x, int y, unsigned char alpha) const
Definition: graphic.cpp:161
GLuint * Textures
Height of the texture.
Definition: video.h:146
void DrawHLine(Uint32 color, int x, int y, int width)
Definition: linedraw.cpp:1994
Uint32 ColorYellow
Definition: video.cpp:202
Uint32 ColorLightBlue
Definition: video.cpp:193
const EventCallback * GetCallbacks()
Get the current callbacks.
Definition: sdl.cpp:920
char VideoForceFullScreen
Fullscreen or windowed set from commandline.
Definition: video.cpp:175
unsigned char A
Blue.
Definition: color.h:56
unsigned char * buffer
Definition: video.h:193
Uint32 ColorGreen
Definition: video.cpp:201
Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: video.h:318
~CGraphic()
Definition: video.h:77
GLuint * PlayerColorTextures[PlayerMax]
Definition: video.h:173
void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2)
Definition: linedraw.cpp:2061
void ColorCycle()
Does ColorCycling..
Definition: video.cpp:455
void AddColorCyclingRange(unsigned int begin, unsigned int end)
Definition: video.cpp:400
void VideoPaletteListRemove(SDL_Surface *surface)
Definition: video.cpp:385
unsigned char G
Red.
Definition: color.h:54
Uint32 ColorBlack
Editor callbacks.
Definition: video.cpp:191
Uint32 ColorWhite
Definition: video.cpp:196
void SetClipping(int left, int top, int right, int bottom)
Definition: video.cpp:217
void Resize(int w, int h)
Definition: graphic.cpp:1198
void DrawFrameClipX(unsigned frame, int x, int y) const
Definition: graphic.cpp:344
virtual int getWidth() const
Definition: video.h:125
Definition: video.h:180
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB
Definition: sdl.cpp:146
bool TransparentPixel(int x, int y)
Definition: graphic.cpp:1380
void SetColorCycleAll(bool value)
Definition: video.cpp:405
unsigned long SlowFrameCounter
Counts quantity of slow frames.
Definition: video.cpp:179
void DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
Definition: linedraw.cpp:2072
bool IsLoaded() const
Definition: video.h:121
void DrawFrameClip(unsigned frame, int x, int y) const
Definition: graphic.cpp:217
int GraphicHeight
Original graphic width.
Definition: video.h:139
GLfloat texture_height
Width of the texture.
Definition: video.h:198
int ViewportHeight
Actual width of the window.
Definition: video.h:365
CGraphic()
Definition: video.h:68
CPlayerColorGraphic()
Definition: video.h:156
frame_pos_t * frame_map
Flipped surface.
Definition: video.h:132
CVideo()
Definition: video.h:257
int GraphicWidth
Number of frames.
Definition: video.h:138
void ToggleFullScreen()
Toggle full screen mode.
Definition: sdl.cpp:1103
static CGraphic * New(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:453
static void Free(CGraphic *g)
Definition: graphic.cpp:743
Uint32 ColorOrange
Definition: video.cpp:195
void ReloadOpenGL()
Reload OpenGL.
Definition: sdl.cpp:331
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB
Definition: sdl.cpp:148
void VideoPaletteListAdd(SDL_Surface *surface)
Definition: video.cpp:365
std::string HashFile
Filename.
Definition: video.h:129
void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha)
Definition: linedraw.cpp:2005
bool FullScreen
Definition: video.h:371
void VideoCclRegister()
register lua function
Definition: video.cpp:352
CPlayerColorGraphic * Clone(bool grayscale=false) const
Definition: graphic.cpp:551
void SaveMapPNG(const char *name)
Save a screenshot to a PNG file.
Definition: png.cpp:392
void FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2162
virtual int getHeight() const
Definition: video.h:126
int NumTextures
Texture names.
Definition: video.h:147
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB
Definition: sdl.cpp:143
CVideo Video
Do SDL hardware unlock.
Definition: video.cpp:166
bool ResizeScreen(int width, int height)
Definition: video.cpp:284
void UnlockScreen()
Definition: video.cpp:266
Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
Definition: video.h:303
void Flip()
Definition: graphic.cpp:846
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB
Definition: sdl.cpp:145
GLfloat TextureHeight
Width of the texture.
Definition: video.h:145
void DrawHLineClip(Uint32 color, int x, int y, int width)
Definition: linedraw.cpp:2016
void DrawRectangle(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:2084
int Refs
Original graphic height.
Definition: video.h:140
void PushClipping()
Push current clipping.
Definition: video.cpp:232
void DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha)
Definition: linedraw.cpp:2027
void InitLineDraw()
Init line draw.
Definition: linedraw.cpp:884
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB
Definition: sdl.cpp:147
void(* MouseMoved)(const PixelPos &screenPos)
Callback for mouse move.
Definition: video.h:217
const char * SdlKey2Str(int key)
Convert a SDLKey to a string.
Definition: sdl.cpp:1049
void DrawPlayerColorFrameClip(int player, unsigned frame, int x, int y)
Definition: graphic.cpp:270
unsigned long FrameCounter
Counts frames.
Definition: video.cpp:178
void DrawFrame(unsigned frame, int x, int y) const
Definition: graphic.cpp:177
void GenFramesMap()
Definition: graphic.cpp:592
SDL_Surface * Surface
Filename used in hash.
Definition: video.h:130
(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.