PDD_CANCREATESURFACE callback function

The DdCanCreateSurface callback function indicates whether the driver can create a surface of the specified surface description.



DWORD APIENTRY DdCanCreateSurface(
{ ... }



Points to the DD_CANCREATESURFACEDATA structure containing the information required for the driver to determine whether a surface can be created.

Return value

DdCanCreateSurface returns one of the following callback codes:



To determine if the driver can support the format and capabilities of the requested surface for the mode that the driver is currently in, DdCanCreateSurface should check the surface description to which the lpDDSurfaceDesc member of the DD_CANCREATESURFACEDATA structure at lpCanCreateSurface points. If the driver supports the surface, the driver should return the DDHAL_DRIVER_HANDLED callback code and specify DD_OK in the ddRVal member of DD_CANCREATESURFACEDATA. Otherwise, the driver should return the DDHAL_DRIVER_HANDLED callback code and specify in ddRVal the DDERR_Xxx error code that best describes why the surface is not supported. For example, the driver should specify the following error codes in ddRVal:

  • DDERR_OUTOFVIDEOMEMORY, indicating that the driver's device has insufficient memory.

  • DDERR_GENERIC, indicating that the driver does not support video memory vertex buffers. DirectDraw can then allocate vertex buffers in system memory.

If the driver specifies an error code in ddRVal, the driver indicates that it does not support creating the surface. The DirectDraw runtime then either creates the surface on its own or terminates the surface creation process and returns the error code to the application that requested the creation.

The bIsDifferentPixelFormat member of the following structure is unreliable for z-buffers. Drivers should use bIsDifferentPixelFormat only when they have first checked that the specified surface is not a z-buffer. Drivers can perform this check by determining whether the DDSCAPS_ZBUFFER flag is set in lpDDSurfaceDesc->ddsCaps.dwCaps.

This function must be implemented in a DirectDraw driver.


Target platform



Ddrawint.h (include Winddi.h)

See also




Send comments about this topic to Microsoft