Beispiel #1
0
// Create the primary surface
static int MakePrimarySurface()
{
  int Ret=0; unsigned int PrimFormat=0; int PrimBpp=0;
  DDSURFACEDESC ddsd;
  DispPrim=NULL;
  memset(&ddsd,0,sizeof(ddsd));
  ddsd.dwSize=sizeof(ddsd);
  ddsd.dwFlags=DDSD_CAPS;
  ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE;
  Ret=pDD->CreateSurface(&ddsd,&DispPrim,NULL);
  if (Ret<0) return 1; if (DispPrim==NULL) return 1; 

  // Find out the color to use to paint the overlay
  GetSurfaceFormat(DispPrim,&PrimFormat,&PrimBpp);
  switch (PrimFormat)
  {
    default: OverlayColor=0; break;
    case 15: OverlayColor=0x0401; break;
    case 16: OverlayColor=0x0801; break;
    case 24: case 32: OverlayColor=0x080008; break;
  }

  // Create a clipper
  Ret=DirectDrawCreateClipper(0,&pClipper,NULL);
  if (Ret==DD_OK)
  {
    Ret=pClipper->SetHWnd(0,hFrameWnd);
    if (Ret==DD_OK) DispPrim->SetClipper(pClipper);
  }

  return 0;
}
Beispiel #2
0
//////////////////////////////////////////////////////////////////////////////////
// CRMEngine CreateWindowed - creates a windowed application
//////////////////////////////////////////////////////////////////////////////////
HRESULT CRMEngine::CreateWindowed(CDXScreen* pScreen, void *hWnd,
                                  int Width, int Height)
{
	GUID d3dGUID;

	CDXLOG("START: CRMEngine::CreateWindowed");

	CDXLOG("Release our m_RMDevice and Clipper object if we have one");

	// first release everything that has been allocated
	RELEASE(m_RMDevice);
	RELEASE(m_lpDDClipper);

	CDXLOG("Save the Screen object and do a CreateWindow");

	// create the CDXScreen object
	m_Screen = pScreen;
	if(FAILED(m_Screen->CreateWindowed(hWnd, Width, Height))) {
    	CDXLOG("CreateWindow failed");
		return D3DRMERR_NOTDONEYET;
	}

	CDXLOG("Create a Clipper object");

	// create the dd clipper object
	if(FAILED(DirectDrawCreateClipper(0, &m_lpDDClipper, NULL))) {
    	CDXLOG("Clipper creation failed");
		return D3DRMERR_NOTDONEYET;
	}

	CDXLOG("Set the hWnd of the clipper to the main window");

	// set the clipper objects hWnd
	if(FAILED(m_lpDDClipper->SetHWnd(0, (HWND)hWnd))) {
		RELEASE(m_lpDDClipper);
		return D3DRMERR_NOTDONEYET;
	}

	CDXLOG("Do a CreateDeviceFromClipper to setup the 3DRM clipper");

	// create the d3d device
	if(FAILED(m_Direct3DRM->CreateDeviceFromClipper(m_lpDDClipper,
		FindDevice(m_Screen->GetBPP(), &d3dGUID), Width, Height, &m_RMDevice))) {
		return D3DRMERR_NOTDONEYET;
	}

	CDXLOG("Call SetDefaults");

	// start our engine with default values based on color depth
	SetDefaults();

	CDXLOG("END: CRMEngine::CreateWindowed");

	return D3DRM_OK;
}
Beispiel #3
0
// Create the windowed direct draw device for Direct3D to display with.
void BoidsWin::createWinDevice( )
{
	// Create the Direct Draw clipper
	DirectDrawCreateClipper( 0, &clipper, NULL );
	clipper -> SetHWnd( 0, m_hWnd );


	// Create the D3DRM drawing device.
	CRect size;
	GetClientRect( &size );

	if ( showControlPanel )  // Make space for the control panel.
	{
		size.right -= CONTROL_PANEL_SIZE;
	}

	d3drm -> CreateDeviceFromClipper( clipper, NULL,
							size.right, size.bottom, &device );


	// If the scene is not constructed, set the device to -
	// - the default render style and then create the scene.
	if ( scene == NULL )
	{
		// Set the initial render style.
		device -> SetQuality( DEFAULT_RENDER_STYLE );

		// IMPORTANT STEP: Set up all the simulation's graphics.
		createScene( );
	}
	else
	{
		// The scene has already been created, -
		// - just reconfigure the device and viewport.
		device -> SetQuality( renderStyle );  // Restore the render style.
		// Create the viewport.
		d3drm -> CreateViewport( device, camera, 0, 0,
				device -> GetWidth( ), device -> GetHeight( ), &viewPort );
		// Set the range of vision, default is 100.
		viewPort -> SetBack( D3DVALUE( VIEWPORT_BACK_DISTANCE ) );
	}
}