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

Classes
video.h File Reference
#include "SDL.h"
#include "shaders.h"
#include "guichan.h"
#include "color.h"
#include "vec2i.h"
#include <libmng.h>

Go to the source code of this file.

Classes

class  PixelModifier
 Class for modifiers for custom pixel manipulations. More...
 
class  CGraphic
 
struct  CGraphic::frame_pos_t
 
class  CPlayerColorGraphic
 
class  Mng
 
struct  EventCallback
 
class  CVideo
 

video.h - The video headerfile.

#define RSHIFT   16
 
#define GSHIFT   8
 
#define BSHIFT   0
 
#define ASHIFT   24
 
#define RMASK   0x00ff0000
 
#define GMASK   0x0000ff00
 
#define BMASK   0x000000ff
 
#define AMASK   0xff000000
 
using pixelModifier = uint32_t(*)(const uint32_t, const uint32_t, const uint32_t)
 
SDL_Window * TheWindow
 The SDL screen. More...
 
SDL_Renderer * TheRenderer
 Internal screen. More...
 
SDL_Surface * TheScreen
 Internal screen. More...
 
SDL_Texture * TheTexture
 Internal screen. More...
 
CVideo Video
 Do SDL hardware unlock. More...
 
int VideoSyncSpeed
 
int SkipFrames
 0 disable interrupts More...
 
char VideoForceFullScreen
 Fullscreen or windowed set from commandline. More...
 
double NextFrameTicks
 Next frame ticks. More...
 
unsigned long FrameCounter
 Counts frames. More...
 
unsigned long SlowFrameCounter
 Counts quantity of slow frames. More...
 
EventCallback GameCallbacks
 
EventCallback EditorCallbacks
 Game callbacks. More...
 
Uint32 ColorBlack
 Editor callbacks. More...
 
Uint32 ColorDarkGreen
 
Uint32 ColorLightBlue
 
Uint32 ColorBlue
 
Uint32 ColorOrange
 
Uint32 ColorWhite
 
Uint32 ColorLightGray
 
Uint32 ColorGray
 
Uint32 ColorDarkGray
 
Uint32 ColorRed
 
Uint32 ColorGreen
 
Uint32 ColorYellow
 
static const char * ColorNames []
 
void SetPlayersPalette ()
 
void VideoCclRegister ()
 register lua function More...
 
void InitImageLoaders ()
 initialize the image loaders part More...
 
void DeInitImageLoaders ()
 deinitialize the image loaders More...
 
void InitVideo ()
 initialize the video part More...
 
void DeInitVideo ()
 deinitliaize the video part More...
 
int VideoValidResolution (int w, int h)
 Check if a resolution is valid. More...
 
void SetVideoSync ()
 Initializes video synchronization. More...
 
void InitLineDraw ()
 Init line draw. More...
 
void Invalidate ()
 Simply invalidates whole window or screen. More...
 
void InvalidateArea (int x, int y, int w, int h)
 
void SetClipping (int left, int top, int right, int bottom)
 
void RealizeVideoMemory ()
 Realize video memory. More...
 
void SaveScreenshotPNG (const char *name)
 Save a screenshot to a PNG file. More...
 
void SaveMapPNG (const char *name)
 Save a screenshot to a PNG file. More...
 
void SetCallbacks (const EventCallback *callbacks)
 Set the current callbacks. More...
 
const EventCallbackGetCallbacks ()
 Get the current callbacks. More...
 
void WaitEventsOneFrame ()
 Process all system events. Returns if the time for a frame is over. More...
 
void ToggleFullScreen ()
 Toggle full screen mode. More...
 
void PushClipping ()
 Push current clipping. More...
 
void PopClipping ()
 Pop current clipping. More...
 
unsigned long GetTicks ()
 Returns the ticks in ms since start. More...
 
const char * SdlKey2Str (int key)
 Convert a SDLKey to a string. More...
 
bool SdlGetGrabMouse ()
 Check if the mouse is grabbed. More...
 
void ToggleGrabMouse (int mode)
 Toggle mouse grab mode. More...
 
Uint32 IndexToColor (unsigned int index)
 
int GetColorIndexByName (const char *colorName)
 
void FreeGraphics ()
 
void VideoPaletteListAdd (SDL_Surface *surface)
 
void VideoPaletteListRemove (SDL_Surface *surface)
 
void ClearAllColorCyclingRange ()
 
void AddColorCyclingRange (unsigned int begin, unsigned int end)
 
unsigned int SetColorCycleSpeed (unsigned int speed)
 
void SetColorCycleAll (bool value)
 
void RestoreColorCyclingSurface ()
 
void ColorCycle ()
 Does ColorCycling.. More...
 
