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


C++ LPDIRECTDRAW::SetCooperativeLevel方法代码示例

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


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

示例1: Initiate

//------------------------------------------------------------
// Name: Initiate
// Desc: Init everything
//------------------------------------------------------------
int Initiate()
{
	// create dd object and test for an error
	hr = DirectDrawCreate(NULL,&lpdd,NULL);
	if (DDFailedCheck(hr, "DirectDrawCreate failed", cpErrorBuf ))
		return 0;
	
	// set cooperation level to windowed mode normal
	hr = lpdd->SetCooperativeLevel(main_window_handle,  DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | 
														DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT   );
	if (DDFailedCheck(hr, "SetCooperativeLevel", cpErrorBuf ))
		return 0;

	// set the display mode. use this for full screen programs
	hr = lpdd->SetDisplayMode(WINDOW_WIDTH ,WINDOW_HEIGHT,16);
	if (DDFailedCheck(hr, "SetDisplayMode", cpErrorBuf ))
		return 0;

	// Create the primary surface
	memset(&ddsd,0,sizeof(ddsd));//clear ddsd structure
	ddsd.dwSize         = sizeof(ddsd);
	ddsd.dwFlags        = DDSD_CAPS;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

	hr = lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL);
	if (DDFailedCheck(hr, "CreateSurface", cpErrorBuf ))
		return 0;

	// return success
	return(1);
}//End Initiate
开发者ID:scirelli,项目名称:testForDX5,代码行数:35,代码来源:WinMain.cpp

示例2: DDInitFullscreen

int DDInitFullscreen(int width, int height, int bpp, HWND hwnd)
{
    HRESULT ret;
    
    // create object and test for error
    if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) {
        return(0);
    }
    
    // set cooperation level to windowed mode normal
    if (lpDD->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) != DD_OK) {
        return(0);
    }
    
    // set the display mode
    if (lpDD->SetDisplayMode(width, height, bpp) != DD_OK) {
        return(0);
    }
    
    // set globals
    screen_height = height;
    screen_width = width;
    screen_bpp = bpp;
    
    // Create the primary surface
    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
    
    // we need to let dd know that we want a complex
    // flippable surface structure, set flags for that
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
    
    // set the backbuffer count to 1
    ddsd.dwBackBufferCount = 1;
    
    // create the primary surface
    ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
    
    // query for the backbuffer i.e the secondary surface
    ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
    lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
    
    // clear out both primary and secondary surfaces
    DDFillSurface(lpDDSPrimary, 0);
    DDFillSurface(lpDDSBack, 0);
    
    DDGetRGB16();
    
    return 1;
}
开发者ID:mreiferson,项目名称:dod,代码行数:51,代码来源:dodddraw.cpp

示例3: InitDDraw

