I need to call the Cairo Graphics API (included with GTK+ 2.24.10 bundle), whilst also using the Direct3D 9 API (DirectX SDK March 2009).
To test, I make basic Cairo function calls as follows:
#include <cairo\cairo.h>
...
cairo_surface_t *surface;
cairo_t *cr;
cairo_status_t status;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 390, 60);
status = cairo_surface_status(surface);
cr = cairo_create(surface);
status = cairo_status(cr);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
status = cairo_status(cr);
cairo_rectangle(cr, 175, 10, 40, 40);
status = cairo_status(cr);
cairo_fill(cr);
status = cairo_status(cr);
cairo_surface_flush(surface);
status = cairo_surface_write_to_png(surface, "c:\\cairo_test.png");
cairo_destroy(cr);
cairo_surface_destroy(surface);
...
If these Cairo API calls are made before a call to IDirect3D9::CreateDevice, then the following .PNG is output:
After making the call to IDirect3D9::CreateDevice, the same Cairo API calls create a blank .PNG:
The IDirect3D9::CreateDevice call is parameterised as follows:
Direct3DCreate9(D3D_SDK_VERSION)->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, WindowHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &PresentParameters, &PDevice);
Where the object parameters contain the following member variables:
WindowHandle 0x001b07f8 {unused=13111204 } HWND__ *
unused 13111204 int
PresentParameters {BackBufferWidth=0 BackBufferHeight=0 BackBufferFormat=D3DFMT_UNKNOWN (0) ...} _D3DPRESENT_PARAMETERS_
BackBufferWidth 0 unsigned int
BackBufferHeight 0 unsigned int
BackBufferFormat D3DFMT_UNKNOWN (0) _D3DFORMAT
BackBufferCount 1 unsigned int
MultiSampleType D3DMULTISAMPLE_NONE (0) _D3DMULTISAMPLE_TYPE
MultiSampleQuality 0 unsigned long
SwapEffect D3DSWAPEFFECT_DISCARD (1) _D3DSWAPEFFECT
+ hDeviceWindow 0x001b07f8 {unused=13111204 } HWND__ *
Windowed 1 int
EnableAutoDepthStencil 0 int
AutoDepthStencilFormat D3DFMT_UNKNOWN (0) _D3DFORMAT
Flags 1 unsigned long
FullScreen_RefreshRateInHz 0 unsigned int
PresentationInterval 0 unsigned int
PDevice 0x00000000 <NULL> IDirect3DDevice9 *
+ IUnknown <struct at NULL> IUnknown
The question is:
- How is it that the code compiles without error, and returns no error status at run-time, but the behaviour of the Cairo API calls varies significantly?
- Is there a way of parameterising the IDirect3D9::CreateDevice call to prevent this, or a way of recovering the expected behaviour of the Cairo API with subsequent function calls?