44 #define GL_GLEXT_PROTOTYPES 1
46 #include "SDL_opengl.h"
57 #if defined(USE_OPENGL) || defined(USE_GLES)
76 #if defined(USE_OPENGL) || defined(USE_GLES)
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;
93 unsigned char alpha)
const;
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;
101 void DrawFrameTrans(
unsigned frame,
int x,
int y,
int alpha)
const;
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;
114 static CGraphic *
New(
const std::string &file,
int w = 0,
int h = 0);
119 #if defined(USE_OPENGL) || defined(USE_GLES)
123 void Load(
bool grayscale =
false);
126 void Resize(
int w,
int h);
153 #if defined(USE_OPENGL) || defined(USE_GLES)
170 #if defined(USE_OPENGL) || defined(USE_GLES)
185 #if defined(USE_OPENGL) || defined(USE_GLES)
200 void Draw(
int x,
int y);
209 #if defined(USE_OPENGL) || defined(USE_GLES)
246 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
251 #define RMASK 0x000000ff
252 #define GMASK 0x0000ff00
253 #define BMASK 0x00ff0000
254 #define AMASK 0xff000000
260 #define RMASK 0xff000000
261 #define GMASK 0x00ff0000
262 #define BMASK 0x0000ff00
263 #define AMASK 0x000000ff
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);
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);
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);
294 void DrawTransLineClip(Uint32 color,
int sx,
int sy,
int dx,
int dy,
unsigned char alpha);
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);
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);
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);
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);
316 inline Uint32
MapRGB(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b)
318 #if defined(USE_OPENGL) || defined(USE_GLES)
320 return MapRGBA(f, r, g, b, 0xFF);
324 return SDL_MapRGB(f, r, g, b);
329 return MapRGB(f, color.
R, color.
G, color.
B);
331 inline Uint32
MapRGBA(SDL_PixelFormat *f, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
333 #if defined(USE_OPENGL) || defined(USE_GLES)
339 return SDL_MapRGBA(f, r, g, b, a);
344 return MapRGBA(f, color.
R, color.
G, color.
B, color.
A);
346 inline void GetRGB(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b)
348 #if defined(USE_OPENGL) || defined(USE_GLES)
350 *r = (c >>
RSHIFT) & 0xff;
351 *g = (c >>
GSHIFT) & 0xff;
352 *b = (c >>
BSHIFT) & 0xff;
356 SDL_GetRGB(c, f, r, g, b);
359 inline void GetRGBA(Uint32 c, SDL_PixelFormat *f, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
361 #if defined(USE_OPENGL) || defined(USE_GLES)
363 *r = (c >>
RSHIFT) & 0xff;
364 *g = (c >>
GSHIFT) & 0xff;
365 *b = (c >>
BSHIFT) & 0xff;
366 *a = (c >>
ASHIFT) & 0xff;
370 SDL_GetRGBA(c, f, r, g, b, a);
376 #if defined(USE_OPENGL) || defined(USE_GLES)
380 #if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
381 SDL_Cursor *blankCursor;
419 #if defined(USE_OPENGL) || defined(USE_GLES)
445 #if defined(USE_OPENGL) || defined(USE_GLES)
479 extern void SetClipping(
int left,
int top,
int right,
int bottom);
534 #if defined(USE_OPENGL) || defined(USE_GLES)
536 int ex,
int ey,
int x,
int y,
int flip);
543 #if defined(USE_OPENGL) && !defined(__APPLE__)
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
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
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
void RestoreColorCyclingSurface()
Definition: video.cpp:479
void DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha)
Definition: linedraw.cpp:1960
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
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
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