BOOL InitDDraw()
{
	DDSURFACEDESC ddsd;
	HRESULT ddrval;

	DirectDrawCreate(NULL, &lpDD, NULL);//产生一个DDRAW对象。
	/*第一个参数是要创建的驱动类型,设为NULL,表示使用当前的显示驱动
	第三个参数用于今后与COM对象兼容,目前都设为NULL*/

	lpDD->SetCooperativeLevel (hWnd, DDSCL_NORMAL);//设置协作级别

	ZeroMemory( &ddsd, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS;
	/*主页面的大小和像素格式都是由当前的显示模式决定的,
	所以不能指定,否则发生错误*/
	ddsd.ddsCaps .dwCaps = DDSCAPS_PRIMARYSURFACE;
	ddrval = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
	/*第三个参数也是用于与COM对象兼容,目前只能设为NULL*/
	if(ddrval != DD_OK)
	{
		return FALSE;
	}
	
	ZeroMemory( &ddsd, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS| DDSD_HEIGHT| DDSD_WIDTH;
	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
	ddsd.dwHeight = 600;
	ddsd.dwWidth = 800;
	/*页面的大小可以和实际图片大小不一样,但会产生失真*/

	RectTemp.left = 0;
	RectTemp.top = 0;
	RectTemp.right = ddsd.dwWidth;
	RectTemp.bottom = ddsd.dwHeight;
	

	lpDD->CreateSurface (&ddsd, &lpDDSTemp, NULL);
	if(ddrval != DD_OK)
	{
		return FALSE;
	}

	DDReLoadBitmap( lpDDSTemp, "gameover.bmp");

	return TRUE;

}
开发者ID:jollywing,项目名称:jolly-code-snippets,代码行数:49,代码来源:init_ddraw.cpp

示例4: mfc_render_init

BOOL mfc_render_init(HWND hWnd)
{
	DDSURFACEDESC    ddsd;
	DDCAPS           ddcaps;

	HRESULT          hRet;

	///////////////////////////////////////////////////////////////////////////
	// Create the main DirectDraw object
	///////////////////////////////////////////////////////////////////////////
	hRet = DirectDrawCreate(NULL, &g_pDD, NULL);
	if (hRet != DD_OK)
		return PRINT_ERRMSG(TEXT("DirectDrawCreate FAILED"));

	// Get exclusive mode
	hRet = g_pDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL);
	if (hRet != DD_OK)
		return PRINT_ERRMSG(TEXT("SetCooperativeLevel FAILED"));


	// Get a primary surface interface pointer (only needed for init.)

	memset(&ddsd, 0, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
	hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL);
	if (hRet != DD_OK)
		return PRINT_ERRMSG(TEXT("CreateSurface FAILED"));

	// See if we can support overlays.
	memset(&ddcaps, 0, sizeof(ddcaps));
	ddcaps.dwSize = sizeof(ddcaps);
	hRet = g_pDD->GetCaps(&ddcaps, NULL);
	if (hRet != DD_OK)
		return PRINT_ERRMSG(TEXT("GetCaps FAILED"));

	if (ddcaps.dwOverlayCaps == 0)
		return PRINT_ERRMSG(TEXT("Overlays are not supported in hardware!"));


	// SW YUV->RGB conversion table initialization
	_initConvTab();

	return TRUE;
}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:46,代码来源:mfc_render.cpp

示例5: DDInitWindowed

int DDInitWindowed(int width, int height, int bpp, HWND hwnd)
{
    HRESULT ret;
    
    // create object and test for error
    if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) {
        return(0);
    }
    
    // set cooperation level to windowed mode normal
    if (lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL) != DD_OK) {
        return(0);
    }
    
    // set globals
    screen_height = height;
    screen_width = width;
    screen_bpp = bpp;
    
    // Create the primary surface
    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    
    // all we need for windowed mode is access to the primary surface
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    
    // create the primary surface
    ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
    
    // create an offscreen and system mem back surface
    lpDDSBack = DDCreateSurface(width, height, NULL);
    
    lpDD->CreateClipper(0, &lpDDClipper, NULL);
    lpDDClipper->SetHWnd(0, hwnd);
    lpDDSPrimary->SetClipper(lpDDClipper);
    
    // clear out both primary and secondary surfaces
    DDFillSurface(lpDDSPrimary, 0);
    DDFillSurface(lpDDSBack, 0);
    
    DDGetRGB16();
    
    return 1;
}
开发者ID:mreiferson,项目名称:dod,代码行数:45,代码来源:dodddraw.cpp

示例6: init_DirectDraw

