144 char const * Message;
146 {DDERR_ALREADYINITIALIZED,
"This object is already initialized"},
147 {DDERR_BLTFASTCANTCLIP,
"Return if a clipper object is attached to the source surface passed into a BltFast call."},
148 {DDERR_CANNOTATTACHSURFACE,
"This surface can not be attached to the requested surface."},
149 {DDERR_CANNOTDETACHSURFACE,
"This surface can not be detached from the requested surface."},
150 {DDERR_CANTCREATEDC,
"Windows can not create any more DCs"},
151 {DDERR_CANTDUPLICATE,
"Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created."},
152 {DDERR_CANTLOCKSURFACE,
"Unable to lock surface because no driver exists which can supply a pointer to the surface."},
153 {DDERR_CLIPPERISUSINGHWND,
"An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd."},
154 {DDERR_COLORKEYNOTSET,
"No src color key specified for this operation."},
155 {DDERR_CURRENTLYNOTAVAIL,
"Support is currently not available."},
156 {DDERR_DIRECTDRAWALREADYCREATED,
"A DirectDraw object representing this driver has already been created for this process."},
157 {DDERR_EXCEPTION,
"An exception was encountered while performing the requested operation."},
158 {DDERR_EXCLUSIVEMODEALREADYSET,
"An attempt was made to set the cooperative level when it was already set to exclusive."},
159 {DDERR_GENERIC,
"Generic failure."},
160 {DDERR_HEIGHTALIGN,
"Height of rectangle provided is not a multiple of reqd alignment."},
161 {DDERR_HWNDALREADYSET,
"The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created."},
162 {DDERR_HWNDSUBCLASSED,
"HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state."},
163 {DDERR_IMPLICITLYCREATED,
"This surface can not be restored because it is an implicitly created surface."},
164 {DDERR_INCOMPATIBLEPRIMARY,
"Unable to match primary surface creation request with existing primary surface."},
165 {DDERR_INVALIDCAPS,
"One or more of the caps bits passed to the callback are incorrect."},
166 {DDERR_INVALIDCLIPLIST,
"DirectDraw does not support the provided cliplist."},
167 {DDERR_INVALIDDIRECTDRAWGUID,
"The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier."},
168 {DDERR_INVALIDMODE,
"DirectDraw does not support the requested mode."},
169 {DDERR_INVALIDOBJECT,
"DirectDraw received a pointer that was an invalid DIRECTDRAW object."},
170 {DDERR_INVALIDPARAMS,
"One or more of the parameters passed to the function are incorrect."},
171 {DDERR_INVALIDPIXELFORMAT,
"The pixel format was invalid as specified."},
172 {DDERR_INVALIDPOSITION,
"Returned when the position of the overlay on the destination is no longer legal for that destination."},
173 {DDERR_INVALIDRECT,
"Rectangle provided was invalid."},
174 {DDERR_INVALIDSURFACETYPE,
"The requested action could not be performed because the surface was of the wrong type."},
175 {DDERR_LOCKEDSURFACES,
"Operation could not be carried out because one or more surfaces are locked."},
176 {DDERR_NO3D,
"There is no 3D present."},
177 {DDERR_NOALPHAHW,
"Operation could not be carried out because there is no alpha accleration hardware present or available."},
179 {DDERR_NOBLTHW,
"No blter hardware present."},
181 {DDERR_NOCLIPLIST,
"No cliplist available."},
182 {DDERR_NOCLIPPERATTACHED,
"No clipper object attached to surface object."},
183 {DDERR_NOCOLORCONVHW,
"Operation could not be carried out because there is no color conversion hardware present or available."},
184 {DDERR_NOCOLORKEY,
"Surface doesn't currently have a color key"},
185 {DDERR_NOCOLORKEYHW,
"Operation could not be carried out because there is no hardware support of the destination color key."},
186 {DDERR_NOCOOPERATIVELEVELSET,
"Create function called without DirectDraw object method SetCooperativeLevel being called."},
187 {DDERR_NODC,
"No DC was ever created for this surface."},
188 {DDERR_NODDROPSHW,
"No DirectDraw ROP hardware."},
189 {DDERR_NODIRECTDRAWHW,
"A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware."},
190 {DDERR_NODIRECTDRAWSUPPORT,
"No DirectDraw support possible with current display driver."},
191 {DDERR_NOEMULATION,
"Software emulation not available."},
192 {DDERR_NOEXCLUSIVEMODE,
"Operation requires the application to have exclusive mode but the application does not have exclusive mode."},
193 {DDERR_NOFLIPHW,
"Flipping visible surfaces is not supported."},
194 {DDERR_NOGDI,
"There is no GDI present."},
195 {DDERR_NOHWND,
"Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND."},
196 {DDERR_NOMIRRORHW,
"Operation could not be carried out because there is no hardware present or available."},
197 {DDERR_NOOVERLAYDEST,
"Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination."},
198 {DDERR_NOOVERLAYHW,
"Operation could not be carried out because there is no overlay hardware present or available."},
199 {DDERR_NOPALETTEATTACHED,
"No palette object attached to this surface. "},
200 {DDERR_NOPALETTEHW,
"No hardware support for 16 or 256 color palettes."},
201 {DDERR_NORASTEROPHW,
"Operation could not be carried out because there is no appropriate raster op hardware present or available."},
202 {DDERR_NOROTATIONHW,
"Operation could not be carried out because there is no rotation hardware present or available."},
203 {DDERR_NOSTRETCHHW,
"Operation could not be carried out because there is no hardware support for stretching."},
204 {DDERR_NOT4BITCOLOR,
"DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette."},
205 {DDERR_NOT4BITCOLORINDEX,
"DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette."},
206 {DDERR_NOT8BITCOLOR,
"DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color."},
207 {DDERR_NOTAOVERLAYSURFACE,
"Returned when an overlay member is called for a non-overlay surface."},
208 {DDERR_NOTEXTUREHW,
"Operation could not be carried out because there is no texture mapping hardware present or available."},
209 {DDERR_NOTFLIPPABLE,
"An attempt has been made to flip a surface that is not flippable."},
210 {DDERR_NOTFOUND,
"Requested item was not found."},
211 {DDERR_NOTLOCKED,
"Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted."},
212 {DDERR_NOTPALETTIZED,
"The surface being used is not a palette-based surface."},
213 {DDERR_NOVSYNCHW,
"Operation could not be carried out because there is no hardware support for vertical blank synchronized operations."},
214 {DDERR_NOZBUFFERHW,
"Operation could not be carried out because there is no hardware support for zbuffer blting."},
215 {DDERR_NOZOVERLAYHW,
"Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays."},
216 {DDERR_OUTOFCAPS,
"The hardware needed for the requested operation has already been allocated."},
217 {DDERR_OUTOFMEMORY,
"DirectDraw does not have enough memory to perform the operation."},
218 {DDERR_OUTOFVIDEOMEMORY,
"DirectDraw does not have enough memory to perform the operation."},
219 {DDERR_OVERLAYCANTCLIP,
"The hardware does not support clipped overlays."},
220 {DDERR_OVERLAYCOLORKEYONLYONEACTIVE,
"Can only have ony color key active at one time for overlays."},
221 {DDERR_OVERLAYNOTVISIBLE,
"Returned when GetOverlayPosition is called on a hidden overlay."},
222 {DDERR_PALETTEBUSY,
"Access to this palette is being refused because the palette is already locked by another thread."},
223 {DDERR_PRIMARYSURFACEALREADYEXISTS,
"This process already has created a primary surface."},
224 {DDERR_REGIONTOOSMALL,
"Region passed to Clipper::GetClipList is too small."},
225 {DDERR_SURFACEALREADYATTACHED,
"This surface is already attached to the surface it is being attached to."},
226 {DDERR_SURFACEALREADYDEPENDENT,
"This surface is already a dependency of the surface it is being made a dependency of."},
227 {DDERR_SURFACEBUSY,
"Access to this surface is being refused because the surface is already locked by another thread."},
228 {DDERR_SURFACEISOBSCURED,
"Access to surface refused because the surface is obscured."},
229 {DDERR_SURFACELOST,
"Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it."},
230 {DDERR_SURFACENOTATTACHED,
"The requested surface is not attached."},
231 {DDERR_TOOBIGHEIGHT,
"Height requested by DirectDraw is too large."},
232 {DDERR_TOOBIGSIZE,
"Size requested by DirectDraw is too large -- the individual height and width are OK."},
233 {DDERR_TOOBIGWIDTH,
"Width requested by DirectDraw is too large."},
234 {DDERR_UNSUPPORTED,
"Action not supported."},
235 {DDERR_UNSUPPORTEDFORMAT,
"FOURCC format requested is unsupported by DirectDraw."},
236 {DDERR_UNSUPPORTEDMASK,
"Bitmask in the pixel format requested is unsupported by DirectDraw."},
237 {DDERR_VERTICALBLANKINPROGRESS,
"Vertical blank is in progress."},
238 {DDERR_WASSTILLDRAWING,
"Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete."},
239 {DDERR_WRONGMODE,
"This surface can not be restored because it was created in a different mode."},
240 {DDERR_XALIGN,
"Rectangle provided was not horizontally aligned on required boundary."}
247 if (result == DD_OK) {
248 if (display_ok_msg) {
249 MessageBox(
MainWindow,
"Direct Draw operation processed without error",
"Note", MB_OK);
262 for (
int index = 0; index <
ARRAY_SIZE(_errors); index++) {
263 if (_errors[index].Error == result) {
264 MessageBox(
MainWindow, _errors[index].Message,
"Westwood Library Direct Draw Error", MB_ICONEXCLAMATION|MB_OK);
274 sprintf(str,
"DDRAW.DLL Error code = %08X", result);
275 MessageBox(
MainWindow, str,
"Direct X", MB_ICONEXCLAMATION|MB_OK);
302 OverlappedVideoBlits =
true;
304 GraphicBufferClass test_buffer;
306 test_buffer.Init (64, 64,
NULL, 0, (GBC_Enum)GBC_VIDEOMEM);
313 test_buffer.Put_Pixel(0, 0, 255);
320 test_buffer.Blit(test_buffer, 0, 0, 0, 1, test_buffer.Get_Width(), test_buffer.Get_Height()-1);
322 if (test_buffer.Get_Pixel(0, 5) == 255) OverlappedVideoBlits =
false;
371 if (result != DD_OK) {
382 result =
DirectDrawObject->CreatePalette( DDPCAPS_8BIT | DDPCAPS_ALLOW256, &PaletteEntries[0], &PalettePtr,
NULL);
384 if (result != DD_OK) {
396 SystemToVideoBlits =
false;
397 VideoToSystemBlits =
false;
398 SystemToSystemBlits=
false;
399 if (result != DD_OK) {
403 DDCAPS emulated_capabilities;
405 memset ((
char*)&capabilities, 0,
sizeof(capabilities));
406 memset ((
char*)&emulated_capabilities, 0,
sizeof(emulated_capabilities));
407 capabilities.dwSize =
sizeof (capabilities);
408 emulated_capabilities.dwSize =
sizeof (emulated_capabilities);
412 if (capabilities.dwCaps & DDCAPS_CANBLTSYSMEM) {
413 SystemToVideoBlits = (capabilities.dwSVBCaps & DDCAPS_BLT) ?
true :
false;
414 VideoToSystemBlits = (capabilities.dwVSBCaps & DDCAPS_BLT) ?
true :
false;
415 SystemToSystemBlits = (capabilities.dwSSBCaps & DDCAPS_BLT) ?
true :
false;
506 DDCAPS video_capabilities;
517 video_capabilities.dwSize =
sizeof(video_capabilities);
520 if (result != DD_OK) {
531 if (video_capabilities.dwCaps & DDCAPS_BLT) video |=
VIDEO_BLITTER;
543 if (video_capabilities.dwCaps & DDCAPS_BLTCOLORFILL) video |=
VIDEO_COLOR_FILL;
593 assert(palette !=
NULL);
600 unsigned char * palette_get = (
unsigned char *)palette;
601 for (
int index = 0; index < 256; index++) {
603 int red = *palette_get++;
604 int green = *palette_get++;
605 int blue = *palette_get++;
607 PaletteEntries[index].peRed = (
unsigned char)red;
608 PaletteEntries[index].peGreen = (
unsigned char)green;
609 PaletteEntries[index].peBlue = (
unsigned char)blue;
612 if (PalettePtr !=
NULL) {
613 if (!FirstPaletteSet) {
615 FirstPaletteSet =
true;
618 PalettePtr->SetEntries(0, 0, 256, &PaletteEntries[0]);