____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "stratagus.h"
#include <vector>
#include "video.h"
#include "font.h"
#include "ui.h"
#include "cursor.h"
#include "iolib.h"
#include "intern_video.h"
#include "SDL.h"
Go to the source code of this file.
Classes | |
| struct | Clip |
Functions | |
| void | InitVideoSdl (void) |
| Init SDL video hardware driver. | |
| void | SdlLockScreen (void) |
| Do SDL hardware lock. | |
| void | SdlUnlockScreen (void) |
| Do SDL hardware unlock. | |
| void | SetClipping (int left, int top, int right, int bottom) |
| Realize video memory. | |
| void | PushClipping (void) |
| Pop current clipping. | |
| void | PopClipping (void) |
| Returns the ticks in ms since start. | |
| unsigned long | GetTicks (void) |
| Convert a SDLKey to a string. | |
| void | InitVideo (void) |
| Check if a resolution is valid. | |
Variables | |
| CVideo | Video |
| bool | UseOpenGL |
| Use OpenGL. | |
| char | VideoForceFullScreen |
| fullscreen set from commandline | |
| unsigned long | NextFrameTicks |
| Ticks of begin of the next frame. | |
| unsigned long | FrameCounter |
| Current frame number. | |
| int | SlowFrameCounter |
| Profile, frames out of sync. | |
| int | ClipX1 |
| current clipping top left | |
| int | ClipY1 |
| current clipping top left | |
| int | ClipX2 |
| current clipping bottom right | |
| int | ClipY2 |
| current clipping bottom right | |
| static std::vector< Clip > | Clips |
| int | VideoSyncSpeed = 100 |
| 0 disable interrupts | |
| int | SkipFrames |
| Skip this frames. | |
| Uint32 | ColorBlack |
| Uint32 | ColorDarkGreen |
| Uint32 | ColorBlue |
| Uint32 | ColorOrange |
| Uint32 | ColorWhite |
| Uint32 | ColorGray |
| Uint32 | ColorRed |
| Uint32 | ColorGreen |
| Uint32 | ColorYellow |
Definition in file video.cpp.
| unsigned long GetTicks | ( | void | ) |
Convert a SDLKey to a string.
Return ticks in ms since start.
Definition at line 261 of file video.cpp.
Referenced by MessagesDisplay::AddMessage(), DoScroll(), NetworkInitClientConnect(), NetworkSendRateLimitedClientMessage(), CParticleManager::update(), and MessagesDisplay::UpdateMessages().
| void InitVideo | ( | void | ) |
Check if a resolution is valid.
Video initialize.
Definition at line 269 of file video.cpp.
References InitLineDraw(), and InitVideoSdl().
Referenced by tolua_stratagus_InitVideo00().
| 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 PopClipping | ( | void | ) |
Returns the ticks in ms since start.
Pop current clipping.
Definition at line 194 of file video.cpp.
References Clips, ClipX1, ClipX2, ClipY1, ClipY2, Clip::X1, Clip::X2, Clip::Y1, and Clip::Y2.
Referenced by CViewport::Draw(), CStatusLine::Draw(), DrawBuildingCursor(), MyOpenGLGraphics::drawImage(), DrawMapCursor(), MessagesDisplay::DrawMessages(), DrawPieMenu(), DrawStartLocations(), and CFont::drawString().
| void PushClipping | ( | void | ) |
Pop current clipping.
Push current clipping.
Definition at line 185 of file video.cpp.
References Clips, ClipX1, ClipX2, ClipY1, and ClipY2.
Referenced by CViewport::Draw(), CStatusLine::Draw(), DrawBuildingCursor(), MyOpenGLGraphics::drawImage(), DrawMapCursor(), MessagesDisplay::DrawMessages(), DrawPieMenu(), DrawStartLocations(), and CFont::drawString().
| 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 SetClipping | ( | int | left, | |
| int | top, | |||
| int | right, | |||
| int | bottom | |||
| ) |
Realize video memory.
Set clipping for graphic routines.
| left | Left X screen coordinate. | |
| top | Top Y screen coordinate. | |
| right | Right X screen coordinate. | |
| bottom | Bottom Y screen coordinate. |
Definition at line 170 of file video.cpp.
References Assert, ClipX1, ClipX2, ClipY1, ClipY2, CVideo::Height, and CVideo::Width.
Referenced by CViewport::Draw(), CStatusLine::Draw(), DrawBuildingCursor(), MyOpenGLGraphics::drawImage(), DrawMapCursor(), MessagesDisplay::DrawMessages(), DrawPieMenu(), DrawStartLocations(), CFont::drawString(), main1(), and CVideo::ResizeScreen().
| int ClipX1 |
current clipping top left
Definition at line 137 of file video.cpp.
Referenced by linedraw_gl::ClipCodeLine(), linedraw_gl::DrawHLineClip(), linedraw_gl::DrawLineClip(), linedraw_gl::DrawRectangleClip(), linedraw_sdl::FillRectangleClip(), PopClipping(), PushClipping(), SetClipping(), linedraw_sdl::VideoDoDrawPixelClip(), and linedraw_sdl::VideoDoDrawTransPixelClip().
| int ClipX2 |
current clipping bottom right
Definition at line 139 of file video.cpp.
Referenced by linedraw_gl::ClipCodeLine(), linedraw_gl::DrawHLineClip(), linedraw_gl::DrawLineClip(), linedraw_gl::DrawPixelClip(), linedraw_gl::DrawRectangleClip(), linedraw_gl::DrawVLineClip(), linedraw_sdl::FillRectangleClip(), PopClipping(), PushClipping(), SetClipping(), linedraw_sdl::VideoDoDrawPixelClip(), and linedraw_sdl::VideoDoDrawTransPixelClip().
| int ClipY1 |
current clipping top left
Definition at line 138 of file video.cpp.
Referenced by linedraw_gl::ClipCodeLine(), linedraw_gl::DrawLineClip(), linedraw_gl::DrawRectangleClip(), linedraw_gl::DrawVLineClip(), linedraw_sdl::FillRectangleClip(), PopClipping(), PushClipping(), SetClipping(), linedraw_sdl::VideoDoDrawPixelClip(), and linedraw_sdl::VideoDoDrawTransPixelClip().
| int ClipY2 |
current clipping bottom right
Definition at line 140 of file video.cpp.
Referenced by linedraw_gl::ClipCodeLine(), linedraw_gl::DrawHLineClip(), linedraw_gl::DrawLineClip(), linedraw_gl::DrawPixelClip(), linedraw_gl::DrawRectangleClip(), linedraw_gl::DrawVLineClip(), linedraw_sdl::FillRectangleClip(), PopClipping(), PushClipping(), SetClipping(), linedraw_sdl::VideoDoDrawPixelClip(), and linedraw_sdl::VideoDoDrawTransPixelClip().
| Uint32 ColorBlack |
Definition at line 147 of file video.cpp.
Referenced by CVideo::ClearScreen(), CChunkParticle::draw(), CViewport::DrawBorder(), DrawGrids(), DrawIcons(), CViewport::DrawMapFogOfWar(), DrawPopup(), CEditor::Init(), InitVideoSdl(), ShowLoadProgress(), UiDrawLifeBar(), UiDrawManaBar(), CMinimap::Update(), and CMinimap::UpdateTerrain().
| Uint32 ColorBlue |
Definition at line 149 of file video.cpp.
Referenced by DrawIcons(), DrawInformations(), InitVideoSdl(), ShowSingleOrder(), and UiDrawManaBar().
| Uint32 ColorDarkGreen |
| Uint32 ColorGray |
Definition at line 152 of file video.cpp.
Referenced by DrawPatchIcons(), DrawPlayers(), DrawUnitIcons(), DrawUnitSelection(), InitVideoSdl(), PatchEditorUpdateDisplay(), and ShowSingleOrder().
| Uint32 ColorGreen |
Definition at line 154 of file video.cpp.
Referenced by DrawBuildingCursor(), DrawIcons(), DrawInformations(), DrawPatchIcons(), DrawPlayers(), DrawUnitIcons(), DrawUnitOn(), DrawUnitSelection(), DrawVisibleRectangleCursor(), InitVideoSdl(), and ShowSingleOrder().
| Uint32 ColorOrange |
Definition at line 150 of file video.cpp.
Referenced by CViewport::DrawBorder(), InitVideoSdl(), and UiDrawLifeBar().
| Uint32 ColorRed |
Definition at line 153 of file video.cpp.
Referenced by DrawBuildingCursor(), DrawInformations(), DrawUnitOn(), DrawUnitSelection(), InitVideoSdl(), ShowSingleOrder(), and UiDrawLifeBar().
| Uint32 ColorWhite |
Definition at line 151 of file video.cpp.
Referenced by DrawEvents(), DrawInfoPanelNoneSelected(), DrawMapCursor(), DrawPatchIcons(), DrawPlayers(), DrawUnitIcons(), DrawUnitOn(), DrawUnitSelection(), InitUserInterface(), and InitVideoSdl().
| Uint32 ColorYellow |
Definition at line 155 of file video.cpp.
Referenced by DrawUnitSelection(), InitVideoSdl(), ShowSingleOrder(), and UiDrawLifeBar().
| unsigned long FrameCounter |
Current frame number.
Counts quantity of slow frames.
Definition at line 134 of file video.cpp.
Referenced by EditorMainLoop(), Exit(), NetworkEvent(), NetworkParseMenuPacket(), NetworkProcessServerRequest(), NetworkRecover(), NetworkSyncCommands(), ServerParseGoodBye(), ServerParseHello(), ServerParseIAmHere(), ServerParseMap(), ServerParseResync(), ServerParseState(), ServerParseWaiting(), SimpleChooseSample(), CMinimap::Update(), and WaitEventsOneFrame().
| unsigned long NextFrameTicks |
Ticks of begin of the next frame.
Counts frames.
Definition at line 133 of file video.cpp.
Referenced by WaitEventsOneFrame().
| int SkipFrames |
Skip this frames.
Fullscreen or windowed set from commandline.
Definition at line 145 of file video.cpp.
Referenced by DoScrollArea(), SetVideoSync(), and WaitEventsOneFrame().
| int SlowFrameCounter |
Profile, frames out of sync.
Initialize Pixels[] for all players. (bring Players[] in sync with Pixels[])
Definition at line 135 of file video.cpp.
Referenced by Exit(), and WaitEventsOneFrame().
| bool UseOpenGL |
Use OpenGL.
Definition at line 129 of file video.cpp.
Referenced by CMap::CleanFogOfWar(), CleanFonts(), ClearMinimap(), CopyMinimapTerrain(), CMinimap::Create(), CMinimap::Destroy(), DoDrawText(), CMinimap::Draw(), CVideo::DrawCircle(), CVideo::DrawCircleClip(), DrawCursor(), DrawFogOfWarTile(), CGraphic::DrawFrame(), CGraphic::DrawFrameClip(), CGraphic::DrawFrameClipTrans(), CGraphic::DrawFrameClipTransX(), CGraphic::DrawFrameClipX(), CGraphic::DrawFrameTrans(), CGraphic::DrawFrameTransX(), CGraphic::DrawFrameX(), DrawGuichanWidgets(), CVideo::DrawHLine(), CVideo::DrawHLineClip(), CVideo::DrawLine(), CVideo::DrawLineClip(), CVideo::DrawPixelClip(), CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), CVideo::DrawRectangle(), CVideo::DrawRectangleClip(), CGraphic::DrawSub(), CGraphic::DrawSubTrans(), CVideo::DrawTransCircle(), CVideo::DrawTransCircleClip(), CVideo::DrawTransHLine(), CVideo::DrawTransHLineClip(), CVideo::DrawTransLine(), CVideo::DrawTransLineClip(), CVideo::DrawTransPixelClip(), CVideo::DrawTransRectangle(), CVideo::DrawTransRectangleClip(), CVideo::DrawTransVLine(), CVideo::DrawTransVLineClip(), CVideo::DrawVLine(), CVideo::DrawVLineClip(), CVideo::FillCircle(), CVideo::FillCircleClip(), CVideo::FillRectangle(), CVideo::FillRectangleClip(), CVideo::FillTransCircle(), CVideo::FillTransCircleClip(), CVideo::FillTransRectangle(), CVideo::FillTransRectangleClip(), CGraphic::Flip(), CGraphic::Free(), CVideo::GetRGB(), CVideo::GetRGBA(), HideCursor(), initGuichan(), InitLineDraw(), InitVideoSdl(), Invalidate(), InvalidateArea(), CGraphic::Load(), LoadFonts(), CGraphic::MakeShadow(), CVideo::MapRGB(), CVideo::MapRGBA(), RealizeVideoMemory(), CGraphic::Resize(), CVideo::ResizeScreen(), SaveScreenshotPNG(), SdlDoEvent(), SdlLockScreen(), SdlUnlockScreen(), SetMinimapPixel(), SetMinimapTerrainPixel(), ToggleFullScreen(), tolua_get_UseOpenGL(), tolua_set_UseOpenGL(), CMinimap::Update(), CMinimap::UpdateTerrain(), CGraphic::UseDisplayFormat(), VideoDrawChar(), VideoDrawOnlyFog(), and WaitEventsOneFrame().
Definition at line 127 of file video.cpp.
Referenced by MyOpenGLGraphics::_beginDraw(), CclGetVideoFullScreen(), CclGetVideoResolution(), CclPlayer(), CclSetVideoFullScreen(), CclSetVideoResolution(), CreateGame(), DoScroll(), CStatusLine::Draw(), CChunkParticle::draw(), CViewport::DrawBorder(), DrawBuildingCursor(), linedraw_sdl::DrawCircle(), linedraw_sdl::DrawCircleClip(), DrawCoordinates(), DrawCosts(), CMinimap::DrawCursor(), DrawEvents(), DrawGrids(), linedraw_gl::DrawHLine(), linedraw_sdl::DrawHLine(), DrawIcons(), MyOpenGLGraphics::drawImage(), DrawInfoPanelNoneSelected(), DrawInformations(), MyOpenGLGraphics::drawLine(), linedraw_gl::DrawLine(), linedraw_sdl::DrawLine(), linedraw_sdl::DrawLineClip(), CViewport::DrawMapBackgroundInViewport(), DrawMapCursor(), CViewport::DrawMapFogOfWar(), DrawMenuButton(), MessagesDisplay::DrawMessages(), DrawPatchIcons(), linedraw_gl::DrawPixel(), linedraw_sdl::DrawPixelClip(), DrawPlayers(), MyOpenGLGraphics::drawPoint(), DrawPopup(), MyOpenGLGraphics::drawRectangle(), linedraw_gl::DrawRectangle(), DrawSelection(), CFont::drawString(), linedraw_gl::DrawTransCircle(), linedraw_sdl::DrawTransCircle(), linedraw_gl::DrawTransCircleClip(), linedraw_sdl::DrawTransCircleClip(), linedraw_gl::DrawTransHLine(), linedraw_sdl::DrawTransHLine(), linedraw_gl::DrawTransHLineClip(), linedraw_sdl::DrawTransHLineClip(), linedraw_gl::DrawTransPixel(), linedraw_gl::DrawTransPixelClip(), linedraw_sdl::DrawTransPixelClip(), linedraw_gl::DrawTransRectangle(), linedraw_gl::DrawTransRectangleClip(), linedraw_gl::DrawTransVLine(), linedraw_sdl::DrawTransVLine(), linedraw_gl::DrawTransVLineClip(), linedraw_sdl::DrawTransVLineClip(), DrawUnitIcons(), DrawUnitOn(), DrawVisibleRectangleCursor(), linedraw_gl::DrawVLine(), linedraw_sdl::DrawVLine(), EditorMainLoop(), MyOpenGLGraphics::fillRectangle(), gcn::SDLGraphics::fillRectangle(), linedraw_gl::FillRectangle(), linedraw_gl::FillTransCircle(), linedraw_gl::FillTransCircleClip(), linedraw_gl::FillTransRectangle(), linedraw_sdl::FillTransRectangle(), linedraw_gl::FillTransRectangleClip(), HandleCursorMove(), HandleMouseExit(), CEditor::Init(), linedraw_sdl::InitLineDraw(), InitOpenGL(), InitPlayers(), InitUserInterface(), InitVideoSdl(), Invalidate(), InvalidateArea(), main(), main1(), MenuLoop(), MenuScreen::MenuScreen(), PatchEditorCallbackMouse(), PatchEditorMainLoop(), PatchEditorUpdateDisplay(), PatchLoadIcons(), PlayMovie(), SaveScreenshotPNG(), SdlDoEvent(), SetMinimapTerrainPixel(), ShowLoadProgress(), ShowSingleOrder(), ShowTitleImage(), ShowTitleScreens(), StartEditor(), StartMap(), ToggleFullScreen(), tolua_get_Video(), tolua_set_Video(), UiDrawLifeBar(), UiDrawManaBar(), UiToggleBigMap(), linedraw_sdl::VideoDoDrawPixel16(), linedraw_sdl::VideoDoDrawPixel32(), linedraw_sdl::VideoDoDrawTransPixel16(), linedraw_sdl::VideoDoDrawTransPixel32(), VideoDrawOnlyFog(), linedraw_sdl::VideoDrawPixel16(), linedraw_sdl::VideoDrawPixel32(), linedraw_sdl::VideoDrawTransPixel16(), linedraw_sdl::VideoDrawTransPixel32(), and WaitEventsOneFrame().
| char VideoForceFullScreen |
fullscreen set from commandline
Next frame ticks.
Definition at line 131 of file video.cpp.
Referenced by CclSetVideoFullScreen(), and main().
| int VideoSyncSpeed = 100 |
0 disable interrupts
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.
Definition at line 144 of file video.cpp.
Referenced by DoScrollArea(), DrawInfoPanelNoneSelected(), GetGameSpeed(), main(), NetworkRecover(), SetGameSpeed(), SetVideoSync(), UiDecreaseGameSpeed(), and UiIncreaseGameSpeed().
1.5.6