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


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

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


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

示例1: 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

示例2: 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

示例3: _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

示例4: InitGraphics


//.........这里部分代码省略.........
                              DDSCAPS_FLIP |
                              DDSCAPS_COMPLEX;
        ddsd.dwBackBufferCount = 1;
        if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer,
                                               NULL ) ) )
        {
            ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
            return E_FAIL;
        }

        // Get a pointer to the back buffer
        ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
        if( FAILED( hr = g_pddsFrontBuffer->GetAttachedSurface( &ddscaps,
                                                         &g_pddsBackBuffer ) ) )
        {
            ShowError(IDS_DDRAW_ERROR_GAS);
            return E_FAIL;
        }
    }
    else
    {
        LPDIRECTDRAWCLIPPER pcClipper;
        
        // Window case, create the primary surface
        // and create a backbuffer in offscreen memory
        ddsd.dwFlags = DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

        if( FAILED( g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer, NULL ) ) )
        {
            ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
            return E_FAIL;
        }

        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;    
        ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
        ddsd.dwWidth = MAX_DEFWIN_X;
        ddsd.dwHeight = MAX_DEFWIN_Y;
        if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsBackBuffer, NULL ) ) )
        {
            ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
            return E_FAIL;
        }

        if( FAILED( hr = g_pDD->CreateClipper( 0, &pcClipper, NULL) ) )
        {
            ShowError(IDS_DDRAW_ERROR_CC);
            return E_FAIL;
        }

        if( FAILED( hr = pcClipper->SetHWnd( 0, g_hwndMain) ) )
        {
            pcClipper->Release();
            ShowError(IDS_DDRAW_ERROR_SH);
            return E_FAIL;
        }

        if( FAILED( hr = g_pddsFrontBuffer->SetClipper( pcClipper) ) )
        {
            pcClipper->Release();
            ShowError(IDS_DDRAW_ERROR_SC);
            return E_FAIL;
        }

        // Done with clipper
        pcClipper->Release();
    }

    ddsd.dwFlags        = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; 
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

    ddsd.dwWidth  = 320;
    ddsd.dwHeight = 128;
    
    for( DWORD i=0; i<4; i++ )
    {
        if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsShip[i], NULL ) ) )
        {
            ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
            return E_FAIL;
        }   
    }

    ddsd.dwHeight = 16;
    if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsNumbers, NULL ) ) )
    {
        ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
        return E_FAIL;
    }

    if( FAILED( RestoreSurfaces() ) )
    {
        ShowError(IDS_DDRAW_ERROR_RS);
        return E_FAIL;
    }
    
    g_dwKeys = 0;
    ShowWindow( g_hwndMain, SW_SHOW);
    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:101,代码来源:gfx.cpp

示例5: set_win

int dd_Window::set_win(int w, int h, int bpp)
{
//	RECT r, r2;
	HRESULT hr;

	shutdown_win();

	dx_win_bsd.dwWidth = w;
	dx_win_bsd.dwHeight = h;
	hr = dx_dd->CreateSurface(&dx_win_bsd, &dx_win_bs, NULL);
	if (hr != DD_OK)
	{
		return 0;
	}
	hr = dx_win_bs->Lock(0, &dx_win_bsd, 0, 0);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		return 0;
	}
	dx_win_bs->Unlock(0);
	hr = dx_dd->CreateClipper(0, &clipper, 0);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		return 0;
	}
	hr = clipper->SetHWnd(0, hwnd);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		DX_RELEASE(clipper);
		return 0;
	}

	if(bGameWindow)
	{
		int ws = GetWindowLong(hwnd,GWL_STYLE);
		ws &= ~WS_POPUP;
		ws |= WS_OVERLAPPEDWINDOW | WS_THICKFRAME;
		SetWindowLong(hwnd, GWL_STYLE, ws);
	}

	//set pixelformat parameters
	//if(bGameWindow)
	//{
	//	DDPIXELFORMAT ddpf;
	//	ddpf.dwSize = sizeof(ddpf);
	//	ddpf.dwFlags = DDPF_RGB;
	//	hr = dx_win_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;
	//}

	delete img;
	img = new image();
	img->width = w;
	img->height = h;
	img->cx1 = 0;
	img->cx2 = w-1;
	img->cy1 = 0;
	img->cy2 = h-1;
	
	if(vid_bpp == DesktopBPP) {
		img->shell = true;
		img->data = (quad*)dx_win_bsd.lpSurface;
		img->pitch = dx_win_bsd.lPitch / vid_bytesperpixel;
	} else {
		img->alloc_data();
	}

	SetHandleImage(imgHandle,img);
	if(bGameWindow)
	{
		SetHandleImage(1,img);
		screen = img;
	}
	

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


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