当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAW7::GetCaps方法代码示例

本文整理汇总了C++中LPDIRECTDRAW7::GetCaps方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW7::GetCaps方法的具体用法?C++ LPDIRECTDRAW7::GetCaps怎么用?C++ LPDIRECTDRAW7::GetCaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAW7的用法示例。


在下文中一共展示了LPDIRECTDRAW7::GetCaps方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DDOverlayInit

//! Setup the overlay object
bool DDOverlayInit()
{
    // Get hardware's CAPabilitieS
    memset(&g_DDCaps, 0, sizeof(g_DDCaps));
    g_DDCaps.dwSize = sizeof(g_DDCaps);
    if (g_pDD->GetCaps(&g_DDCaps, 0))
        return DisplayError("Can't get capabilities");

    // Make sure it supports overlays
    if (!(g_DDCaps.dwCaps & DDCAPS_OVERLAY))
        return DisplayError("Hardware doesn't support overlays");

    //DO NOT Make sure it supports stretching (scaling)
    //if (!(g_DDCaps.dwCaps & DDCAPS_OVERLAYSTRETCH)) return false;

    DDSURFACEDESC2              ddsd;  // DirectDraw surface descriptor
    HRESULT                     hRet;  // I'm not even going to try...
    // The pixel formats that we want the surface to be in
    DDPIXELFORMAT               ddpfOverlayFormats[] = {
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF0000, 0x0FF00, 0x0000FF, 0}, // 32-bit RGB
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x007C00, 0x003e0, 0x00001F, 0}, // 16-bit RGB 5:5:5
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x00F800, 0x007e0, 0x00001F, 0}, // 16-bit RGB 5:6:5
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, mmioFOURCC('U','Y','V','Y'), 16, 0, 0, 0, 0}, // UYVY
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, mmioFOURCC('Y','4','2','2'), 16, 0, 0, 0, 0}, // the same as UYVY
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, mmioFOURCC('Y','U','Y','2'), 16, 0, 0, 0, 0}, // YUY2 is unsupported color-space here
        {0}};

    // Setup the overlay surface's attributes in the surface descriptor
    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY | g_DDCaps.ddsCaps.dwCaps&DDSCAPS_VIDEOMEMORY;
    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
    ddsd.dwBackBufferCount = 0;
    ddsd.dwWidth = g_sizex;
    ddsd.dwHeight = g_sizey;
    for(int format = 0; ddpfOverlayFormats[format].dwSize; format++) {
        ddsd.ddpfPixelFormat = ddpfOverlayFormats[format];
        // Attempt to create the surface with theses settings
        hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSOverlay, NULL);
        if(hRet == DD_OK) break;
    }
    if (hRet != DD_OK)
        return DisplayError("Can't create appropriate overlay surface", hRet);
    return true;
}
开发者ID:ucberkeley,项目名称:lithe,代码行数:46,代码来源:ddvideo.cpp

示例2: initialize


