Пример #1
0
static IDirectDrawSurface* GetBlitSurface()
{
  IDirectDrawSurface* blitSurface;

  if(PrimarySurfaceVersion < 4)
  {
    IDirectDrawSurface *surf = (IDirectDrawSurface *) PrimarySurface;

    DDSURFACEDESC ddsd;
    ZeroMemory(&ddsd,sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    if(FAILED(surf->GetSurfaceDesc(&ddsd)))
      printLog("video: can't get surface desc\n");
    else
    {
      ddsd.dwWidth = captureWidth;
      ddsd.dwHeight = captureHeight;

      ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
      ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
      IDirectDraw *dd = (IDirectDraw *) PrimaryDDraw;
      if(FAILED(dd->CreateSurface(&ddsd,&blitSurface,0)))
        printLog("video: could not create blit target\n");
    }
  }
  else
  {
    IDirectDrawSurface4 *srf4 = (IDirectDrawSurface4 *) PrimarySurface;

    DDSURFACEDESC2 ddsd;
    ZeroMemory(&ddsd,sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    if(FAILED(srf4->GetSurfaceDesc(&ddsd)))
      printLog("video: can't get surface desc\n");
    else
    {
      ddsd.dwWidth = captureWidth;
      ddsd.dwHeight = captureHeight;

      ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
      ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
      ddsd.ddsCaps.dwCaps2 = 0;
      IDirectDraw4 *dd = (IDirectDraw4 *) PrimaryDDraw;
      if(FAILED(dd->CreateSurface(&ddsd,(IDirectDrawSurface4 **) &blitSurface,0)))
        printLog("video: could not create blit target\n");
    }
  }

  return blitSurface;
}
Пример #2
0
static void PrimarySurfaceCreated(IUnknown *ddraw,IUnknown *srfp,int ver)
{
  PrimaryDDraw = ddraw;
  PrimarySurface = srfp;
  PrimarySurfaceVersion = ver;

  if(PrimarySurfaceVersion < 4)
  {
    IDirectDrawSurface *surf = (IDirectDrawSurface *) PrimarySurface;

    DDSURFACEDESC ddsd;
    ZeroMemory(&ddsd,sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    if(FAILED(surf->GetSurfaceDesc(&ddsd)))
      printLog("video: can't get surface desc\n");
    else
    {
      if(captureWidth != ddsd.dwWidth || captureHeight != ddsd.dwHeight)
        setCaptureResolution(ddsd.dwWidth,ddsd.dwHeight);
    }
  }
  else
  {
    IDirectDrawSurface4 *srf4 = (IDirectDrawSurface4 *) PrimarySurface;

    DDSURFACEDESC2 ddsd;
    ZeroMemory(&ddsd,sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    if(FAILED(srf4->GetSurfaceDesc(&ddsd)))
      printLog("video: can't get surface desc\n");
    else
    {
      if(captureWidth != ddsd.dwWidth || captureHeight != ddsd.dwHeight)
        setCaptureResolution(ddsd.dwWidth,ddsd.dwHeight);
    }
  }

  graphicsInitTiming();
}