_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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
Classes
video.h File Reference
#include "SDL.h"
#include "GLES/gl.h"
#include "SDL_opengl.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  CGraphic
 
class  CPlayerColorGraphic
 
class  Mng
 
struct  EventCallback
 
class  CVideo
 

video.h - The video headerfile.

#define RSHIFT   0
 
#define GSHIFT   8
 
#define BSHIFT   16
 
#define ASHIFT   24
 
#define RMASK   0x000000ff
 
#define GMASK   0x0000ff00
 
#define BMASK   0x00ff0000
 
#define AMASK   0xff000000
 
char ForceUseOpenGL
 
bool UseOpenGL
 
bool ZoomNoResize
 Use OpenGL. More...
 
bool GLShaderPipelineSupported
 
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...
 
SDL_Surface * TheScreen
 The SDL screen. More...
 
GLint GLMaxTextureSize
 Max texture size supported on the video card. More...
 
GLint GLMaxTextureSizeOverride
 User-specified limit for GLMaxTextureSize. More...
 
bool GLTextureCompressionSupported
 Is OpenGL texture compression supported. More...
 
bool UseGLTextureCompression
 Use OpenGL texture compression. 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
 
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB
 
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB
 
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB
 
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB
 
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB
 
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB
 
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB
 
void SetPlayersPalette ()
 
void VideoCclRegister ()
 register lua function 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...
 
int LoadGraphicPNG (CGraphic *g)
 Load graphic from PNG file. More...
 
void MakeTexture (CGraphic *graphic)
 Make an OpenGL texture. More...
 
void MakePlayerColorTexture (CPlayerColorGraphic *graphic, int player)
 Make an OpenGL texture of the player color pixels only. More...
 
void ValidateOpenGLScreen ()
 Regenerate Window screen if needed. More...
 
void FreeOpenGLGraphics ()
 Free OpenGL graphics. More...
 
void ReloadGraphics ()
 Reload OpenGL graphics. More...
 
void ReloadOpenGL ()
 Reload OpenGL. 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...
 
void DrawTexture (const CGraphic *g, GLuint *textures, int sx, int sy, int ex, int ey, int x, int y, int flip)
 
void FreeGraphics ()
 
void VideoPaletteListAdd (SDL_Surface *surface)
 
void VideoPaletteListRemove (SDL_Surface *surface)
 
void ClearAllColorCyclingRange ()
 
void AddColorCyclingRange (unsigned int begin, unsigned int end)
 
void SetColorCycleAll (bool value)
 
void RestoreColorCyclingSurface ()
 
void ColorCycle ()
 Does ColorCycling.. More...
 

Macro Definition Documentation

#define AMASK   0xff000000
#define ASHIFT   24
#define BMASK   0x00ff0000
#define BSHIFT   16
#define GMASK   0x0000ff00
#define GSHIFT   8
#define RMASK   0x000000ff
#define RSHIFT   0

Function Documentation

void AddColorCyclingRange ( unsigned int  begin,
unsigned int  end 
)
void ClearAllColorCyclingRange ( )
void ColorCycle ( )

Does ColorCycling..

Color cycle.

MACRO defines speed of colorcycling FIXME: should be made configurable

void DeInitVideo ( )

deinitliaize the video part

void DrawTexture ( const CGraphic g,
GLuint *  textures,
int  gx_beg,
int  gy_beg,
int  gx_end,
int  gy_end,
int  sx_beg,
int  sy_beg,
int  flip 
)

Draw a rectangular part of a CGraphic to the screen.

This function does not attempt to clip the CGraphic based on the screen coordinates. If the caller wants clipping, it can set the parameters accordingly, or perhaps configure OpenGL to clip the output.

Parameters
gThe graphic to be drawn. It may consist of multiple OpenGL textures if it is too large to fit in one texture.
texturesThe OpenGL textures to be drawn. There must be g->NumTextures elements in the array. These textures may be the same as g->Textures, or perhaps variants of them with different colors for a specific player.
gx_begX coordinate of the left side of the rectangle to be drawn from *g.
gy_begY coordinate of the top of the rectangle to be drawn from *g.
gx_endX coordinate of the right side of the rectangle to be drawn from *g.
gy_endY coordinate of the bottom of the rectangle to be drawn from *g.
sx_begX coordinate of the left side of the graphic on the screen.
sy_begY coordinate of the top of the graphic on the screen.
flipWhether to flip the graphic in the X direction. In any case, the graphic will extend from sx_beg to (gx_end - gx_beg + sx_beg) on the screen. Flipping controls which of those values corresponds to gx_beg and which one to gx_end.
void FreeGraphics ( )
void FreeOpenGLGraphics ( )

