HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) { DDSURFACEDESC surface_desc; IDirectDrawSurface *primary_surface, *render_target; HWND window; HRESULT hr; hr = IDirectDrawClipper_GetHWnd(clipper, &window); if (FAILED(hr)) return hr; hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); if (FAILED(hr)) return hr; memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL); if (FAILED(hr)) return hr; hr = IDirectDrawSurface_SetClipper(primary_surface, clipper); if (FAILED(hr)) { IDirectDrawSurface_Release(primary_surface); return hr; } memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; surface_desc.dwWidth = width; surface_desc.dwHeight = height; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL); if (FAILED(hr)) { IDirectDrawSurface_Release(primary_surface); return hr; } object->primary_surface = primary_surface; object->clipper = clipper; IDirectDrawClipper_AddRef(clipper); *surface = render_target; return D3DRM_OK; }
static HRESULT WINAPI ddraw_clipper_QueryInterface(IDirectDrawClipper *iface, REFIID iid, void **object) { struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface); TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object); if (IsEqualGUID(&IID_IDirectDrawClipper, iid) || IsEqualGUID(&IID_IUnknown, iid)) { IDirectDrawClipper_AddRef(&clipper->IDirectDrawClipper_iface); *object = &clipper->IDirectDrawClipper_iface; return S_OK; } WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); *object = NULL; return E_NOINTERFACE; }