1 ----------------------------------------------------------------------------
3 Fatal Error DirectX Graphics Library (FeDX) documentation
5 ----------------------------------------------------------------------------
10 Implements the Fatal Error Standard Graphics Interface (FESGI) using
11 Microsoft DirectX 8.0a. As FESGI requires, it handles both resolution and
12 colordepth changes as well as various bitmap handling routines.
20 The basic bitmap structure. Includes all data of the bitmap in a DirectX
21 surface, and various functions for its efficient usage.
25 bitmap(const char* FileName)
27 Loads contents from specified file and creates a bitmap to hold
28 them. The file must use pcx-style RLE-compression.
30 bitmap(ushort XSize, ushort YSize)
32 Creates a bitmap of specified size. Initial contents are
33 undefined, so you must fill it with data before using.
35 bitmap(IDirectDrawSurface7* DDSurface)
37 Special constructor used only for the DoubleBuffer bitmap in Win32.
41 Destroys the bitmap object.
43 Save(std::ofstream* SaveFile, ushort XPos, ushort YPos, ushort XSize,
46 Saves a rectangle specified by parameters to SaveFile as an
47 uncompressed bytestream.
49 Load(std::ifstream* SaveFile, ushort XPos, ushort YPos, ushort XSize,
52 The reverse function of the preseding.
54 Save(std::string FileName)
56 Saves the entire bitmap as a dib-format bmp-file.
58 PutPixel(ushort X, ushort Y, ushort Color)
60 Quite self-explaining. Color must be in 16-bit format.
62 ushort GetPixel(ushort X, ushort Y)
64 The reverse function of the preseding.
66 ClearToColor(ushort Color = 0)
68 Fills the entire bitmap surface with the given color, which must
71 ClearToColor(ushort DestX, ushort DestY, ushort SizeX, ushort SizeY,
74 Fills a rectancle bound by the parameters with the given 16b-color.
76 Blit(bitmap* Bitmap, ushort SourceX, ushort SourceY, ushort DestX, ushort
77 DestY, ushort Width, ushort Height, uchar Flags = 0)
79 A bit block transfering procedure, which copies a source rectancle
80 from this to Bitmap. If Flags is zero, all pixels are overwritten
81 with their exact counterparts of the source. Otherwise if the
82 MIRROR (1) flag is set, the bitmap is mirrored (flipped over the
83 Y-axis), if FLIP (2) flag is set, it is flipped (over the X-axis),
84 if ROTATE_90 (4) flag is set, it is rotated by 90 degrees
85 clockwise. The Flags can be mixed in eight different combinations
86 (including zero) as wanted.
88 Warning: ensure that borders of both bitmaps are respected, or
89 the application may crash, since there's no clipping. This applies
90 also to all sister Blits.
92 Blit(bitmap* Bitmap, ushort SourceX, ushort SourceY, ushort DestX, ushort
93 DestY, ushort Width, ushort Height, ushort Luminance)
95 As a luminated variant of the preseding, this function allows
96 lightning effects with the bit block transfer. Luminance must be in
97 the range of 0-511, and it is applied to all pixel color components
98 copied to the destination, according to the following formula:
99 ColorComponent += Luminance - 256. So 256 means the lightning level
100 is average, 0 that there's no light, and 511 is (almost) as brigth
101 as Valpuri Himself. Notice that there's no Flags, and so no
102 mirroring, flipping or rotating is possible with this method.
106 bitmap Picture("Char.pcx");
107 Picture.Blit(DOUBLEBUFFER, 92, 128, 0, 0, 16, 16, 400);
108 graphics::BlitDBToScreen();
110 Result: A highly radioactive-looking Enner Beast is displayed in
111 the top left corner of the display.
113 MaskedBlit(bitmap* Bitmap, ushort SourceX, ushort SourceY, ushort DestX,
114 ushort DestY, ushort Width, ushort Height, uchar Flags = 0)
116 Same as Blit of same parameters, except that transparent pixels
117 (those of brigth pink color 0xF81F) are not copied. This allows
118 non-rectangular sprites (characters, items etc.) to be displayed
119 on the screen on top of each other.
121 MaskedBlit(bitmap* Bitmap, ushort SourceX, ushort SourceY, ushort DestX,
122 ushort DestY, ushort Width, ushort Height, ushort Luminance)
124 Same as above, except that Luminance is supported as in the
125 corresponding Blit. Notice that there's no Flags, and so no
126 mirroring, flipping or rotating is possible with this method.
128 BlitToDB(ushort SourceX, ushort SourceY, ushort DestX, ushort DestY, ushort
129 Width, ushort Height)
130 BlitToDB(ushort SourceX, ushort SourceY, ushort DestX, ushort DestY, ushort
131 Width, ushort Height, ushort Luminance)
132 MaskedBlitToDB(ushort SourceX, ushort SourceY, ushort DestX, ushort DestY,
133 ushort Width, ushort Height)
134 MaskedBlitToDB(ushort SourceX, ushort SourceY, ushort DestX, ushort DestY,
135 ushort Width, ushort Height, ushort Luminance)
137 All of these are equalent to calling the most similiar blit or
138 maskedblit with DOUBLEBUFFER as the first argument. Note:
139 you shouldn't use these functions anymore. They are provided
140 just for backwards compability.
142 FastBlit(bitmap* Bitmap)
144 Just a raw fast blit to the destination bitmap without any luminance
145 or masking. The destination *must* be of same size, because although
146 FeDX doesn't crash if it isn't, the DOS-port of FESGI, FeVesa, does.
148 FastMaskedBlit(bitmap* Bitmap)
150 Same as above, except that transparent pixels are again ignored.
152 Printf(bitmap* Font, ushort X, ushort Y, const char* Format, ...)
154 Prints text to *this* bitmap, using Font as the font bitmap.
155 Font bitmap is a 246x216x16-bitmap containing ASCII-codes 32-255
156 as little 8x8-subbitmaps, 16 in every line, with 8 pixels of
157 empty space between each character and same amount between
158 each line. The string printed is generated using Format as
159 printf() does, and placed according to given X & Y coordinates.
163 bitmap Font("Font.pcx");
164 DOUBLEBUFFER->Printf(&Font, 0, 0, "Oree has taken %d SWAT commandos
166 graphics::BlitDBToScreen();
168 Result: "Oree has taken 8 SWAT commandos as gay-slaves." is printed
169 in the upper left corner of the screen.
171 ReadFromDB(ushort X, ushort Y)
173 Obsolete function that copies contents of DOUBLEBUFFER to this.
175 WriteToDB(ushort X, ushort Y)
177 Reverses the preseding.
179 PrintfToDB(ushort X, ushort Y, const char* Format, ...)
181 Just calls DOUBLEBUFFER->Printf(this, X, Y, Format, ...).
183 Backup(ushort X = 0, ushort Y = 0, bool DestroySurface = true)
185 Backups the contents of the DirectX surface into a bytestream
186 and releases the surface if DestroySurface is true. Used only by
187 graphics::SwitchMode().
189 Restore(ushort X = 0, ushort Y = 0, bool CreateSurface = true)
191 Reverses the preseding. CreateSurface must be true if surface is
192 known to be destroyed. Used only by graphics::SwitchMode().
194 AttachSurface(IDirectDrawSurface7* DDSurface)
196 Attaches the given surface to the bitmap. Used only by
197 graphics::SwitchMode().
204 CDisplay (ddutil.h) and CSurface (ddutil.h)
205 -------------------------------------------
207 Two wrapper classes copypasted from DirectX SDK samples :) More or less
208 temporary, so no documentation is available.
210 graphics (graphics.h)
211 ---------------------
213 A purely static class that contains functions dealing with the doublebuffer
214 and screen display mode.
221 Obsolete and do nothing.
223 SetMode(HINSTANCE hInst, HWND* phWnd, const char* Title, ushort NewXRes,
224 ushort NewYRes, uchar NewColorDepth, bool FullScreen)
226 Calls globalwindowhandler::Init() and sets up a new display mode.
227 The first parameter is provided by Windows to WinMain, second
228 by FEEL to Main, so don't lose them if you plan to change modes.
229 Title is the text displayed on top of the window and at the
230 toolbar. Other parameters are self-explanatory.
234 Blits the DoubleBuffer to the screen surface, effectively to
235 be shown on the monitor display.
237 ClearDBToColor(ushort Color = 0)
239 Just calls DOUBLEBUFFER->ClearToColor(Color);
241 ClearDBToColor(ushort X, ushort Y, ushort XSize, ushort YSize,
244 A more sophisticated variant of the preseding.
248 Updates the Window bounds stored in the CDisplay class. Used
249 only by globalwindowhandler::WndProc(), when the window is resized
254 Switches between fullscreen and windowed modes.
259 Return the resolution width and height.
261 bitmap* GetDoubleBuffer(void)
263 Return a pointer to the DoubleBuffer bitmap, which is attached
264 to the BackBuffer DirectX surface. All data must be blitted
265 or otherwise drawn to this bitmap in order to be shown on
266 the screen. This is a common function, so the macro DOUBLEBUFFER
267 is provided to ease usage.
269 CDisplay* GetDXDisplay(void) { return DXDisplay; }
271 Returns the display structure. Used only by bitmap member functions.
273 ----------------------------------------------------------------------------