Free OpenGL graphics.

Free OpenGL graphics

const EventCallback* GetCallbacks ( )

Get the current callbacks.

Get the current callbacks

unsigned long GetTicks ( )

Returns the ticks in ms since start.

Return ticks in ms since start.

void InitLineDraw ( )

Init line draw.

Initialize line draw

void InitVideo ( )

initialize the video part

Video initialize.

void Invalidate ( )

Simply invalidates whole window or screen.

Invalidate whole window

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.
int LoadGraphicPNG ( CGraphic g)

Load graphic from PNG file.

Load a png graphic file. Modified function from SDL_Image

Parameters
ggraphic to load.
Returns
0 for success, -1 for error.
void MakePlayerColorTexture ( CPlayerColorGraphic g,
int  player 
)

Make an OpenGL texture of the player color pixels only.

Make an OpenGL texture with the player colors.

Parameters
gThe graphic to texture with player colors.
playerPlayer number to make textures for.
void MakeTexture ( CGraphic g)

Make an OpenGL texture.

Make an OpenGL texture or textures out of a graphic object.

Parameters
gThe graphic object.
void PopClipping ( )

Pop current clipping.

Pop current clipping.

void PushClipping ( )

Push current clipping.

Push current clipping.

void RealizeVideoMemory ( )

Realize video memory.

Realize video memory.

void ReloadGraphics ( )

Reload OpenGL graphics.

Reload OpenGL graphics

void ReloadOpenGL ( )

Reload OpenGL.

void RestoreColorCyclingSurface ( )
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.
void SaveScreenshotPNG ( const char *  name)

Save a screenshot to a PNG file.

Save a screenshot to a PNG file.

Parameters
namePNG filename to save.
bool SdlGetGrabMouse ( )

Check if the mouse is grabbed.

Check if the mouse is grabbed

const char* SdlKey2Str ( int  key)

Convert a SDLKey to a string.

Convert a SDLKey to a string

void SetCallbacks ( const EventCallback callbacks)

Set the current callbacks.

Set the current callbacks

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.
void SetColorCycleAll ( bool  value)
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.
void SetVideoSync ( )

Initializes video synchronization.

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

See also
VideoSyncSpeed
SkipFrames
FrameTicks
void ToggleFullScreen ( )

Toggle full screen mode.

Toggle full screen mode.

void ToggleGrabMouse ( int  mode)

Toggle mouse grab mode.

Toggle grab mouse.

Parameters
modeWanted mode, 1 grab, -1 not grab, 0 toggle.
void ValidateOpenGLScreen ( )

Regenerate Window screen if needed.

void VideoCclRegister ( )

register lua function

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.
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.
int VideoValidResolution ( int  w,
int  h 
)

Check if a resolution is valid.

Check if a resolution is valid

Parameters
wWidth
hHeight
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

Uint32 ColorBlack

Editor callbacks.

Editor callbacks.

Uint32 ColorBlue
Uint32 ColorDarkGray
Uint32 ColorDarkGreen
Uint32 ColorGray
Uint32 ColorGreen
Uint32 ColorLightBlue
Uint32 ColorLightGray
Uint32 ColorOrange
Uint32 ColorRed
Uint32 ColorWhite
Uint32 ColorYellow
EventCallback EditorCallbacks

Game callbacks.

char ForceUseOpenGL
unsigned long FrameCounter

Counts frames.

Counts frames.

EventCallback GameCallbacks
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB
GLint GLMaxTextureSize

Max texture size supported on the video card.

GLint GLMaxTextureSizeOverride

User-specified limit for GLMaxTextureSize.

User-specified limit for GLMaxTextureSize.

bool GLShaderPipelineSupported
bool GLTextureCompressionSupported

Is OpenGL texture compression supported.

Is OpenGL texture compression supported.

double NextFrameTicks

Next frame ticks.

Next frame ticks.

int SkipFrames

0 disable interrupts

unsigned long SlowFrameCounter

Counts quantity of slow frames.

Counts quantity of slow frames.

SDL_Surface* TheScreen

The SDL screen.

bool UseGLTextureCompression

Use OpenGL texture compression.

Use OpenGL texture compression.

bool UseOpenGL
CVideo Video

Do SDL hardware unlock.

char VideoForceFullScreen

Fullscreen or windowed set from commandline.

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
bool ZoomNoResize

Use OpenGL.

(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.