_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"
#include <map>
#include <string>
#include <vector>
#include <limits.h>
#include <math.h>
#include "SDL.h"
#include "SDL_syswm.h"
#include "GLES/gl.h"
#include "SDL_opengl.h"
#include "shaders.h"
#include <sys/socket.h>
#include <shellapi.h>
#include "editor.h"
#include "font.h"
#include "game.h"
#include "interface.h"
#include "minimap.h"
#include "network.h"
#include "parameters.h"
#include "sound.h"
#include "sound_server.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "video.h"
#include "widgets.h"
sdl.cpp - SDL video support. | |
SDL_Surface * | TheScreen |
The SDL screen. More... | |
static SDL_Rect | Rects [100] |
Internal screen. More... | |
static int | NumRects |
GLint | GLMaxTextureSize = 256 |
Max texture size supported on the video card. More... | |
GLint | GLMaxTextureSizeOverride |
Max texture size supported on the video card. More... | |
bool | GLTextureCompressionSupported |
User-specified limit for GLMaxTextureSize. More... | |
bool | UseGLTextureCompression |
Is OpenGL texture compression supported. More... | |
static std::map< int, std::string > | Key2Str |
Use OpenGL texture compression. More... | |
static std::map< std::string, int > | Str2Key |
double | FrameTicks |
const EventCallback * | Callbacks |
Frame length in ms. More... | |
static bool | RegenerateScreen = false |
bool | IsSDLWindowVisible = true |
Flag telling if the SDL window is visible. More... | |
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC | glCompressedTexImage3DARB |
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC | glCompressedTexImage2DARB |
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC | glCompressedTexImage1DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC | glCompressedTexSubImage3DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC | glCompressedTexSubImage2DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC | glCompressedTexSubImage1DARB |
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC | glGetCompressedTexImageARB |
void | SetVideoSync () |
Initializes video synchronization. More... | |
static bool | IsExtensionSupported (const char *extension) |
static void | InitOpenGLExtensions () |
static void | InitOpenGL () |
void | ReloadOpenGL () |
Reload OpenGL. More... | |
static void | InitKey2Str () |
void | InitVideoSdl () |
int | VideoValidResolution (int w, int h) |
Check if a resolution is valid. More... | |
void | InvalidateArea (int x, int y, int w, int h) |
void | Invalidate () |
Simply invalidates whole window or screen. More... | |
static void | SdlDoEvent (const EventCallback &callbacks, SDL_Event &event) |
void | ValidateOpenGLScreen () |
Regenerate Window screen if needed. More... | |
void | SetCallbacks (const EventCallback *callbacks) |
Set the current callbacks. More... | |
const EventCallback * | GetCallbacks () |
Get the current callbacks. More... | |
void | WaitEventsOneFrame () |
Process all system events. Returns if the time for a frame is over. More... | |
void | RealizeVideoMemory () |
Realize video memory. More... | |
void | SdlLockScreen () |
Init SDL video hardware driver. More... | |
void | SdlUnlockScreen () |
Do SDL hardware lock. More... | |
const char * | SdlKey2Str (int key) |
Convert a SDLKey to a string. More... | |
int | Str2SdlKey (const char *str) |
bool | SdlGetGrabMouse () |
Check if the mouse is grabbed. More... | |
void | ToggleGrabMouse (int mode) |
Toggle mouse grab mode. More... | |
void | ToggleFullScreen () |
Toggle full screen mode. More... | |
const EventCallback* GetCallbacks | ( | ) |
Get the current callbacks.
Get the current callbacks
|
static |
Initialize SDLKey to string map
|
static |
Initialize OpenGL
|
static |
Initialize OpenGL extensions
void InitVideoSdl | ( | ) |
Initialize the video part for SDL.
void Invalidate | ( | ) |
Simply invalidates whole window or screen.
Invalidate whole window
void InvalidateArea | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Invalidate some area
x | screen pixel X position. |
y | screen pixel Y position. |
w | width of rectangle in pixels. |
h | height of rectangle in pixels. |
|
static |
Check if an extension is supported
void RealizeVideoMemory | ( | ) |
Realize video memory.
Realize video memory.
void ReloadOpenGL | ( | ) |
Reload OpenGL.
|
static |
Handle interactive input event.
callbacks | Callback structure for events. |
event | SDL event structure pointer. |
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 SdlLockScreen | ( | ) |
Init SDL video hardware driver.
Lock the screen for write access.
void SdlUnlockScreen | ( | ) |
Do SDL hardware lock.
Unlock the screen for write access.
void SetCallbacks | ( | const EventCallback * | callbacks | ) |
Set the current callbacks.
Set the current callbacks
void SetVideoSync | ( | ) |
Initializes video synchronization.
Initialise video sync. Calculate the length of video frame and any simulation skips.
int Str2SdlKey | ( | const char * | str | ) |
Convert a string to SDLKey
void ToggleFullScreen | ( | ) |
Toggle full screen mode.
Toggle full screen mode.
void ToggleGrabMouse | ( | int | mode | ) |
Toggle mouse grab mode.
Toggle grab mouse.
mode | Wanted mode, 1 grab, -1 not grab, 0 toggle. |
void ValidateOpenGLScreen | ( | ) |
Regenerate Window screen if needed.
int VideoValidResolution | ( | int | w, |
int | h | ||
) |
Check if a resolution is valid.
Check if a resolution is valid
w | Width |
h | Height |
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.
const EventCallback* Callbacks |
Frame length in ms.
double FrameTicks |
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB |
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB |
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB |
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB |
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB |
GLint GLMaxTextureSize = 256 |
Max texture size supported on the video card.
GLint GLMaxTextureSizeOverride |
Max texture size supported on the video card.
User-specified limit for GLMaxTextureSize.
bool GLTextureCompressionSupported |
User-specified limit for GLMaxTextureSize.
Is OpenGL texture compression supported.
bool IsSDLWindowVisible = true |
Flag telling if the SDL window is visible.
|
static |
Use OpenGL texture compression.
|
static |
|
static |
Internal screen.
|
static |
|
static |
SDL_Surface* TheScreen |
The SDL screen.
bool UseGLTextureCompression |
Is OpenGL texture compression supported.
Use OpenGL texture compression.