static void init_DirectDraw() {
    /**
     * Note: if DirectDraw fails to initialize, we will use GDI to
     *  draw to do the screenBuffer->LCD copying.
     */
    HRESULT hRet;
    hRet = DirectDrawCreate(NULL, &g_pDD, NULL);
    if (hRet != DD_OK) {
        return;
    }

    hRet = g_pDD->SetCooperativeLevel(hwndMain, DDSCL_NORMAL);
    if (hRet != DD_OK) {
        g_pDD->Release();
        g_pDD = NULL;
        return;
    }

    wince_init_fonts();
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:20,代码来源:winceapp_export.cpp

示例7: screen_size

PRBool
nsWindowGfx::InitDDraw()
{
  HRESULT hr;

  hr = DirectDrawCreate(NULL, &glpDD, NULL);
  NS_ENSURE_SUCCESS(hr, PR_FALSE);

  hr = glpDD->SetCooperativeLevel(NULL, DDSCL_NORMAL);
  NS_ENSURE_SUCCESS(hr, PR_FALSE);

  DDSURFACEDESC ddsd;
  memset(&ddsd, 0, sizeof(ddsd));
  ddsd.dwSize = sizeof(ddsd);
  ddsd.dwFlags = DDSD_CAPS;
  ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
  ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

  hr = glpDD->CreateSurface(&ddsd, &glpDDPrimary, NULL);
  NS_ENSURE_SUCCESS(hr, PR_FALSE);

  hr = glpDD->CreateClipper(0, &glpDDClipper, NULL);
  NS_ENSURE_SUCCESS(hr, PR_FALSE);

  hr = glpDDPrimary->SetClipper(glpDDClipper);
  NS_ENSURE_SUCCESS(hr, PR_FALSE);

  // We do not use the cairo ddraw surface for IMAGE_DDRAW16.  Instead, we
  // use an 24bpp image surface, convert that to 565, then blit using ddraw.
  if (!IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_DDRAW16)) {
    gfxIntSize screen_size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
    gpDDSurf = new gfxDDrawSurface(glpDD, screen_size, gfxASurface::ImageFormatRGB24);
    if (!gpDDSurf) {
      /*XXX*/
      fprintf(stderr, "couldn't create ddsurf\n");
      return PR_FALSE;
    }
  }

  return PR_TRUE;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:41,代码来源:nsWindowGfx.cpp

示例8: q_initDD

void q_initDD()
{
    if (initialized)
        return;

    DirectDrawCreate(NULL, &g_pDD, NULL);

    HRESULT h;
    h = g_pDD->SetCooperativeLevel(0, DDSCL_NORMAL);

    if (h != DD_OK)
        qDebug() << "cooperation level failed";

    h = g_pDD->TestCooperativeLevel();
    if (h != DD_OK)
        qDebug() << "cooperation level failed test";

    DDSURFACEDESC ddsd;
    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);

    ddsd.dwFlags = DDSD_CAPS;

    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    h = g_pDD->CreateSurface(&ddsd, &g_pDDSSurface, NULL);

    if (h != DD_OK)
        qDebug() << "CreateSurface failed!";

    if (g_pDDSSurface->GetCaps(&ddsCaps) != DD_OK)
        qDebug() << "GetCaps failed";

    q_lock();
    q_unlock();
    initialized = true;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:37,代码来源:ddhelper.cpp

示例9: WinMain

/********************************************************************
* Function : WinMain()
* Purpose : Mandatory Windows Init function.
********************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
						 LPSTR lpCmdLine, int nCmdShow)
{
	MSG		msg;
	HWND		hwnd;
	WNDCLASS	wc;
	static char ClassName[] = "ChromeTestingFacility";
	DDSURFACEDESC	ddsd;
	DDSCAPS			ddscaps;
	HRESULT			ddreturn;
	int n;

	// Set all key booleans to FALSE, assume no key is pressed.
	bForwardKey = FALSE;
	bBackKey = FALSE;
	bLeftKey = FALSE;
	bRightKey = FALSE;
	nState = 0;
	nGauge = 0;

	lpCmdLine = lpCmdLine;
	hPrevInstance = hPrevInstance;
	RealTime = 0;	/* Start of using spacebar for frameflipping. */

	/* Register and realize our display window */
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = ClassName;
	wc.lpszClassName = ClassName;
	RegisterClass(&wc);

	/* Initialize our test world. */
	if (!InitWorld(XRES, YRES, Colormap))
	{	return FALSE;
	}

	/* Convert the Chrome colormap to a windows colormap. */
	for (n = 0; n < 256; n++)
	{
		WinColormap[n].peRed = (unsigned char)((Colormap[n] & 0xFF0000) >> 16);
		WinColormap[n].peGreen = (unsigned char)((Colormap[n] & 0xFF00) >> 8);
		WinColormap[n].peBlue = (unsigned char)((Colormap[n] & 0xFF));
		WinColormap[n].peFlags = 0;
	}
	/* Create a full screen window so that GDI won't ever be
	 * called. */
	hwnd = CreateWindowEx(WS_EX_TOPMOST,
								 ClassName,
								 ClassName,
								 WS_POPUP,
								 0,
								 0,
								 GetSystemMetrics(SM_CXSCREEN),
								 GetSystemMetrics(SM_CYSCREEN),
								 NULL,
								 NULL,
								 hInstance,
								 NULL);
	if (hwnd == NULL)
		return FALSE;
	
	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);
	SetFocus(hwnd);
	ShowCursor(FALSE);		/* Remove cursor to prevent GDI from writing. */

	/* Instanciate our DirectDraw object */
	ddreturn = DirectDrawCreate(NULL, &lpDirectDrawObject, NULL);
	if (ddreturn != DD_OK)
	{
		DestroyWindow(hwnd);
		return FALSE;
	}

	ddreturn = lpDirectDrawObject->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX);
	if (ddreturn != DD_OK)
	{
		DestroyWindow(hwnd);
		return FALSE;
	}

	/* Create a palette for the surfaces. */
	ddreturn = lpDirectDrawObject->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE,
																(LPPALETTEENTRY)WinColormap,
																&lpPalette,
																NULL);
	if (ddreturn != DD_OK)
	{	DestroyWindow(hwnd);
		return FALSE;
	}
