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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #ifdef __APPLE__
44 #define GL_GLEXT_PROTOTYPES 1
45 #endif
46 #include "SDL_opengl.h"
47 #include "shaders.h"
48 #endif
49 
50 #include "guichan.h"
51 
52 #include "color.h"
53 #include "vec2i.h"
54 
55 class CFont;
56 
57 #if defined(USE_OPENGL) || defined(USE_GLES)
58 extern char ForceUseOpenGL;
59 extern bool UseOpenGL;
60 extern bool ZoomNoResize;
61 extern bool GLShaderPipelineSupported;
62 #endif
63 
64 class CGraphic : public gcn::Image
65 {
66 
67  struct frame_pos_t {
68  short int x;
69  short int y;
70  };
71 
72 protected:
73  CGraphic() : Surface(NULL), SurfaceFlip(NULL), frame_map(NULL),
74  Width(0), Height(0), NumFrames(1), GraphicWidth(0), GraphicHeight(0),
75  Refs(1), Resized(false)
76 #if defined(USE_OPENGL) || defined(USE_GLES)
77  , TextureWidth(0.f), TextureHeight(0.f), Textures(NULL), NumTextures(0),
79 #endif
80  {
81  frameFlip_map = NULL;
82  }
83  ~CGraphic() {}
84 
85 public:
86  // Draw
87  void DrawClip(int x, int y) const;
88  void DrawSub(int gx, int gy, int w, int h, int x, int y) const;
89  void DrawSubClip(int gx, int gy, int w, int h, int x, int y) const;
90  void DrawSubTrans(int gx, int gy, int w, int h, int x, int y,
91  unsigned char alpha) const;
92  void DrawSubClipTrans(int gx, int gy, int w, int h, int x, int y,
93  unsigned char alpha) const;
94 
95  // Draw frame
96  void DrawFrame(unsigned frame, int x, int y) const;
97 #if defined(USE_OPENGL) || defined(USE_GLES)
98  void DoDrawFrameClip(GLuint *textures, unsigned frame, int x, int y) const;
99 #endif
100  void DrawFrameClip(unsigned frame, int x, int y) const;
101  void DrawFrameTrans(unsigned frame, int x, int y, int alpha) const;
102  void DrawFrameClipTrans(unsigned frame, int x, int y, int alpha) const;
103 
104  // Draw frame flipped horizontally
105  void DrawFrameX(unsigned frame, int x, int y) const;
106 #if defined(USE_OPENGL) || defined(USE_GLES)
107  void DoDrawFrameClipX(GLuint *textures, unsigned frame, int x, int y) const;
108 #endif
109  void DrawFrameClipX(unsigned frame, int x, int y) const;
110  void DrawFrameTransX(unsigned frame, int x, int y, int alpha) const;
111  void DrawFrameClipTransX(unsigned frame, int x, int y, int alpha) const;
112 
113 
114  static CGraphic *New(const std::string &file, int w = 0, int h = 0);
115  static CGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
116  static CGraphic *Get(const std::string &file);
117 
118  static void Free(CGraphic *g);
119 #if defined(USE_OPENGL) || defined(USE_GLES)
121 #endif
122 
123  void Load(bool grayscale = false);
124  void Flip();
125  void UseDisplayFormat();
126  void Resize(int w, int h);
127  void SetOriginalSize();
128  bool TransparentPixel(int x, int y);
129  void MakeShadow();
130 
131  inline bool IsLoaded() const { return Surface != NULL; }
132 
133  //guichan
134  virtual void *_getData() const { return Surface; }
135  virtual int getWidth() const { return Width; }
136  virtual int getHeight() const { return Height; }
137 
138  std::string File;
139  std::string HashFile;
140  SDL_Surface *Surface;
141  SDL_Surface *SurfaceFlip;
142  frame_pos_t *frame_map;
143  frame_pos_t *frameFlip_map;
144  void GenFramesMap();
145  int Width;
146  int Height;
147  int NumFrames;
150  int Refs;
151  bool Resized;
152 
153 #if defined(USE_OPENGL) || defined(USE_GLES)
154  GLfloat TextureWidth;
155  GLfloat TextureHeight;
156  GLuint *Textures;
160 #endif
161 
162  friend class CFont;
163 };
164 
166 {
167 protected:
169  {
170 #if defined(USE_OPENGL) || defined(USE_GLES)
171  memset(PlayerColorTextures, 0, sizeof(PlayerColorTextures));
172 #endif
173  }
174 
175 public:
176  void DrawPlayerColorFrameClipX(int player, unsigned frame, int x, int y);
177  void DrawPlayerColorFrameClip(int player, unsigned frame, int x, int y);
178 
179  static CPlayerColorGraphic *New(const std::string &file, int w = 0, int h = 0);
180  static CPlayerColorGraphic *ForceNew(const std::string &file, int w = 0, int h = 0);
181  static CPlayerColorGraphic *Get(const std::string &file);
182 
183  CPlayerColorGraphic *Clone(bool grayscale = false) const;
184 
185 #if defined(USE_OPENGL) || defined(USE_GLES)
187 #endif
188 };
189 
190 #ifdef USE_MNG
191 #include <libmng.h>
192 
193 class Mng
194 {
195 public:
196  Mng();
197  ~Mng();
198  int Load(const std::string &name);
199  void Reset();
200  void Draw(int x, int y);
201 
202  std::string name;
203  FILE *fd;
204  mng_handle handle;
205  SDL_Surface *surface;
206  unsigned char *buffer;
207  unsigned long ticks;
209 #if defined(USE_OPENGL) || defined(USE_GLES)
210  GLfloat texture_width;
211  GLfloat texture_height;
212  GLuint texture_name;
213 #endif
214 };
215 #endif
216 
224 
226  void (*ButtonPressed)(unsigned buttons);
228  void (*ButtonReleased)(unsigned buttons);
230  void (*MouseMoved)(const PixelPos &screenPos);
232  void (*MouseExit)();
233 
235  void (*KeyPressed)(unsigned keycode, unsigned keychar);
237  void (*KeyReleased)(unsigned keycode, unsigned keychar);
239  void (*KeyRepeated)(unsigned keycode, unsigned keychar);
240 
242  void (*NetworkEvent)();
243 
244 };
245 
246 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
247 #define RSHIFT 0
248 #define GSHIFT 8
249 #define BSHIFT 16
250 #define ASHIFT 24
251 #define RMASK 0x000000ff
252 #define GMASK 0x0000ff00
253 #define BMASK 0x00ff0000
254 #define AMASK 0xff000000
255 #else
256 #define RSHIFT 24
257 #define GSHIFT 16
258 #define BSHIFT 8
259 #define ASHIFT 0
260 #define RMASK 0xff000000
261 #define GMASK 0x00ff0000
262 #define BMASK 0x0000ff00
263 #define AMASK 0x000000ff
264 #endif
265 
266 
267 class CVideo
268 {
269 public:
270  CVideo() : Width(0), Height(0), Depth(0), FullScreen(false) {}
271 
272  void LockScreen();
273  void UnlockScreen();
274 
275  void ClearScreen();
276  bool ResizeScreen(int width, int height);
277 
278  void DrawPixelClip(Uint32 color, int x, int y);
279  void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha);
280 
281  void DrawVLine(Uint32 color, int x, int y, int height);
282  void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha);
283  void DrawVLineClip(Uint32 color, int x, int y, int height);
284  void DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha);
285 
286  void DrawHLine(Uint32 color, int x, int y, int width);
287  void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha);
288  void DrawHLineClip(Uint32 color, int x, int y, int width);
289  void DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha);
290 
291  void DrawLine(Uint32 color, int sx, int sy, int dx, int dy);
292  void DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
293  void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2);
294  void DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha);
295 
296  void DrawRectangle(Uint32 color, int x, int y, int w, int h);
297  void DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
298  void DrawRectangleClip(Uint32 color, int x, int y, int w, int h);
299  void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
300 
301  void FillRectangle(Uint32 color, int x, int y, int w, int h);
302  void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
303  void FillRectangleClip(Uint32 color, int x, int y, int w, int h);
304  void FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha);
305 
306  void DrawCircle(Uint32 color, int x, int y, int r);
307  void DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha);
308  void DrawCircleClip(Uint32 color, int x, int y, int r);
309  void DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha);
310 
311  void FillCircle(Uint32 color, int x, int y, int radius);
312  void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha);
313  void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius);
314  void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha);
315 
316  inline Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
317  {
318 #if defined(USE_OPENGL) || defined(USE_GLES)
319  if (UseOpenGL) {
320  return MapRGBA(f, r, g, b, 0xFF);
321  } else
322 #endif
323  {
324  return SDL_MapRGB(f, r, g, b);
325  }
326  }
327  inline Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
328  {
329  return MapRGB(f, color.R, color.G, color.B);
330  }
331  inline Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
332  {
333 #if defined(USE_OPENGL) || defined(USE_GLES)
334  if (UseOpenGL) {
335  return ((r << RSHIFT) | (g << GSHIFT) | (b << BSHIFT) | (a << ASHIFT));
336  } else
337 #endif
338  {
339  return SDL_MapRGBA(f, r, g, b, a);
340  }
341  }
342  inline Uint32 MapRGBA(SDL_PixelFormat *f, const CColor &color)
343  {
344  return MapRGBA(f, color.R, color.G, color.B, color.A);
345  }
346  inline void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
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  } else
354 #endif
355  {
356  SDL_GetRGB(c, f, r, g, b);
357  }
358  }
359  inline void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
360  {
361 #if defined(USE_OPENGL) || defined(USE_GLES)
362  if (UseOpenGL) {
363  *r = (c >> RSHIFT) & 0xff;
364  *g = (c >> GSHIFT) & 0xff;
365  *b = (c >> BSHIFT) & 0xff;
366  *a = (c >> ASHIFT) & 0xff;
367  } else
368 #endif
369  {
370  SDL_GetRGBA(c, f, r, g, b, a);
371  }
372  }
373 
374  int Width;
375  int Height;
376 #if defined(USE_OPENGL) || defined(USE_GLES)
379 #endif
380 #if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
381  SDL_Cursor *blankCursor;
382 #endif
383  int Depth;
385 };
386 
387 extern CVideo Video;
388 
396 extern int VideoSyncSpeed;
397 
398 extern int SkipFrames;
399 
401 extern char VideoForceFullScreen;
402 
404 extern double NextFrameTicks;
405 
407 extern unsigned long FrameCounter;
408 
410 extern unsigned long SlowFrameCounter;
411 
414 extern void SetPlayersPalette();
415 
417 extern SDL_Surface *TheScreen;
418 
419 #if defined(USE_OPENGL) || defined(USE_GLES)
420 extern GLint GLMaxTextureSize;
423 extern GLint GLMaxTextureSizeOverride;
427 extern bool UseGLTextureCompression;
428 #endif
429 
431 extern void VideoCclRegister();
432 
434 extern void InitVideo();
435 
437 void DeInitVideo();
438 
440 extern int VideoValidResolution(int w, int h);
441 
443 extern int LoadGraphicPNG(CGraphic *g);
444 
445 #if defined(USE_OPENGL) || defined(USE_GLES)
446 
448 extern void MakeTexture(CGraphic *graphic);
450 extern void MakePlayerColorTexture(CPlayerColorGraphic *graphic, int player);
451 
453 extern void ValidateOpenGLScreen();
454 
456 extern void FreeOpenGLGraphics();
458 extern void ReloadGraphics();
460 extern void ReloadOpenGL();
461 
462 #endif
463 
465 extern void SetVideoSync();
466 
468 extern void InitLineDraw();
469 
471 extern void Invalidate();
472 
475 extern void InvalidateArea(int x, int y, int w, int h);
476 
479 extern void SetClipping(int left, int top, int right, int bottom);
480 
482 extern void RealizeVideoMemory();
483 
485 extern void SaveScreenshotPNG(const char *name);
486 
488 extern void SaveMapPNG(const char *name);
489 
491 extern void SetCallbacks(const EventCallback *callbacks);
493 extern const EventCallback *GetCallbacks();
494 
496 extern void WaitEventsOneFrame();
497 
499 extern void ToggleFullScreen();
500 
502 extern void PushClipping();
503 
505 extern void PopClipping();
506 
508 extern unsigned long GetTicks();
509 
511 extern const char *SdlKey2Str(int key);
512 
514 extern bool SdlGetGrabMouse();
516 extern void ToggleGrabMouse(int mode);
517 
520 
521 extern Uint32 ColorBlack;
522 extern Uint32 ColorDarkGreen;
523 extern Uint32 ColorLightBlue;
524 extern Uint32 ColorBlue;
525 extern Uint32 ColorOrange;
526 extern Uint32 ColorWhite;
527 extern Uint32 ColorLightGray;
528 extern Uint32 ColorGray;
529 extern Uint32 ColorDarkGray;
530 extern Uint32 ColorRed;
531 extern Uint32 ColorGreen;
532 extern Uint32 ColorYellow;
533 
534 #if defined(USE_OPENGL) || defined(USE_GLES)
535 void DrawTexture(const CGraphic *g, GLuint *textures, int sx, int sy,
536  int ex, int ey, int x, int y, int flip);
537 #endif
538 
539 extern void FreeGraphics();
540 
541 
542 // ARB_texture_compression
543 #if defined(USE_OPENGL) && !defined(__APPLE__)
544 extern PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB;
545 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
546 extern PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB;
547 extern PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB;
548 extern PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB;
549 extern PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB;
550 extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
551 #endif
552 
553 //
554 // Color Cycling stuff
555 //
556 
557 extern void VideoPaletteListAdd(SDL_Surface *surface);
558 extern void VideoPaletteListRemove(SDL_Surface *surface);
559 extern void ClearAllColorCyclingRange();
560 extern void AddColorCyclingRange(unsigned int begin, unsigned int end);
561 extern void SetColorCycleAll(bool value);
562 extern void RestoreColorCyclingSurface();
563 
565 extern void ColorCycle();
566 
568 
569 #endif // !__VIDEO_H__
void ReloadGraphics()
Reload OpenGL graphics.
Definition: graphic.cpp:858
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:610
int Height
Definition: video.h:375
int LoadGraphicPNG(CGraphic *g)
Load graphic from PNG file.
Definition: png.cpp:88
int NumFrames
Height of a frame.
Definition: video.h:147
void(* MouseExit)()
Callback for mouse exit of game window.
Definition: video.h:232
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:249
void FillCircleClip(Uint32 color, const PixelPos &screenPos, int radius)
Definition: linedraw.cpp:2241
Definition: video.h:223
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:116
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:891
Definition: video.h:165
Uint32 MapRGB(SDL_PixelFormat *f, const CColor &color)
Definition: video.h:327
GLuint ** ColorCyclingTextures
Number of textures.
Definition: video.h:158
static CGraphic * Get(const std::string &file)
Definition: graphic.cpp:569
GLint GLMaxTextureSize
Max texture size supported on the video card.
Definition: sdl.cpp:114
frame_pos_t * frameFlip_map
Definition: video.h:143
int Load(const std::string &name)
Definition: mng.cpp:311
void ClearScreen()
Definition: video.cpp:264
static CPlayerColorGraphic * Get(const std::string &file)
Definition: graphic.cpp:588
void PopClipping()
Pop current clipping.
Definition: video.cpp:231
#define RSHIFT
Definition: video.h:247
void DrawPixelClip(Uint32 color, int x, int y)
Definition: linedraw.cpp:1926
double NextFrameTicks
Next frame ticks.
Definition: video.cpp:167
Uint32 ColorDarkGreen
Definition: video.cpp:182
A platform independent color.
Definition: color.h:39
mng_handle handle
Definition: video.h:204
void ValidateOpenGLScreen()
Regenerate Window screen if needed.
Definition: sdl.cpp:880
Definition: video.h:267
void RestoreColorCyclingSurface()
Definition: video.cpp:479
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:374
void DoDrawFrameClip(GLuint *textures, unsigned frame, int x, int y) const
Definition: graphic.cpp:192
#define ASHIFT
Definition: video.h:250
Uint32 ColorLightGray
Definition: video.cpp:187
bool GLShaderPipelineSupported
Definition: video.cpp:162
void FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2140
char ForceUseOpenGL
Definition: video.cpp:159
virtual void * _getData() const
Definition: video.h:134
bool SdlGetGrabMouse()
Check if the mouse is grabbed.
Definition: sdl.cpp:1059
unsigned char B
Green.
Definition: color.h:55
void ClearAllColorCyclingRange()
Definition: video.cpp:385
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:138
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(* KeyRepeated)(unsigned keycode, unsigned keychar)
Callback for key repeated.
Definition: video.h:239
void DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
Definition: linedraw.cpp:2117
void(* ButtonReleased)(unsigned buttons)
Callback for mouse button release.
Definition: video.h:228
static CPlayerColorGraphic * New(const std::string &file, int w=0, int h=0)
Definition: graphic.cpp:489
void SetOriginalSize()
Definition: graphic.cpp:1419
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:157
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB
Definition: sdl.cpp:137
void RealizeVideoMemory()
Realize video memory.
Definition: sdl.cpp:970
void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
Definition: video.h:346
void LockScreen()
Definition: video.cpp:248
void MakeTexture(CGraphic *graphic)
Make an OpenGL texture.
Definition: graphic.cpp:1208
void Reset()
Definition: mng.cpp:343
unsigned long GetTicks()
Returns the ticks in ms since start.
Definition: video.cpp:311
bool ZoomNoResize
Use OpenGL.
Definition: video.cpp:161
void DrawFrameTrans(unsigned frame, int x, int y, int alpha) const
Definition: graphic.cpp:230
FILE * fd
Definition: video.h:203
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:914
void(* KeyPressed)(unsigned keycode, unsigned keychar)
Callback for key press.
Definition: video.h:235
int Depth
Actual height of the window.
Definition: video.h:383
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
void FreeGraphics()
Definition: graphic.cpp:1531
Uint32 ColorRed
Definition: video.cpp:190
~Mng()
Definition: mng.cpp:224
void(* MouseMoved)(const PixelPos &screenPos)
Callback for mouse move.
Definition: video.h:230
SDL_Surface * SurfaceFlip
Surface.
Definition: video.h:141
void DeInitVideo()
deinitliaize the video part
Definition: video.cpp:325
unsigned long ticks
Definition: video.h:207
Uint32 ColorBlue
Definition: video.cpp:184
SDL_Surface * surface
Definition: video.h:205
GLfloat TextureWidth
Image has been resized.
Definition: video.h:154
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:67
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:705
int SkipFrames
0 disable interrupts
Definition: video.cpp:179
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:749
void UseDisplayFormat()
Definition: graphic.cpp:997
void MakeShadow()
Definition: graphic.cpp:1502
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:342
void Invalidate()
Simply invalidates whole window or screen.
Definition: sdl.cpp:768
bool UseOpenGL
Definition: video.cpp:160
void SetVideoSync()
Initializes video synchronization.
Definition: sdl.cpp:155
bool DeleteColorCyclingTextures()
Definition: graphic.cpp:1652
void SetPlayersPalette()
Definition: player.cpp:1222
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:359
Definition: video.h:64
void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
Definition: linedraw.cpp:1937
#define GSHIFT
Definition: video.h:248
int VideoValidResolution(int w, int h)
Check if a resolution is valid.
Definition: sdl.cpp:736
void DrawPlayerColorFrameClipX(int player, unsigned frame, int x, int y)
Definition: graphic.cpp:423
void Draw(int x, int y)
Definition: mng.cpp:248
Font definition.
Definition: font.h:73
int iteration
Definition: video.h:208
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:212
bool Resized
Uses of this graphic.
Definition: video.h:151
EventCallback EditorCallbacks
Game callbacks.
Definition: mainloop.cpp:68
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:1069
void FreeOpenGLGraphics()
Free OpenGL graphics.
Definition: graphic.cpp:837
int ViewportWidth
Definition: video.h:377
void MakePlayerColorTexture(CPlayerColorGraphic *graphic, int player)
Make an OpenGL texture of the player color pixels only.
Definition: graphic.cpp:1267
bool UseGLTextureCompression
Use OpenGL texture compression.
Definition: sdl.cpp:117
int Width
Definition: video.h:145
void FillTransCircleClip(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:2252
int VideoSyncSpeed
Definition: video.cpp:178
GLfloat texture_width
Definition: video.h:210
Uint32 ColorGray
Definition: video.cpp:188
GLint GLMaxTextureSizeOverride
User-specified limit for GLMaxTextureSize.
Definition: sdl.cpp:115
int Height
Width of a frame.
Definition: video.h:146
std::string name
Definition: video.h:202
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB
Definition: sdl.cpp:142
void InitVideo()
initialize the video part
Definition: video.cpp:319
void FillRectangle(Uint32 color, int x, int y, int w, int h)
Definition: linedraw.cpp:2129
void FillTransCircle(Uint32 color, int x, int y, int radius, unsigned char alpha)
Definition: linedraw.cpp:2230
Uint32 ColorDarkGray
Definition: video.cpp:189
SDL_Surface * TheScreen
The SDL screen.
Definition: sdl.cpp:108
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:156
void DrawHLine(Uint32 color, int x, int y, int width)
Definition: linedraw.cpp:1994
Uint32 ColorYellow
Definition: video.cpp:192
Uint32 ColorLightBlue
Definition: video.cpp:183
const EventCallback * GetCallbacks()
Get the current callbacks.
Definition: sdl.cpp:899
char VideoForceFullScreen
Fullscreen or windowed set from commandline.
Definition: video.cpp:165
unsigned char A
Blue.
Definition: color.h:56
unsigned char * buffer
Definition: video.h:206
Uint32 ColorGreen
Definition: video.cpp:191
Uint32 MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: video.h:331
void(* NetworkEvent)()
Callback for network event.
Definition: video.h:242
~CGraphic()
Definition: video.h:83
GLuint * PlayerColorTextures[PlayerMax]
Definition: video.h:186
void DrawLineClip(Uint32 color, const PixelPos &pos1, const PixelPos &pos2)
Definition: linedraw.cpp:2061
void ColorCycle()
Does ColorCycling..
Definition: video.cpp:451
void AddColorCyclingRange(unsigned int begin, unsigned int end)
Definition: video.cpp:390
void VideoPaletteListRemove(SDL_Surface *surface)
Definition: video.cpp:375
unsigned char G
Red.
Definition: color.h:54
int NumColorCycles
Texture names.
Definition: video.h:159
Uint32 ColorBlack
Editor callbacks.
Definition: video.cpp:181
Uint32 ColorWhite
Definition: video.cpp:186
void SetClipping(int left, int top, int right, int bottom)
Definition: video.cpp:207
void Resize(int w, int h)
Definition: graphic.cpp:1284
void DrawFrameClipX(unsigned frame, int x, int y) const
Definition: graphic.cpp:344
virtual int getWidth() const
Definition: video.h:135
Definition: video.h:193
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB
Definition: sdl.cpp:139
bool TransparentPixel(int x, int y)
Definition: graphic.cpp:1470
void SetColorCycleAll(bool value)
Definition: video.cpp:395
unsigned long SlowFrameCounter
Counts quantity of slow frames.
Definition: video.cpp:169
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:131
void DrawFrameClip(unsigned frame, int x, int y) const
Definition: graphic.cpp:217
int GraphicHeight
Original graphic width.
Definition: video.h:149
GLfloat texture_height
Width of the texture.
Definition: video.h:211
int ViewportHeight
Actual width of the window.
Definition: video.h:378
CGraphic()
Definition: video.h:73
CPlayerColorGraphic()
Definition: video.h:168
frame_pos_t * frame_map
Flipped surface.
Definition: video.h:142
CVideo()
Definition: video.h:270
int GraphicWidth
Number of frames.
Definition: video.h:148
void ToggleFullScreen()
Toggle full screen mode.
Definition: sdl.cpp:1083
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:781
Uint32 ColorOrange
Definition: video.cpp:185
void ReloadOpenGL()
Reload OpenGL.
Definition: sdl.cpp:338
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB
Definition: sdl.cpp:141
void VideoPaletteListAdd(SDL_Surface *surface)
Definition: video.cpp:355
void(* ButtonPressed)(unsigned buttons)
Callback for mouse button press.
Definition: video.h:226
void(* KeyReleased)(unsigned keycode, unsigned keychar)
Callback for key release.
Definition: video.h:237
std::string HashFile
Filename.
Definition: video.h:139
void DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha)
Definition: linedraw.cpp:2005
bool FullScreen
Definition: video.h:384
void VideoCclRegister()
register lua function
Definition: video.cpp:342
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:412
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:136
int NumTextures
Texture names.
Definition: video.h:157
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB
Definition: sdl.cpp:136
CVideo Video
Do SDL hardware unlock.
Definition: video.cpp:155
bool ResizeScreen(int width, int height)
Definition: video.cpp:274
void UnlockScreen()
Definition: video.cpp:256
Uint32 MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
Definition: video.h:316
void Flip()
Definition: graphic.cpp:888
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB
Definition: sdl.cpp:138
GLfloat TextureHeight
Width of the texture.
Definition: video.h:155
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:150
void PushClipping()
Push current clipping.
Definition: video.cpp:222
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:140
const char * SdlKey2Str(int key)
Convert a SDLKey to a string.
Definition: sdl.cpp:1029
void DrawPlayerColorFrameClip(int player, unsigned frame, int x, int y)
Definition: graphic.cpp:270
unsigned long FrameCounter
Counts frames.
Definition: video.cpp:168
void DrawFrame(unsigned frame, int x, int y) const
Definition: graphic.cpp:177
void GenFramesMap()
Definition: graphic.cpp:630
SDL_Surface * Surface
Filename used in hash.
Definition: video.h:140
(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.