43 #include "SDL_opengl.h"
53 #if defined(USE_OPENGL) || defined(USE_GLES)
71 #if defined(USE_OPENGL) || defined(USE_GLES)
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;
87 unsigned char alpha)
const;
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;
95 void DrawFrameTrans(
unsigned frame,
int x,
int y,
int alpha)
const;
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;
108 static CGraphic *
New(
const std::string &file,
int w = 0,
int h = 0);
113 void Load(
bool grayscale =
false);
116 void Resize(
int w,
int h);
143 #if defined(USE_OPENGL) || defined(USE_GLES)
158 #if defined(USE_OPENGL) || defined(USE_GLES)
172 #if defined(USE_OPENGL) || defined(USE_GLES)
187 void Draw(
int x,
int y);
196 #if defined(USE_OPENGL) || defined(USE_GLES)
233 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
238 #define RMASK 0x000000ff
239 #define GMASK 0x0000ff00
240 #define BMASK 0x00ff0000
241 #define AMASK 0xff000000
247 #define RMASK 0xff000000
248 #define GMASK 0x00ff0000
249 #define BMASK 0x0000ff00
250 #define AMASK 0x000000ff
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);
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);
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);
281 void DrawTransLineClip(Uint32 color,
int sx,
int sy,
int dx,
int dy,
unsigned char alpha);
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);
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);
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);
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);
303 inline Uint32
MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
305 #if defined(USE_OPENGL) || defined(USE_GLES)
307 return MapRGBA(f, r, g, b, 0xFF);
311 return SDL_MapRGB(f, r, g, b);
316 return MapRGB(f, color.
R, color.
G, color.
B);
318 inline Uint32
MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
320 #if defined(USE_OPENGL) || defined(USE_GLES)
326 return SDL_MapRGBA(f, r, g, b, a);
331 return MapRGBA(f, color.
R, color.
G, color.
B, color.
A);
333 inline void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
335 #if defined(USE_OPENGL) || defined(USE_GLES)
337 *r = (c >>
RSHIFT) & 0xff;
338 *g = (c >>
GSHIFT) & 0xff;
339 *b = (c >>
BSHIFT) & 0xff;
343 SDL_GetRGB(c, f, r, g, b);
346 inline void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
348 #if defined(USE_OPENGL) || defined(USE_GLES)
350 *r = (c >>
RSHIFT) & 0xff;
351 *g = (c >>
GSHIFT) & 0xff;
352 *b = (c >>
BSHIFT) & 0xff;
353 *a = (c >>
ASHIFT) & 0xff;
357 SDL_GetRGBA(c, f, r, g, b, a);
363 #if defined(USE_OPENGL) || defined(USE_GLES)
367 #if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
368 SDL_Cursor *blankCursor;
406 #if defined(USE_OPENGL) || defined(USE_GLES)
432 #if defined(USE_OPENGL) || defined(USE_GLES)
466 extern void SetClipping(
int left,
int top,
int right,
int bottom);
521 #if defined(USE_OPENGL) || defined(USE_GLES)
523 int ex,
int ey,
int x,
int y,
int flip);
527 extern void FreeGraphics();
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
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
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
void RestoreColorCyclingSurface()
Definition: video.cpp:476
void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:1960
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
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
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