//.........这里部分代码省略.........
开发者ID:kingletbv,项目名称:chrome2k,代码行数:101,代码来源:dxmain.cpp

示例10: dd_SetMode

int dd_SetMode(int xres, int yres, int bpp, bool windowflag)
{
	HRESULT hr;

	if (!dd_initd)
		dd_init();

	//do this now for the gamewindow, because this is the first time we know what size to make the gamewindow
	if(!dd_bGameWindowRectInitialized)
	{
		RECT r;
		dd_gameWindow->adjust(xres,yres,&r);

		int base_win_x_res = getInitialWindowXres();
		int base_win_y_res = getInitialWindowYres();

		/// this is for the windowsize verge.cfg vars.
		if( base_win_x_res > 0 && base_win_y_res > 0 ) {
			int win_offset_x = (r.right-r.left) - xres;
			int win_offset_y = (r.bottom-r.top) - yres;

			dd_gameWindow->winw = win_offset_x+base_win_x_res;
			dd_gameWindow->winh = win_offset_y+base_win_y_res;
		
		} else {
			dd_gameWindow->winw = r.right-r.left;
			dd_gameWindow->winh = r.bottom-r.top;
		}

		WINDOWPLACEMENT wp;
		wp.length = sizeof(WINDOWPLACEMENT);
		GetWindowPlacement(dd_gameWindow->hwnd,&wp);
		wp.rcNormalPosition.left = GetSystemMetrics(SM_CXSCREEN)/2-xres/2;
		wp.rcNormalPosition.top = GetSystemMetrics(SM_CYSCREEN)/2-yres/2;
		wp.rcNormalPosition.right = wp.rcNormalPosition.left + dd_gameWindow->winw;
		wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + dd_gameWindow->winh;
		SetWindowPlacement(dd_gameWindow->hwnd,&wp);

		dd_bGameWindowRectInitialized = true;
	}

	//must deactivate all auxwindows
	if(vid_window && !windowflag)
		for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++)
		{
			if(!(*it)->bGameWindow)
				(*it)->deactivate();
		}

	if (!windowflag)
	{
		//if we are switching into fullscreen, we are going to lose these sizes and positions
		//save them now so we can restore them when we flip back to windowmode
		if(vid_window)
		{
			WINDOWPLACEMENT wp;
			wp.length = sizeof(WINDOWPLACEMENT);
			GetWindowPlacement(dd_gameWindow->hwnd,&wp);
			dd_gameWindow->winx = wp.rcNormalPosition.left;
			dd_gameWindow->winy = wp.rcNormalPosition.top;
			dd_gameWindow->winw = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
			dd_gameWindow->winh = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
			dd_bWasMaximized = (wp.showCmd == SW_SHOWMAXIMIZED);
		}

		//ShowWindow(dd_gameWindow->hwnd,SW_SHOWMAXIMIZED);
		ShowWindow(dd_gameWindow->hwnd,SW_HIDE);

		int ret = dd_gameWindow->set_fullscreen(xres,yres,bpp);
		if(!ret)
			return 0;

		ShowWindow(dd_gameWindow->hwnd,SW_SHOW);

		dd_gameWindow->xres = xres;
		dd_gameWindow->yres = yres;

		vid_xres = xres;
		vid_yres = yres;
		vid_window = false;
		dd_bHasBeenFullscreen = true;

		dd_RegisterBlitters();
		return ret;
	}
	else
	{
		DX_RELEASE(dx_ps);
		DX_RELEASE(dx_win_ps);

		if (bpp != DesktopBPP) return 0;
		if (!vid_window)
			dx_dd->RestoreDisplayMode();
		dx_dd->SetCooperativeLevel(dd_gameWindow->hwnd, DDSCL_NORMAL);

		hr = dx_dd->CreateSurface(&dx_win_psd, &dx_win_ps, NULL);
		if (hr != DD_OK)
		{
			return 0;
		}
//.........这里部分代码省略.........
开发者ID:Bananattack,项目名称:verge3,代码行数:101,代码来源:vid_ddbase.cpp

示例11: _GameMode

BOOL _GameMode( HINSTANCE hInstance, int nCmdShow, int x, int y, int bpp )
{
    HRESULT result;
    WNDCLASS wc;
    DDSURFACEDESC ddsd;
    DDSCAPS ddscaps;
    LPDIRECTDRAW pdd;

    wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    wc.lpfnWndProc = WindowProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wc.hCursor = LoadCursor( NULL, IDC_ARROW );
    wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "EXAM3";
    RegisterClass( &wc );

    MainHwnd = CreateWindowEx (
            0, "EXAM3", NULL, WS_POPUP, 0, 0,
            GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
            NULL, NULL, hInstance, NULL );


    if ( !MainHwnd ) return FALSE;

    SetFocus( MainHwnd );
    ShowWindow( MainHwnd, nCmdShow );
    UpdateWindow( MainHwnd );
    ShowCursor( FALSE );

    result = DirectDrawCreate( NULL, &pdd, NULL );
    if ( result != DD_OK ) return Fail( MainHwnd );

    result = pdd->QueryInterface(IID_IDirectDraw, (LPVOID *) &DirectOBJ);
    if ( result != DD_OK ) return Fail( MainHwnd );

	gWidth=x;
	gHeight=y;

	// 윈도우 핸들의 협력 단계를 설정한다.
	if(gFullScreen){
	    result = DirectOBJ->SetCooperativeLevel( MainHwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
		if ( result != DD_OK ) return Fail( MainHwnd );

		result = DirectOBJ->SetDisplayMode( x, y, bpp);
		if ( result != DD_OK ) return Fail( MainHwnd );

		memset( &ddsd, 0, sizeof(ddsd) );
		ddsd.dwSize = sizeof( ddsd );
		ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
		ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
		ddsd.dwBackBufferCount = 1;

	    result = DirectOBJ -> CreateSurface( &ddsd, &RealScreen, NULL );
	   if ( result != DD_OK ) return Fail( MainHwnd );

		memset( &ddscaps, 0, sizeof(ddscaps) );
		ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
		result = RealScreen -> GetAttachedSurface( &ddscaps, &BackScreen );
		if ( result != DD_OK ) return Fail( MainHwnd );

	}
	else{
	    result = DirectOBJ->SetCooperativeLevel( MainHwnd, DDSCL_NORMAL );
		if ( result != DD_OK ) return Fail( MainHwnd );

		memset( &ddsd, 0, sizeof(ddsd) );
	    ddsd.dwSize = sizeof( ddsd );
		ddsd.dwFlags = DDSD_CAPS;
	    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
		ddsd.dwBackBufferCount = 0;

		result = DirectOBJ -> CreateSurface( &ddsd, &RealScreen, NULL );
	    if(result != DD_OK) return Fail(MainHwnd);

		memset( &ddsd, 0, sizeof(ddsd) );
		ddsd.dwSize = sizeof(ddsd);
	    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
		ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
		ddsd.dwWidth = x; 
		ddsd.dwHeight = y;
		result = DirectOBJ->CreateSurface( &ddsd, &BackScreen, NULL );
		if ( result != DD_OK ) return Fail( MainHwnd );

		result = DirectOBJ->CreateClipper( 0, &ClipScreen, NULL);
		if ( result != DD_OK ) return Fail( MainHwnd );

		result = ClipScreen->SetHWnd( 0, MainHwnd );
		if ( result != DD_OK ) return Fail( MainHwnd );

		result = RealScreen->SetClipper( ClipScreen );
		if ( result != DD_OK ) return Fail( MainHwnd );

		SetWindowPos(MainHwnd, NULL, 100, 100, x, y, SWP_NOZORDER | SWP_NOACTIVATE); 
	}


//.........这里部分代码省略.........
开发者ID:Redrock912,项目名称:reboot,代码行数:101,代码来源:spriteSound.cpp

示例12: GetDXVersion


//.........这里部分代码省略.........
    }

    DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( hDInputDLL,
                                                        "DirectInputCreateA" );
    if( DirectInputCreate == NULL )
    {
        // No DInput... must be DX2
        FreeLibrary( hDInputDLL );
        pDDraw->Release();
        FreeLibrary( hDDrawDLL );
        OutputDebugString(_T("Couldn't GetProcAddress DInputCreate\r\n"));
        return dwDXVersion;
    }

    // DirectInputCreate exists. We are at least DX3
    dwDXVersion = 0x300;
    FreeLibrary( hDInputDLL );

    // Can do checks for 3a vs 3b here


	//-------------------------------------------------------------------------
    // DirectX 5.0 Checks
	//-------------------------------------------------------------------------

    // We can tell if DX5 is present by checking for the existence of
    // IDirectDrawSurface3. First, we need a surface to QI off of.
    DDSURFACEDESC ddsd;
    ZeroMemory( &ddsd, sizeof(ddsd) );
    ddsd.dwSize         = sizeof(ddsd);
    ddsd.dwFlags        = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL );
    if( FAILED(hr) )
    {
        // Failure. This means DDraw isn't properly installed.
        pDDraw->Release();
        FreeLibrary( hDDrawDLL );
        dwDXVersion = 0;
        OutputDebugString(_T("Couldn't Set coop level\r\n"));
        return dwDXVersion;
    }

    hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL );
    if( FAILED(hr) )
    {
        // Failure. This means DDraw isn't properly installed.
        pDDraw->Release();
        FreeLibrary( hDDrawDLL );
        dwDXVersion = 0;
        OutputDebugString(_T("Couldn't CreateSurface\r\n"));
        return dwDXVersion;
    }

    // Query for the IDirectDrawSurface3 interface
    if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3,
                                       (VOID**)&pSurf3 ) ) )
    {
        pSurf->Release();
        pDDraw->Release();
        FreeLibrary( hDDrawDLL );
        OutputDebugString(_T("Couldn't QI DDS3\r\n"));
        return dwDXVersion;
    }