void BlitSurfaceAlphaBlending_32bpp (const SDL_Surface *srcSurface, const SDL_Rect *srcRect, SDL_Surface *dstSurface, const SDL_Rect *dstRect, const bool enableMT=true)
 Blit a surface into another with alpha blending. More...
 

Macro Definition Documentation

◆ AMASK

#define AMASK   0xff000000

◆ ASHIFT

#define ASHIFT   24

◆ BMASK

#define BMASK   0x000000ff

◆ BSHIFT

#define BSHIFT   0

◆ GMASK

#define GMASK   0x0000ff00

◆ GSHIFT

#define GSHIFT   8

◆ RMASK

#define RMASK   0x00ff0000

◆ RSHIFT

#define RSHIFT   16

Typedef Documentation

◆ pixelModifier

using pixelModifier = uint32_t(*)(const uint32_t, const uint32_t, const uint32_t)

Function Documentation

◆ AddColorCyclingRange()

void AddColorCyclingRange ( unsigned int  begin,
unsigned int  end 
)

◆ BlitSurfaceAlphaBlending_32bpp()

void BlitSurfaceAlphaBlending_32bpp ( const SDL_Surface *  srcSurface,
const SDL_Rect *  srcRect,
SDL_Surface *  dstSurface,
const SDL_Rect *  dstRect,
const bool  enableMT = true 
)

Blit a surface into another with alpha blending.

This implementation of blittind doesn't scale

Crop rectangles if necessary

Alpha blending of the src texture into the dst

TODO: change numOfThreads for small rectangles to prevent False Sharing

pragma omp parallel

◆ ClearAllColorCyclingRange()

void ClearAllColorCyclingRange ( )

◆ ColorCycle()

void ColorCycle ( )

Does ColorCycling..

Color cycle.

MACRO defines speed of colorcycling FIXME: should be made configurable

◆ DeInitImageLoaders()

void DeInitImageLoaders ( )

deinitialize the image loaders

◆ DeInitVideo()

void DeInitVideo ( )

deinitliaize the video part

◆ FreeGraphics()

void FreeGraphics ( )

◆ GetCallbacks()

const EventCallback* GetCallbacks ( )

Get the current callbacks.

Get the current callbacks

◆ GetColorIndexByName()

int GetColorIndexByName ( const char *  colorName)
inline

◆ GetTicks()

unsigned long GetTicks ( )

Returns the ticks in ms since start.

Return ticks in ms since start.

◆ IndexToColor()

Uint32 IndexToColor ( unsigned int  index)
inline

◆ InitImageLoaders()

void InitImageLoaders ( )

initialize the image loaders part

◆ InitLineDraw()

void InitLineDraw ( )

Init line draw.

Initialize line draw

◆ InitVideo()

void InitVideo ( )

initialize the video part

Video initialize.

◆ Invalidate()

void Invalidate ( )

Simply invalidates whole window or screen.

Invalidate whole window

◆ InvalidateArea()

void InvalidateArea ( int  x,
int  y,
int  w,
int  h 
)

Invalidates selected area on window or screen. Use for accurate redrawing. in so

Invalidate some area

Parameters
xscreen pixel X position.
yscreen pixel Y position.
wwidth of rectangle in pixels.
hheight of rectangle in pixels.

◆ PopClipping()

void PopClipping ( )

Pop current clipping.

Pop current clipping.

◆ PushClipping()

void PushClipping ( )

Push current clipping.

Push current clipping.

◆ RealizeVideoMemory()

void RealizeVideoMemory ( )

Realize video memory.

◆ RestoreColorCyclingSurface()

void RestoreColorCyclingSurface ( )

◆ SaveMapPNG()

void SaveMapPNG ( const char *  name)

Save a screenshot to a PNG file.

Save a whole map to a PNG file.

Parameters
namePNG filename to save.

◆ SaveScreenshotPNG()

void SaveScreenshotPNG ( const char *  name)

Save a screenshot to a PNG file.

Save a screenshot to a PNG file.

Parameters
namePNG filename to save.

◆ SdlGetGrabMouse()

bool SdlGetGrabMouse ( )

Check if the mouse is grabbed.

Check if the mouse is grabbed

◆ SdlKey2Str()

const char* SdlKey2Str ( int  key)

Convert a SDLKey to a string.

Convert a SDLKey to a string

◆ SetCallbacks()

void SetCallbacks ( const EventCallback callbacks)

Set the current callbacks.

Set the current callbacks

◆ SetClipping()

void SetClipping ( int  left,
int  top,
int  right,
int  bottom 
)

Set clipping for nearly all vector primitives. Functions which support clipping will be marked Clip. Set the system-wide clipping rectangle.