//.........这里部分代码省略.........
  DWORD styleEx = 0;
  
  if(theApp.videoOption <= VIDEO_4X)
    style |= WS_OVERLAPPEDWINDOW;
  else
    styleEx = WS_EX_TOPMOST;

  if(theApp.videoOption <= VIDEO_4X)
    AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx);
  else
    AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx);    

  int winSizeX = theApp.dest.right-theApp.dest.left;
  int winSizeY = theApp.dest.bottom-theApp.dest.top;

  int x = 0;
  int y = 0;

  if(theApp.videoOption <= VIDEO_4X) {
    x = theApp.windowPositionX;
    y = theApp.windowPositionY;
  }

  // Create a window
  MainWnd *pWnd = new MainWnd;
  theApp.m_pMainWnd = pWnd;

  pWnd->CreateEx(styleEx,
                 theApp.wndClass,
                 "VisualBoyAdvance",
                 style,
                 x,y,winSizeX,winSizeY,
                 NULL,
                 0);
  
  if (!(HWND)*pWnd) {
    winlog("Error creating Window %08x\n", GetLastError());
    return FALSE;
  }

  
  theApp.updateMenuBar();
  
  theApp.adjustDestRect();
  
  GUID *guid = NULL;
  if(theApp.ddrawEmulationOnly)
    guid = (GUID *)DDCREATE_EMULATIONONLY;

  if(theApp.pVideoDriverGUID)
    guid = theApp.pVideoDriverGUID;

  ddrawDLL = AfxLoadLibrary("DDRAW.DLL");
  HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *);  
  if(ddrawDLL != NULL) {    
    DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *))
      GetProcAddress(ddrawDLL, "DirectDrawCreateEx");

    if(DDrawCreateEx == NULL) {
      theApp.directXMessage("DirectDrawCreateEx");
      return FALSE;
    }
  } else {
    theApp.directXMessage("DDRAW.DLL");
    return FALSE;
  }

  theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly;
  
  HRESULT hret = DDrawCreateEx(guid,
                               (void **)&pDirectDraw,
                               IID_IDirectDraw7,
                               NULL);
    
  if(hret != DD_OK) {
    winlog("Error creating DirectDraw object %08x\n", hret);
    if(theApp.ddrawEmulationOnly) {
      // disable emulation only setting in case of failure
      regSetDwordValue("ddrawEmulationOnly", 0);
    }
    //    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret);
    return FALSE;
  }

  if(theApp.ddrawDebug) {
    DDCAPS driver;
    DDCAPS hel;
    ZeroMemory(&driver, sizeof(driver));
    ZeroMemory(&hel, sizeof(hel));
    driver.dwSize = sizeof(driver);
    hel.dwSize = sizeof(hel);
    pDirectDraw->GetCaps(&driver, &hel);
    int i;
    DWORD *p = (DWORD *)&driver;
    for(i = 0; i < (int)driver.dwSize; i+=4)
      winlog("Driver CAPS %2d: %08x\n", i>>2, *p++);
    p = (DWORD *)&hel;
    for(i = 0; i < (int)hel.dwSize; i+=4)
      winlog("HEL CAPS %2d: %08x\n", i>>2, *p++);
  }
开发者ID:oydang,项目名称:CS4701-pokemon-AI,代码行数:101,代码来源:DirectDraw.cpp

示例3: DriverEnumCallback

//************************************************************************************
// DriverEnumCallback()
// Callback function for enumerating drivers.
//************************************************************************************
static BOOL WINAPI DriverEnumCallback(GUID * pGUID, TCHAR * strDesc,
                                      TCHAR * strName, VOID *, HMONITOR)
{
	D3DEnum_DeviceInfo d3dDeviceInfo;
	LPDIRECTDRAW7      pDD;
	LPDIRECT3D7        pD3D;
	HRESULT            hr;

	// Use the GUID to create the DirectDraw object
	hr = DirectDrawCreateEx(pGUID, (VOID **)&pDD, IID_IDirectDraw7, NULL);

	if (FAILED(hr))
	{
		DEBUG_MSG(_T("Can't create DDraw during enumeration!"));
		return D3DENUMRET_OK;
	}

	// Create a D3D object, to enumerate the d3d devices
	hr = pDD->QueryInterface(IID_IDirect3D7, (VOID **)&pD3D);

	if (FAILED(hr))
	{
		pDD->Release();
		DEBUG_MSG(_T("Can't query IDirect3D7 during enumeration!"));
		return D3DENUMRET_OK;
	}

	// Copy data to a device info structure
	ZeroMemory(&d3dDeviceInfo, sizeof(d3dDeviceInfo));
	lstrcpyn(d3dDeviceInfo.strDesc, strDesc, 39);
	d3dDeviceInfo.ddDriverCaps.dwSize = sizeof(DDCAPS);
	d3dDeviceInfo.ddHELCaps.dwSize    = sizeof(DDCAPS);
	pDD->GetCaps(&d3dDeviceInfo.ddDriverCaps, &d3dDeviceInfo.ddHELCaps);

	if (pGUID)
	{
		d3dDeviceInfo.guidDriver = (*pGUID);
		d3dDeviceInfo.pDriverGUID = &d3dDeviceInfo.guidDriver;
	}

	// Record whether the device can render into a desktop window
	if (d3dDeviceInfo.ddDriverCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED)
		if (NULL == d3dDeviceInfo.pDriverGUID)
			d3dDeviceInfo.bDesktopCompatible = TRUE;

	// Enumerate the fullscreen display modes.
	pDD->EnumDisplayModes(0, NULL, &d3dDeviceInfo, ModeEnumCallback);

	// Sort list of display modes
	qsort(d3dDeviceInfo.pddsdModes, d3dDeviceInfo.dwNumModes,
	      sizeof(DDSURFACEDESC2), SortModesCallback);

	// Now, enumerate all the 3D devices
	pD3D->EnumDevices(DeviceEnumCallback, &d3dDeviceInfo);

	// Clean up and return
	SAFE_DELETE(d3dDeviceInfo.pddsdModes);
	pD3D->Release();
	pDD->Release();

	return DDENUMRET_OK;
}
开发者ID:okready,项目名称:ArxFatalis,代码行数:66,代码来源:EERIEenum.cpp