开发者ID:identity0815,项目名称:os45,代码行数:66,代码来源:getdxver.cpp

示例13: GetDXVersion


//.........这里部分代码省略.........
    }

    DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst,
                                                        "DirectInputCreateA" );
    if( DirectInputCreate == 0 )
    {
        // No DInput... must be DX2
        FreeLibrary( DIHinst );
        FreeLibrary( DDHinst );
        pDDraw->Release();
        OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" );
        return;
    }

    // DirectInputCreate exists. We are at least DX3
    (*pdwDXVersion) = 0x300;
    FreeLibrary( DIHinst );

    // Can do checks for 3a vs 3b here


    ///////////////////////////////////////////////////////////////////////////
    // DirectX 5.0 Checks
    ///////////////////////////////////////////////////////////////////////////

    // We can tell if DX5 is present by checking for the existence of
    // IDirectDrawSurface3. First, we need a surface to QI off of.
    DDSURFACEDESC ddsd;
    ZeroMemory( &ddsd, sizeof(ddsd) );
    ddsd.dwSize         = sizeof(ddsd);
    ddsd.dwFlags        = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL );
    if( FAILED(hr) )
    {
        // Failure. This means DDraw isn't properly installed.
        pDDraw->Release();
        FreeLibrary( DDHinst );
        (*pdwDXVersion) = 0;
        OutputDebugString( "Couldn't Set coop level\r\n" );
        return;
    }

    hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL );
    if( FAILED(hr) )
    {
        // Failure. This means DDraw isn't properly installed.
        pDDraw->Release();
        FreeLibrary( DDHinst );
        *pdwDXVersion = 0;
        OutputDebugString( "Couldn't CreateSurface\r\n" );
        return;
    }

    // Query for the IDirectDrawSurface3 interface
    if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3,
                                       (VOID**)&pSurf3 ) ) )
    {
        pDDraw->Release();
        FreeLibrary( DDHinst );
        return;
    }

    // QI for IDirectDrawSurface3 succeeded. We must be at least DX5
    (*pdwDXVersion) = 0x500;