Set clipping for graphic routines.

Parameters
leftLeft X screen coordinate.
topTop Y screen coordinate.
rightRight X screen coordinate.
bottomBottom Y screen coordinate.

◆ SetColorCycleAll()

void SetColorCycleAll ( bool  value)

◆ SetColorCycleSpeed()

unsigned int SetColorCycleSpeed ( unsigned int  speed)

Set the Color Cycle speed.

Returns
the previous speed

◆ SetPlayersPalette()

void SetPlayersPalette ( )

Initialize Pixels[] for all players. (bring Players[] in sync with Pixels[])

Setup the player colors for the current palette.

Todo:
FIXME: could be called before PixelsXX is setup.

◆ SetVideoSync()

void SetVideoSync ( )

Initializes video synchronization.

Initialise video sync. Calculate the length of video frame and any simulation skips.

See also
VideoSyncSpeed
SkipFrames
FrameTicks

◆ ToggleFullScreen()

void ToggleFullScreen ( )

Toggle full screen mode.

Toggle full screen mode.

◆ ToggleGrabMouse()

void ToggleGrabMouse ( int  mode)

Toggle mouse grab mode.

Toggle grab mouse.

Parameters
modeWanted mode, 1 grab, -1 not grab, 0 toggle.

◆ VideoCclRegister()

void VideoCclRegister ( )

register lua function

◆ VideoPaletteListAdd()

void VideoPaletteListAdd ( SDL_Surface *  surface)

Add a surface to the palette list, used for color cycling

Parameters
surfaceThe SDL surface to add to the list to cycle.

◆ VideoPaletteListRemove()

void VideoPaletteListRemove ( SDL_Surface *  surface)

Remove a surface to the palette list, used for color cycling

Parameters
surfaceThe SDL surface to add to the list to cycle.

◆ VideoValidResolution()

int VideoValidResolution ( int  w,
int  h 
)

Check if a resolution is valid.

Check if a resolution is valid

Parameters
wWidth
hHeight

◆ WaitEventsOneFrame()

void WaitEventsOneFrame ( )

Process all system events. Returns if the time for a frame is over.

Wait for interactive input event for one frame.

Handles system events, joystick, keyboard, mouse. Handles the network messages. Handles the sound queue.

All events available are fetched. Sound and network only if available. Returns if the time for one frame is over.

Variable Documentation

◆ ColorBlack

Uint32 ColorBlack

Editor callbacks.

Editor callbacks.

◆ ColorBlue

Uint32 ColorBlue

◆ ColorDarkGray

Uint32 ColorDarkGray

◆ ColorDarkGreen

Uint32 ColorDarkGreen

◆ ColorGray

Uint32 ColorGray

◆ ColorGreen

Uint32 ColorGreen

◆ ColorLightBlue

Uint32 ColorLightBlue

◆ ColorLightGray

Uint32 ColorLightGray

◆ ColorNames

const char* ColorNames[]
static
Initial value:
= {"red", "yellow", "green", "light-gray",
"gray", "dark-gray", "white", "orange",
"light-blue", "blue", "dark-green", "black", NULL}

◆ ColorOrange

Uint32 ColorOrange

◆ ColorRed

Uint32 ColorRed

◆ ColorWhite

Uint32 ColorWhite

◆ ColorYellow

Uint32 ColorYellow

◆ EditorCallbacks

EventCallback EditorCallbacks

Game callbacks.

◆ FrameCounter

unsigned long FrameCounter

Counts frames.

Counts frames.

◆ GameCallbacks

EventCallback GameCallbacks

◆ NextFrameTicks

double NextFrameTicks

Next frame ticks.

Next frame ticks.

◆ SkipFrames

int SkipFrames

0 disable interrupts

◆ SlowFrameCounter

unsigned long SlowFrameCounter

Counts quantity of slow frames.

Counts quantity of slow frames.

◆ TheRenderer

SDL_Renderer* TheRenderer

Internal screen.

◆ TheScreen

SDL_Surface* TheScreen

Internal screen.

◆ TheTexture

SDL_Texture* TheTexture

Internal screen.

◆ TheWindow

SDL_Window* TheWindow

The SDL screen.

◆ Video

CVideo Video

Do SDL hardware unlock.

◆ VideoForceFullScreen

char VideoForceFullScreen

Fullscreen or windowed set from commandline.

◆ VideoSyncSpeed

int VideoSyncSpeed

Video synchronization speed. Synchronization time in percent. If =0, video framerate is not synchronized. 100 is exact CYCLES_PER_SECOND (30). Game will try to redraw screen within intervals of VideoSyncSpeed, not more, not less.

See also
CYCLES_PER_SECOND
(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.