____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include "stratagus.h"
#include <map>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "video.h"
#include "font.h"
#include "interface.h"
#include "network.h"
#include "ui.h"
#include "sound_server.h"
#include "sound.h"
#include "minimap.h"
#include "widgets.h"
#include "editor.h"
Go to the source code of this file.
Functions | |
| void | SetVideoSync (void) |
| Init line draw. | |
| static bool | IsExtensionSupported (const char *extension) |
| static void | InitOpenGLExtensions () |
| static void | InitOpenGL (void) |
| void | ReloadOpenGL () |
| Initializes video synchronization. | |
| static void | InitKey2Str () |
| void | InitVideoSdl (void) |
| Init SDL video hardware driver. | |
| int | VideoValidResolution (int w, int h) |
| Load graphic from PNG file. | |
| void | InvalidateArea (int x, int y, int w, int h) |
| void | Invalidate (void) |
| static void | SdlDoEvent (const EventCallback *callbacks, const SDL_Event *event) |
| void | SetCallbacks (const EventCallback *callbacks) |
| Get the current callbacks. | |
| const EventCallback * | GetCallbacks () |
| Process all system events. Returns if the time for a frame is over. | |
| void | WaitEventsOneFrame () |
| Toggle full screen mode. | |
| void | RealizeVideoMemory (void) |
| Save a screenshot to a PNG file. | |
| void | SdlLockScreen (void) |
| Do SDL hardware lock. | |
| void | SdlUnlockScreen (void) |
| Do SDL hardware unlock. | |
| const char * | SdlKey2Str (int key) |
| Check if the mouse is grabbed. | |
| int | Str2SdlKey (const char *str) |
| bool | SdlGetGrabMouse (void) |
| Toggle mouse grab mode. | |
| void | ToggleGrabMouse (int mode) |
| void | ToggleFullScreen (void) |
| Push current clipping. | |
Variables | |
| SDL_Surface * | TheScreen |
| Internal screen. | |
| static SDL_Rect | Rects [100] |
| static int | NumRects |
| GLint | GLMaxTextureSize |
| Max texture size supported on the video card. | |
| bool | GLTextureCompressionSupported |
| Is OpenGL texture compression supported. | |
| bool | UseGLTextureCompression |
| Use OpenGL texture compression. | |
| static std::map< int, std::string > | Key2Str |
| static std::map< std::string, int > | Str2Key |
| static int | FrameTicks |
| Frame length in ms. | |
| static int | FrameRemainder |
| Frame remainder 0.1 ms. | |
| static int | FrameFraction |
| Frame fractional term. | |
| const EventCallback * | Callbacks |
| PFNGLCOMPRESSEDTEXIMAGE3DARBPROC | glCompressedTexImage3DARB |
| PFNGLCOMPRESSEDTEXIMAGE2DARBPROC | glCompressedTexImage2DARB |
| PFNGLCOMPRESSEDTEXIMAGE1DARBPROC | glCompressedTexImage1DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC | glCompressedTexSubImage3DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC | glCompressedTexSubImage2DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC | glCompressedTexSubImage1DARB |
| PFNGLGETCOMPRESSEDTEXIMAGEARBPROC | glGetCompressedTexImageARB |
Definition in file sdl.cpp.
| const EventCallback* GetCallbacks | ( | ) |
Process all system events. Returns if the time for a frame is over.
Get the current callbacks
Definition at line 610 of file sdl.cpp.
Referenced by EditorMainLoop(), GameMainLoop(), PatchEditorMainLoop(), PlayMovie(), MenuScreen::run(), SdlDoEvent(), ShowTitleImage(), and WaitEventsOneFrame().
| static void InitKey2Str | ( | ) | [static] |
Initialize SDLKey to string map
Definition at line 278 of file sdl.cpp.
References _, Key2Str, sprintf_s(), and Str2Key.
Referenced by InitVideoSdl(), and Str2SdlKey().
| static void InitOpenGL | ( | void | ) | [static] |
Initialize OpenGL
Definition at line 218 of file sdl.cpp.
References GLMaxTextureSize, CVideo::Height, InitOpenGLExtensions(), Video, and CVideo::Width.
Referenced by InitVideoSdl(), and ReloadOpenGL().
| static void InitOpenGLExtensions | ( | ) | [static] |
Initialize OpenGL extensions
Definition at line 181 of file sdl.cpp.
References glCompressedTexImage1DARB, glCompressedTexImage2DARB, glCompressedTexImage3DARB, glCompressedTexSubImage1DARB, glCompressedTexSubImage2DARB, glCompressedTexSubImage3DARB, glGetCompressedTexImageARB, GLTextureCompressionSupported, and IsExtensionSupported().
Referenced by InitOpenGL().
| void InitVideoSdl | ( | void | ) |
Init SDL video hardware driver.
Initialize the video part for SDL.
Definition at line 379 of file sdl.cpp.
References ColorBlack, ColorBlue, ColorDarkGreen, ColorGray, ColorGreen, ColorOrange, ColorRed, ColorWhite, ColorYellow, CVideo::Depth, CVideo::FullScreen, CVideo::Height, InitKey2Str(), InitOpenGL(), CVideo::MapRGB(), CUserInterface::MouseWarpX, CUserInterface::MouseWarpY, TheScreen, UI, UseOpenGL, Video, and CVideo::Width.
Referenced by InitVideo().
| void Invalidate | ( | void | ) |
Invalidate whole window
Definition at line 500 of file sdl.cpp.
References CVideo::Height, NumRects, Rects, UseOpenGL, Video, and CVideo::Width.
Referenced by EditorMainLoop(), EditorUpdateDisplay(), MenuLoop(), PatchEditorUpdateDisplay(), PlayMovie(), ShowTitleImage(), ShowTitleScreens(), StartEditor(), StartMap(), ToggleFullScreen(), and UpdateDisplay().
| 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. |
Definition at line 484 of file sdl.cpp.
References Assert, CVideo::Height, NumRects, Rects, UseOpenGL, Video, and CVideo::Width.
Referenced by ShowLoadProgress().
| static bool IsExtensionSupported | ( | const char * | extension | ) | [static] |
Check if an extension is supported
Definition at line 145 of file sdl.cpp.
Referenced by InitOpenGLExtensions().
| void RealizeVideoMemory | ( | void | ) |
Save a screenshot to a PNG file.
Realize video memory.
Definition at line 736 of file sdl.cpp.
References HideCursor(), NumRects, Rects, TheScreen, and UseOpenGL.
Referenced by EditorUpdateDisplay(), GameMainLoop(), PatchEditorUpdateDisplay(), PlayMovie(), MenuScreen::run(), ShowLoadProgress(), and ShowTitleImage().
| void ReloadOpenGL | ( | ) |
Initializes video synchronization.
Definition at line 255 of file sdl.cpp.
References InitOpenGL(), CUserInterface::Minimap, CMinimap::Reload(), ReloadFonts(), ReloadGraphics(), and UI.
Referenced by CVideo::ResizeScreen(), and ToggleFullScreen().
| static void SdlDoEvent | ( | const EventCallback * | callbacks, | |
| const SDL_Event * | event | |||
| ) | [static] |
Handle interactive input event.
| callbacks | Callback structure for events. | |
| event | SDL event structure pointer. |
Definition at line 517 of file sdl.cpp.
References Exit(), GamePaused, GetCallbacks(), handleInput(), CVideo::Height, InputKeyButtonPress(), InputKeyButtonRelease(), InputMouseButtonPress(), InputMouseButtonRelease(), InputMouseExit(), InputMouseMove(), CUserInterface::MouseWarpX, CUserInterface::MouseWarpY, CVideo::ResizeScreen(), UI, UiTogglePause(), UseOpenGL, Video, and CVideo::Width.
Referenced by WaitEventsOneFrame().
| bool SdlGetGrabMouse | ( | void | ) |
Toggle mouse grab mode.
Check if the mouse is grabbed
Definition at line 807 of file sdl.cpp.
Referenced by GetGrabMouse(), and ToggleGrabMouse().
| const char* SdlKey2Str | ( | int | key | ) |
Check if the mouse is grabbed.
Convert a SDLKey to a string
Definition at line 777 of file sdl.cpp.
References Key2Str.
Referenced by HandleCommandKey().
| void SdlLockScreen | ( | void | ) |
Do SDL hardware lock.
Lock the screen for write access.
Definition at line 753 of file sdl.cpp.
References TheScreen, and UseOpenGL.
Referenced by CVideo::LockScreen().
| void SdlUnlockScreen | ( | void | ) |
Do SDL hardware unlock.
Unlock the screen for write access.
Definition at line 765 of file sdl.cpp.
References TheScreen, and UseOpenGL.
Referenced by CVideo::UnlockScreen().
| void SetCallbacks | ( | const EventCallback * | callbacks | ) |
Get the current callbacks.
Set the current callbacks
Definition at line 602 of file sdl.cpp.
Referenced by EditorMainLoop(), GameMainLoop(), PatchEditorMainLoop(), PlayMovie(), MenuScreen::run(), ShowTitleImage(), and MenuScreen::stop().
| void SetVideoSync | ( | void | ) |
Init line draw.
Initialise video sync. Calculate the length of video frame and any simulation skips.
Definition at line 118 of file sdl.cpp.
References _C_, CYCLES_PER_SECOND, DebugPrint, FrameRemainder, FrameTicks, SkipFrames, and VideoSyncSpeed.
Referenced by EditorMainLoop(), GameMainLoop(), SetGameSpeed(), ShowTitleScreens(), UiDecreaseGameSpeed(), and UiIncreaseGameSpeed().
| int Str2SdlKey | ( | const char * | str | ) |
Convert a string to SDLKey
Definition at line 785 of file sdl.cpp.
References InitKey2Str(), Key2Str, and Str2Key.
Referenced by convertKey().
| void ToggleFullScreen | ( | void | ) |
Push current clipping.
Toggle full screen mode.
Definition at line 831 of file sdl.cpp.
References Exit(), CVideo::FullScreen, Invalidate(), ReloadOpenGL(), TheScreen, UseOpenGL, and Video.
Referenced by CommandKey(), EditorCallbackKeyDown(), PatchEditorCallbackKeyDown(), and tolua_stratagus_ToggleFullScreen00().
| void ToggleGrabMouse | ( | int | mode | ) |
Toggle grab mouse.
| mode | Wanted mode, 1 grab, -1 not grab, 0 toggle. |
Definition at line 817 of file sdl.cpp.
References SdlGetGrabMouse().
Referenced by SetGrabMouse(), and UiToggleGrabMouse().
| int VideoValidResolution | ( | int | w, | |
| int | h | |||
| ) |
Load graphic from PNG file.
Check if a resolution is valid
| w | Width | |
| h | Height |
Definition at line 471 of file sdl.cpp.
References TheScreen.
Referenced by CVideo::ResizeScreen().
| void WaitEventsOneFrame | ( | ) |
Toggle full screen mode.
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.
Definition at line 625 of file sdl.cpp.
References CVideo::ClearScreen(), CursorAnimate(), Editor, FrameCounter, FrameFraction, FrameRemainder, FrameTicks, GameRunning, GetCallbacks(), handleInput(), InputKeyTimeout(), InputMouseTimeout(), IsNetworkGame, _event_callback_::NetworkEvent, NetworkFildes, NextFrameTicks, PatchEditorRunning, CEditor::Running, SdlDoEvent(), SkipFrames, SkipGameCycle, SlowFrameCounter, UseOpenGL, and Video.
Referenced by EditorMainLoop(), GameMainLoop(), PatchEditorMainLoop(), PlayMovie(), MenuScreen::run(), and ShowTitleImage().
| const EventCallback* Callbacks |
int FrameFraction [static] |
int FrameRemainder [static] |
Frame remainder 0.1 ms.
Definition at line 90 of file sdl.cpp.
Referenced by SetVideoSync(), and WaitEventsOneFrame().
int FrameTicks [static] |
Frame length in ms.
Definition at line 89 of file sdl.cpp.
Referenced by SetVideoSync(), and WaitEventsOneFrame().
| PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB |
| PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB |
| PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB |
| PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB |
| PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB |
| GLint GLMaxTextureSize |
Max texture size supported on the video card.
Is OpenGL texture compression supported.
Definition at line 82 of file sdl.cpp.
Referenced by DrawTexture(), InitOpenGL(), MakeTextures(), and MakeTextures2().
Is OpenGL texture compression supported.
Use OpenGL texture compression.
Definition at line 83 of file sdl.cpp.
Referenced by InitOpenGLExtensions(), and MakeTextures2().
std::map<int, std::string> Key2Str [static] |
int NumRects [static] |
Definition at line 81 of file sdl.cpp.
Referenced by Invalidate(), InvalidateArea(), and RealizeVideoMemory().
SDL_Rect Rects[100] [static] |
Definition at line 80 of file sdl.cpp.
Referenced by Invalidate(), InvalidateArea(), and RealizeVideoMemory().
std::map<std::string, int> Str2Key [static] |
| SDL_Surface* TheScreen |
Internal screen.
Max texture size supported on the video card.
Definition at line 78 of file sdl.cpp.
Referenced by CclPlayer(), CMinimap::Create(), CMinimap::Draw(), DrawCursor(), CGraphic::DrawFrameClipTransX(), CGraphic::DrawFrameClipX(), CGraphic::DrawFrameTransX(), CGraphic::DrawFrameX(), DrawMenuButton(), MessagesDisplay::DrawMessages(), DrawPopup(), CGraphic::DrawSub(), DrawUnitOn(), gcn::SDLGraphics::fillRectangle(), linedraw_sdl::FillRectangle(), linedraw_sdl::FillRectangleClip(), HideCursor(), initGuichan(), InitPlayers(), InitUserInterface(), InitVideoSdl(), OutputTheora(), PlayMovie(), RealizeVideoMemory(), CVideo::ResizeScreen(), SavePlayers(), SaveScreenshotPNG(), SdlLockScreen(), SdlUnlockScreen(), ToggleFullScreen(), linedraw_sdl::VideoDoDrawPixel16(), linedraw_sdl::VideoDoDrawPixel32(), linedraw_sdl::VideoDoDrawTransPixel16(), linedraw_sdl::VideoDoDrawTransPixel32(), VideoDrawChar(), VideoDrawOnlyFog(), and VideoValidResolution().
Use OpenGL texture compression.
initialize the video part
Definition at line 84 of file sdl.cpp.
Referenced by MakeTextures2(), tolua_get_UseGLTextureCompression(), and tolua_set_UseGLTextureCompression().
1.5.6