开发者ID:Cav098,项目名称:blitz3d,代码行数:67,代码来源:checkdx.cpp

示例14: rglswCreateWindow

extern "C" unsigned char rglswCreateWindow(GLint ihwnd, GLint width)
{
    DDSURFACEDESC ddsd;
    HRESULT       ddrval;
    DDPIXELFORMAT pix;
    DDSCAPS       ddscaps;
    DDCAPS        ddcaps;
    HWND          hWnd = (HWND)ihwnd;

    SCRWIDTH = width;
    switch (width)
    {
    case 1600:
        SCRHEIGHT = 1200;
        break;
    case 1280:
        SCRHEIGHT = 1024;
        break;
    case 1024:
        SCRHEIGHT = 768;
        break;
    case 800:
        SCRHEIGHT = 600;
        break;
    default:
        SCRWIDTH  = 640;
        SCRHEIGHT = 480;
    }

    hwnd = hWnd;

    ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
    if (ddrval != DD_OK)
    {
        return FALSE;
    }

    ZeroMemory(&ddcaps, sizeof(ddcaps));
    ddcaps.dwSize = sizeof(ddcaps);
    lpDD->GetCaps(&ddcaps, NULL);

    if (WINDOWED)
    {
        ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
        if (ddrval != DD_OK)
        {
            return FALSE;
        }
    }
    else
    {
        ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
        if (ddrval != DD_OK)
        {
            return FALSE;
        }

        ddrval = lpDD->SetDisplayMode(SCRWIDTH, SCRHEIGHT, 16);
        if (ddrval != DD_OK)
        {
            return FALSE;
        }
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    if (WINDOWED)
    {
        ddsd.dwFlags = DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
        ddrval = lpDD->CreateSurface(&ddsd, &PrimarySurface, NULL);
    }
    else
    {
        ddsd.dwFlags = DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
        ddrval = lpDD->CreateSurface(&ddsd, &PrimarySurface, NULL);
    }
    if (ddrval != DD_OK)
    {
        return FALSE;
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
    ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
    ddsd.dwWidth = SCRWIDTH;
    ddsd.dwHeight = SCRHEIGHT;
    ddrval = lpDD->CreateSurface(&ddsd, &BackSurface, NULL);
    if (ddrval != DD_OK)
    {
        ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
        ddrval = lpDD->CreateSurface(&ddsd, &BackSurface, NULL);
    }
    if (ddrval != DD_OK)
    {
        return FALSE;
    }

//.........这里部分代码省略.........
开发者ID:Almamu,项目名称:homeworld,代码行数:101,代码来源:draw.cpp

示例15: set_fullscreen

//must be the game window
int dd_Window::set_fullscreen(int w, int h, int bpp)
{
	_ASSERTE(bGameWindow);

	quad ws;
	HRESULT hr;


	DX_RELEASE(dx_os);
	DX_RELEASE(dx_ps);
	DX_RELEASE(dx_win_ps);

	hr = dx_dd->SetCooperativeLevel(hMainWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
	if (hr != DD_OK)
	{
		return 0;
	}

	//hack for 320x200 letterboxing
	if(w == 320 && h == 200)
		dx_dd->SetDisplayMode(320, 240, bpp);
	else
		dx_dd->SetDisplayMode(w, h, bpp);


	hr = dx_dd->CreateSurface(&dx_psd, &dx_ps, NULL);
	if (hr != DD_OK)
	{
		return 0;
	}


	dx_osd.dwWidth=w;
	dx_osd.dwHeight=h;
	hr=dx_dd->CreateSurface(&dx_osd,&dx_os,NULL);
	if(hr!=DD_OK)
	{
		return 0;
	}
	hr = dx_ps->GetAttachedSurface(&dx_bsd.ddsCaps, &dx_bs);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_os);
		return 0;
	}

	ws = GetWindowLong(hwnd, GWL_STYLE);
	ws &= ~WS_OVERLAPPEDWINDOW;
	ws |= WS_POPUP;
	SetWindowLong(hwnd, GWL_STYLE, ws);
	SetWindowPos(hwnd,0,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED | SWP_NOZORDER);

	//make window take up entire screen
	//choose one or the other
	//SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOZORDER);
	ShowWindow(hwnd,SW_SHOWMAXIMIZED);

	//set pixelformat parameters
	{
		DDPIXELFORMAT ddpf;
		ddpf.dwSize = sizeof(ddpf);
		ddpf.dwFlags = DDPF_RGB;
		hr = dx_ps->GetPixelFormat(&ddpf);
		if (hr != DD_OK) err("Could not get pixel format!");
		//if (ddpf.dwRBitMask == 0x7C00 && bpp == 16)
		//	vid_bpp = 15, vid_bytesperpixel = 2;
		//else
		//	vid_bpp = bpp, vid_bytesperpixel = bpp / 8;
		vid_bpp = 32;
	}


	if(img) delete img;
	img = new image();
	img->shell = true;

	SetHandleImage(1,img);
	screen = img;

//	img->alphamap = 0;
	img->width = w;
	img->height = h;
	img->cx1 = 0;
	img->cx2 = w-1;
	img->cy1 = 0;
	img->cy2 = h-1;
	img->data=0;

	flip_fullscreen();

	return 1;
}
开发者ID:Bananattack,项目名称:verge3,代码行数:93,代码来源:vid_ddbase.cpp


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