示例4: D3DM_InitDevices

int D3DM_InitDevices( HWND hwnd, int w, int h, int full, HMENU menu )
{
	char	buf[256];
	int		i,j;
		LPDIRECTDRAW7 pDD = NULL;	
		HRESULT hr;
		if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&pDD, IID_IDirectDraw7, NULL ) ) )
			return DDENUMRET_CANCEL;

		D3DCapsStruct.m_ddCaps.dwSize = sizeof(DDCAPS);
		pDD->GetCaps( &D3DCapsStruct.m_ddCaps, NULL );
		if(pDD) {
			pDD->Release();
			pDD = NULL;
		}
	ZeroMemory( d3dTexture, sizeof(D3DD_TEXTURE)*D3DD_MAX_TEXTURE_AMOUNT );
	ZeroMemory( d3dText, sizeof(D3DD_TEXT)*D3DD_MAX_TEXT_AMOUNT );
	ZeroMemory( d3dDisp, sizeof(D3DD_DISP)*D3DD_MAX_DISP_AMOUNT );


	
	pD3D = Direct3DCreate8(D3D_SDK_VERSION);
	if(pD3D == NULL){
		MessageBox(NULL,"Direct3Dオブジェクトの生成に失敗しました。[DirectX8.1が入っていない?]","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}

	
	if( FAILED(pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCapsStruct.m_d3dCaps)) ){
		MessageBox(NULL,"デバイス能力の取得に失敗しました","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}
	
	EnumAdapters(D3DADAPTER_DEFAULT);

	
	if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureWidth < D3DD_TEXTURE_CONTROL_SIZE ){
		DebugBox( NULL, "このビデオカードは、幅 %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE);
		return FALSE;
	}else if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureHeight < D3DD_TEXTURE_CONTROL_SIZE ){
		DebugBox( NULL, "このビデオカードは、高さ %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE );
		return FALSE;
	}

	if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_ALPHAGOURAUDBLEND) ){
		MessageBox(NULL,"このビデオデバイスはグーロブレンディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
	}
	if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_COLORGOURAUDRGB) ){
		MessageBox(NULL,"このビデオデバイスはグーロシェーディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
	}

	if( D3DCapsStruct.m_d3dCaps.TextureCaps&D3DPTEXTURECAPS_SQUAREONLY ){
		DebugBox( NULL, "このビデオカードは長方形テクスチャを生成できません。[デバッグ用ダイアログ]" );
	}

	
	if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){	
		MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}
	D3DCapsStruct.m_WindowDisplayMode = D3DCapsStruct.m_NowDisplayMode;
	D3DMain.m_DrawHwnd = hwnd;
	D3DMain.m_MenuHwnd = menu;
	if( GetSystemMetrics(SM_CXFULLSCREEN)<=800 || GetSystemMetrics(SM_CYFULLSCREEN)<=600){
		D3DMain.m_FullScreenOnly = TRUE;
		D3DMain.m_WindowMode = FALSE;
	}else{
		D3DMain.m_FullScreenOnly = FALSE;
		D3DMain.m_WindowMode = !full;
	}


	ZeroMemory(&d3dppApp,sizeof(d3dppApp));
	


	WinWidth  = w;
	WinHeight = h;



	d3dppApp.SwapEffect = D3DSWAPEFFECT_COPY;

	d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format;
	d3dppApp.BackBufferCount = 1;
	d3dppApp.BackBufferWidth  = WinWidth;
	d3dppApp.BackBufferHeight = WinHeight;





	d3dppApp.Windowed = TRUE;							
	d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

	
	HRESULT	ret;
	ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
	if( FAILED(ret) ){	
		ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
//.........这里部分代码省略.........
开发者ID:0xrofi,项目名称:Aquaplus,代码行数:101,代码来源:d3d_main.cpp


注:本文中的LPDIRECTDRAW7::GetCaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。