1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares Video, base class for video output plugins.
24 * @author The GemRB Project
33 #include "Animation.h"
35 #include "ScriptedAnimation.h"
39 class AnimationFactory
;
41 // Note: not all these flags make sense together. Specifically:
42 // NOSHADOW overrides TRANSSHADOW
43 enum SpriteBlitFlags
{
44 BLIT_HALFTRANS
= IE_VVC_TRANSPARENT
, // 2
45 BLIT_BLENDED
= IE_VVC_BLENDED
, // 8; not implemented in SDLVideo yet
46 BLIT_MIRRORX
= IE_VVC_MIRRORX
, // 0x10
47 BLIT_MIRRORY
= IE_VVC_MIRRORY
, // 0x20
48 BLIT_NOSHADOW
= 0x1000,
49 BLIT_TRANSSHADOW
= 0x2000,
50 BLIT_TINTED
= 0x00010000, // IE_VVC_TINT = 0x00030000
51 BLIT_GREY
= IE_VVC_GREYSCALE
, // 0x80000
52 BLIT_RED
= IE_VVC_RED_TINT
, // 0x02000000
53 BLIT_DARK
= IE_VVC_DARKEN
, // 0x00100000; not implemented in SDLVideo yet
54 BLIT_GLOW
= IE_VVC_GLOWING
// 0x00200000; not implemented in SDLVideo yet
55 // Note: bits 29,30,31 are used by SDLVideo internally
59 #define MOUSE_DISABLED 1
60 #define MOUSE_GRAYED 2
62 // !!! Keep this synchronized with GUIDefines.py !!!
63 // used for calculating the tooltip delay limit and the real tooltip delay
64 #define TOOLTIP_DELAY_FACTOR 250
68 * Base class for video output plugins.
71 class GEM_EXPORT Video
: public Plugin
{
75 virtual int Init(void) = 0;
76 virtual int CreateDisplay(int width
, int height
, int bpp
, bool fullscreen
) = 0;
77 /** Sets window title of GemRB window */
78 virtual void SetDisplayTitle(char* title
, char* icon
) = 0;
79 virtual VideoModes
GetVideoModes(bool fullscreen
= false) = 0;
80 virtual bool TestVideoMode(VideoMode
& vm
) = 0;
81 /** Toggles GemRB between fullscreen and windowed mode.
82 * 0 = windowed, 1 = fullscreen, -1 (default) = toggle */
83 virtual bool ToggleFullscreenMode(int set_reset
=-1) = 0;
84 /** Swaps displayed and back buffers */
85 virtual int SwapBuffers(void) = 0;
86 /** Grabs and releases mouse cursor within GemRB window */
87 virtual bool ToggleGrabInput() = 0;
88 virtual short GetWidth() = 0;
89 virtual short GetHeight() = 0;
91 virtual void InitSpriteCover(SpriteCover
* sc
, int flags
) = 0;
92 virtual void AddPolygonToSpriteCover(SpriteCover
* sc
, Wall_Polygon
* poly
) = 0;
93 virtual void DestroySpriteCover(SpriteCover
* sc
) = 0;
95 virtual Sprite2D
* CreateSprite(int w
, int h
, int bpp
, ieDword rMask
,
96 ieDword gMask
, ieDword bMask
, ieDword aMask
, void* pixels
,
97 bool cK
= false, int index
= 0) = 0;
98 virtual Sprite2D
* CreateSprite8(int w
, int h
, int bpp
, void* pixels
,
99 void* palette
, bool cK
= false, int index
= 0) = 0;
100 virtual Sprite2D
* CreateSpriteBAM8(int /*w*/, int /*h*/, bool /* RLE */,
101 const unsigned char* /*pixeldata*/,
102 AnimationFactory
* /*datasrc*/,
103 Palette
* /*palette*/,
104 int /*transindex*/) { return 0; }
105 virtual bool SupportsBAMSprites() { return false; }
106 virtual void FreeSprite(Sprite2D
* &spr
) = 0;
107 virtual Sprite2D
* DuplicateSprite(Sprite2D
* spr
) = 0;
108 virtual void BlitTile(Sprite2D
* spr
, Sprite2D
* mask
, int x
, int y
, Region
* clip
, bool trans
) = 0;
109 virtual void BlitSprite(Sprite2D
* spr
, int x
, int y
, bool anchor
= false,
110 Region
* clip
= NULL
) = 0;
112 // Note: BlitSpriteRegion's clip region is shifted by Viewport.x/y if
113 // anchor is false. This is different from the other BlitSprite functions.
114 virtual void BlitSpriteRegion(Sprite2D
* spr
, Region
& size
, int x
, int y
,
115 bool anchor
= true, Region
* clip
= NULL
) = 0;
116 // Note: Tint cannot be constified, because it is modified locally
117 // not a pretty interface :)
118 virtual void BlitGameSprite(Sprite2D
* spr
, int x
, int y
,
119 unsigned int flags
, Color tint
,
120 SpriteCover
* cover
, Palette
*palette
= NULL
,
121 Region
* clip
= NULL
, bool anchor
= false) = 0;
122 virtual void SetCursor(Sprite2D
* up
, Sprite2D
* down
) = 0;
123 /** Sets a temporary cursor when dragging an Item from Inventory.
124 * VideoDriver will call FreeSprite on it.
126 virtual void SetDragCursor(Sprite2D
* drag
) = 0;
127 /** Return GemRB window screenshot.
128 * It's generated from the momentary back buffer */
129 virtual Sprite2D
* GetScreenshot( Region r
) = 0;
130 virtual void ConvertToVideoFormat(Sprite2D
* sprite
) = 0;
131 /** Sets the palette of a plugin specific sprite */
132 virtual void SetPalette(void* data
, Palette
* pal
) = 0;
133 /** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */
134 virtual void DrawRect(const Region
& rgn
, const Color
& color
, bool fill
= true, bool clipped
= false) = 0;
135 /** this function draws a clipped sprite */
136 virtual void DrawRectSprite(const Region
& rgn
, const Color
& color
, Sprite2D
* sprite
) = 0;
137 virtual void SetPixel(short x
, short y
, const Color
& color
, bool clipped
= false) = 0;
138 virtual void GetPixel(short x
, short y
, Color
& color
) = 0;
139 virtual long GetPixel(void *, unsigned short x
, unsigned short y
) = 0;
140 virtual void GetPixel(void *, unsigned short x
, unsigned short y
, Color
&color
) = 0;
141 /** Draws a circle */
142 virtual void DrawCircle(short cx
, short cy
, unsigned short r
, const Color
& color
, bool clipped
= true) = 0;
143 /** Draws an Ellipse Segment */
144 virtual void DrawEllipseSegment(short cx
, short cy
, unsigned short xr
, unsigned short yr
, const Color
& color
,
145 double anglefrom
, double angleto
, bool drawlines
= true, bool clipped
= true) = 0;
146 /** Draws an ellipse */
147 virtual void DrawEllipse(short cx
, short cy
, unsigned short xr
,
148 unsigned short yr
, const Color
& color
, bool clipped
= true) = 0;
149 /** Draws a polygon on the screen */
150 virtual void DrawPolyline(Gem_Polygon
* poly
, const Color
& color
,
151 bool fill
= false) = 0;
152 /** Draws a line segment */
153 virtual void DrawLine(short x1
, short y1
, short x2
, short y2
,
154 const Color
& color
, bool clipped
= false) = 0;
155 /** Blits a Sprite filling the Region */
156 void BlitTiled(Region rgn
, Sprite2D
* img
, bool anchor
= false);
157 /** Sets Event Manager */
158 void SetEventMgr(EventMgr
* evnt
);
159 /** Sends a Quit Signal to the Event Queue */
160 virtual bool Quit(void) = 0;
161 /** Gets the Palette of a surface */
162 virtual Palette
* GetPalette(void* surface
) = 0;
163 /** Flips sprite vertically, returns new sprite */
164 virtual Sprite2D
*MirrorSpriteVertical(Sprite2D
*sprite
, bool MirrorAnchor
) = 0;
165 /** Flips sprite horizontally, returns new sprite */
166 virtual Sprite2D
*MirrorSpriteHorizontal(Sprite2D
*sprite
, bool MirrorAnchor
) = 0;
167 /** Duplicates and transforms sprite to have an alpha channel */
168 Sprite2D
* CreateAlpha(Sprite2D
*sprite
);
170 /** Converts a Screen Coordinate to a Game Coordinate */
171 virtual void ConvertToGame(short& x
, short& y
) = 0;
172 /** Converts a Game Coordinate to a Screen Coordinate */
173 virtual void ConvertToScreen(short& x
, short& y
) = 0;
174 /** Sets the Fading Color */
175 virtual void SetFadeColor(int r
, int g
, int b
) = 0;
176 /** Sets the Fading to Color Percentage */
177 virtual void SetFadePercent(int percent
) = 0;
178 /** Sets Clip Rectangle */
179 virtual void SetClipRect(const Region
* clip
) = 0;
180 /** Gets Clip Rectangle */
181 virtual void GetClipRect(Region
& clip
) = 0;
182 /** returns the current mouse coordinates */
183 virtual void GetMousePos(int &x
, int &y
) = 0;
184 /** clicks the mouse forcibly */
185 virtual void ClickMouse(unsigned int button
) = 0;
186 /** moves the mouse forcibly */
187 virtual void MoveMouse(unsigned int x
, unsigned int y
) = 0;
188 /** initializes the screen for movie */
189 virtual void InitMovieScreen(int &w
, int &h
, bool yuv
=false) = 0;
190 /** sets the font and color of the movie subtitles */
191 virtual void SetMovieFont(Font
*stfont
, Palette
*pal
) = 0;
192 /** draws a movie frame */
193 virtual void showFrame(unsigned char* buf
, unsigned int bufw
,
194 unsigned int bufh
, unsigned int sx
, unsigned int sy
,
195 unsigned int w
, unsigned int h
, unsigned int dstx
,
196 unsigned int dsty
, int truecolor
, unsigned char *palette
,
197 ieDword titleref
) = 0;
198 virtual void showYUVFrame(unsigned char** buf
, unsigned int *strides
,
199 unsigned int bufw
, unsigned int bufh
,
200 unsigned int w
, unsigned int h
,
201 unsigned int dstx
, unsigned int dsty
,
202 ieDword titleref
) = 0;
203 /** handles events during movie */
204 virtual int PollMovieEvents() = 0;
205 virtual void SetGamma(int brightness
, int contrast
) = 0;
207 /** Event Manager Pointer */
209 void SetMouseEnabled(int enabled
);
210 void SetMouseGrayed(bool grayed
);
212 /** Scales down a sprite by a ratio */
213 Sprite2D
* SpriteScaleDown( Sprite2D
* sprite
, unsigned int ratio
);
214 /** Creates an ellipse or circle shaped sprite with various intensity
215 * for projectile light spots */
216 Sprite2D
* CreateLight(int radius
, int intensity
);
218 Color
SpriteGetPixelSum (Sprite2D
* sprite
, unsigned short xbase
, unsigned short ybase
, unsigned int ratio
);
219 Region
GetViewport(void);
220 void SetViewport(int x
, int y
, unsigned int w
, unsigned int h
);
221 void MoveViewportTo(int x
, int y
);
227 int width
,height
,bpp
;
230 unsigned char Gamma10toGamma22
[256];
231 unsigned char Gamma22toGamma10
[256];