Exemplo n.º 1
0
static Bool
winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  HRESULT		ddrval = DD_OK;
  DDSURFACEDESC		ddsd;

  /* Describe the primary surface */
  ZeroMemory (&ddsd, sizeof (ddsd));
  ddsd.dwSize = sizeof (ddsd);
  ddsd.dwFlags = DDSD_CAPS;
  ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  
  /* Create the primary surface */
  ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
				       &ddsd,
				       &pScreenPriv->pddsPrimary,
				       NULL);
  if (FAILED (ddrval))
    {
      ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
	      "surface: %08x\n", (unsigned int) ddrval);
      return FALSE;
    }
  
#if CYGDEBUG
  winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
#endif

  /*
   * Attach a clipper to the primary surface that will clip our blits to our
   * display window.
   */
  ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
					   pScreenPriv->pddcPrimary);
  if (FAILED (ddrval))
    {
      ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
	      "failed: %08x\n",
	      (unsigned int) ddrval);
      return FALSE;
    }

#if CYGDEBUG
  winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
	  "primary surface\n");
#endif

  /* Everything was correct */
  return TRUE;
}
Exemplo n.º 2
0
static Bool
winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  Bool			fReturn;
  
#if CYGDEBUG
  winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
#endif

  /* Flag that the screen is closed */
  pScreenPriv->fClosed = TRUE;
  pScreenPriv->fActive = FALSE;

  /* Call the wrapped CloseScreen procedure */
  WIN_UNWRAP(CloseScreen);
  fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);

  /* Free the screen DC */
  ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);

  /* Delete the window property */
  RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);

  /* Free the shadow surface, if there is one */
  if (pScreenPriv->pddsShadow)
    {
      IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
      IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
      pScreenPriv->pddsShadow = NULL;
    }

  /* Detach the clipper from the primary surface and release the clipper. */
  if (pScreenPriv->pddcPrimary)
    {
      /* Detach the clipper */
      IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
				      NULL);

      /* Release the clipper object */
      IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
      pScreenPriv->pddcPrimary = NULL;
    }

  /* Release the primary surface, if there is one */
  if (pScreenPriv->pddsPrimary)
    {
      IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
      pScreenPriv->pddsPrimary = NULL;
    }

  /* Free the DirectDraw2 object, if there is one */
  if (pScreenPriv->pdd2)
    {
      IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
      IDirectDraw2_Release (pScreenPriv->pdd2);
      pScreenPriv->pdd2 = NULL;
    }

  /* Free the DirectDraw object, if there is one */
  if (pScreenPriv->pdd)
    {
      IDirectDraw_Release (pScreenPriv->pdd);
      pScreenPriv->pdd = NULL;
    }

  /* Delete tray icon, if we have one */
  if (!pScreenInfo->fNoTrayIcon)
    winDeleteNotifyIcon (pScreenPriv);
  
  /* Free the exit confirmation dialog box, if it exists */
  if (g_hDlgExit != NULL)
    {
      DestroyWindow (g_hDlgExit);
      g_hDlgExit = NULL;
    }

  /* Kill our window */
  if (pScreenPriv->hwndScreen)
    {
      DestroyWindow (pScreenPriv->hwndScreen);
      pScreenPriv->hwndScreen = NULL;
    }

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
  /* Destroy the thread startup mutex */
  pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
#endif

  /* Kill our screeninfo's pointer to the screen */
  pScreenInfo->pScreen = NULL;

  /* Invalidate the ScreenInfo's fb pointer */
  pScreenInfo->pfb = NULL;

  /* Free the screen privates for this screen */
  free ((pointer) pScreenPriv);

  return fReturn;
}
Exemplo n.º 3
0
int directdraw_init(HWND hwndp)
{
    int                 width = 320, height = 200;
    RECT                rect;
    DDPIXELFORMAT       format;
    DDSURFACEDESC       descriptor;
    DIRECTDRAWCREATE    DirectDrawCreate;

	if(lpDDS) return 0;
	if(!hwndp) return 0;
	if(video_window) return 0; /* you gotta uninitialize it first */

    library = (HMODULE) LoadLibrary(uni("ddraw.dll"));
    if(!library) return 0;

    DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(library, "DirectDrawCreate");
    if(!DirectDrawCreate) return 0;

    if(FAILED(DirectDrawCreate(0,&lpDD,0))) return 0;

    wc.style         = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = 0;
    wc.hIcon         = 0;
    wc.hCursor       = LoadCursor(0, IDC_ARROW);
    wc.hbrBackground = 0;
    wc.lpszMenuName  = 0;
    wc.lpszClassName = window_class_name;

    RegisterClass(&wc);

    video_window = CreateWindow(window_class_name, uni("Video"), WS_CHILD, 0, 0, width, height, hwndp, 0, 0, 0);

    ShowWindow(video_window, SW_NORMAL);

    if(FAILED(IDirectDraw2_SetCooperativeLevel(lpDD, video_window, DDSCL_NORMAL))) return 0;


    descriptor.dwSize         = sizeof(descriptor);
    descriptor.dwFlags        = DDSD_CAPS;
    descriptor.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY;

    if(FAILED(IDirectDraw2_CreateSurface(lpDD, &descriptor, &lpDDS, 0))) return 0;

    descriptor.dwFlags        = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	descriptor.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    descriptor.dwWidth        = d_width ;
    descriptor.dwHeight       = d_height;

    if(FAILED(IDirectDraw2_CreateSurface(lpDD, &descriptor, &lpDDS_secondary, 0))) return 0;
    
    if(FAILED(IDirectDraw2_CreateClipper(lpDD, 0, &lpDDC, 0))) return 0;

    if(FAILED(IDirectDrawClipper_SetHWnd(lpDDC, 0, video_window))) return 0;

    if(FAILED(IDirectDrawSurface2_SetClipper(lpDDS, lpDDC))) return 0;
    
    lpDDS_back    = lpDDS_secondary;
    format.dwSize = sizeof(format);

    if(FAILED(IDirectDrawSurface2_GetPixelFormat(lpDDS, &format))) return 0;

    if(!(format.dwFlags & DDPF_RGB)) return 0;


	IDirectDraw2_EnumDisplayModes(lpDD, DDEDM_STANDARDVGAMODES, 0, 0, EnumDisplayModesCallback);


	osd_initialize();
	osd_created = 0;

    return 1;
}