• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IDirect3DSurface8类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IDirect3DSurface8的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSurface8类的具体用法?C++ IDirect3DSurface8怎么用?C++ IDirect3DSurface8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: d3d8_init_format_backbuffer

static bool d3d8_init_format_backbuffer(IDirect3DDevice8 *device)
{
	IDirect3DSurface8 *backbuffer;
	D3DSURFACE_DESC desc;
	HRESULT hr;

	if (!d3d8_get_window_handle(device))
		return false;

	backbuffer = d3d8_get_backbuffer(device);
	if (!backbuffer)
		return false;

	hr = backbuffer->GetDesc(&desc);
	backbuffer->Release();
	if (FAILED(hr)) {
		hlog_hr("d3d8_init_format_backbuffer: Failed to get "
				"backbuffer descriptor", hr);
		return false;
	}

	data.d3d8_format = desc.Format;
	data.dxgi_format = d3d8_to_dxgi_format(desc.Format);
	data.cx = desc.Width;
	data.cy = desc.Height;

	return true;
}
开发者ID:AlexNe,项目名称:obs-studio,代码行数:28,代码来源:d3d8-capture.cpp


示例2: d3d8_shmem_capture

static void d3d8_shmem_capture(IDirect3DDevice8 *device,
		IDirect3DSurface8 *backbuffer)
{
	int cur_surface;
	int next_surface;
	HRESULT hr;

	cur_surface = data.cur_surface;
	next_surface = (cur_surface == NUM_BUFFERS - 1) ? 0 : cur_surface + 1;

	if (data.copy_wait < NUM_BUFFERS - 1) {
		data.copy_wait++;
	} else {
		IDirect3DSurface8 *src = backbuffer;
		IDirect3DSurface8 *dst = data.copy_surfaces[cur_surface];

		if (shmem_texture_data_lock(next_surface)) {
			dst->UnlockRect();
			data.surface_locked[next_surface] = false;
			shmem_texture_data_unlock(next_surface);
		}

		hr = device->CopyRects(src, nullptr, 0, dst, nullptr);
		if (SUCCEEDED(hr)) {
			d3d8_shmem_capture_copy(cur_surface);
		}
	}

	data.cur_surface = next_surface;
}
开发者ID:AlexNe,项目名称:obs-studio,代码行数:30,代码来源:d3d8-capture.cpp


示例3: ReplaceBootTexture

void ReplaceBootTexture(IDirect3DTexture8* srcTexture, IDirect3DTexture8* repTexture, UINT width)
{
    IDirect3DSurface8* src = NULL;
    IDirect3DSurface8* dest = NULL;

    RECT destRect;
    RECT srcRect = {0,0,170,256};
    if (width == 512) {
        destRect.top=0; destRect.left=0;
        destRect.bottom=256; destRect.right=170;
    } else {
        destRect.top=0; destRect.left=0;
        destRect.bottom=64; destRect.right=170/4;
    }

    if (SUCCEEDED(srcTexture->GetSurfaceLevel(0, &dest))) {
        if (SUCCEEDED(repTexture->GetSurfaceLevel(0, &src))) {
            // need 3 copies of the boot texture
            for (int i=0; i<3; i++) {
                destRect.left = (width==512) ? (i*170) : (i*170/4);
                destRect.right = (width==512) ? ((i+1)*170) : ((i+1)*170/4);
                if (SUCCEEDED(D3DXLoadSurfaceFromSurface(
                                dest, NULL, &destRect,
                                src, NULL, &srcRect,
                                D3DX_DEFAULT, 0))) {
                } else {
                }
            }
            src->Release();
        }
        dest->Release();
    }
}
开发者ID:kitserver,项目名称:kitserver5,代码行数:33,代码来源:bootserv.cpp


示例4:

//! lock function
void* CD3D8Texture::lock(bool readOnly, u32 mipmapLevel)
{
	if (!Texture)
		return 0;

	MipLevelLocked=mipmapLevel;
	HRESULT hr;
	D3DLOCKED_RECT rect;
	if(!IsRenderTarget)
	{
		hr = Texture->LockRect(mipmapLevel, &rect, 0, readOnly?D3DLOCK_READONLY:0);
		if (FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
			return 0;
		}
	}
	else
	{
		if (!RTTSurface)
		{
			// Make RTT surface large enough for all miplevels (including 0)
			D3DSURFACE_DESC desc;
			Texture->GetLevelDesc(0, &desc);
			hr = Device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &RTTSurface);
			if (FAILED(hr))
			{
				os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
				return 0;
			}
		}

		IDirect3DSurface8 *surface = 0;
		hr = Texture->GetSurfaceLevel(mipmapLevel, &surface);
		if (FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", "Could not get surface.", ELL_ERROR);
			return 0;
		}
		hr = Device->CopyRects(surface, 0, 0, RTTSurface, 0);
		surface->Release();
		if(FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", "Data copy failed.", ELL_ERROR);
			return 0;
		}
		hr = RTTSurface->LockRect(&rect, 0, readOnly?D3DLOCK_READONLY:0);
		if(FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", "LockRect failed.", ELL_ERROR);
			return 0;
		}
	}
	return rect.pBits;
}
开发者ID:Lumirion,项目名称:pseuwow,代码行数:56,代码来源:CD3D8Texture.cpp


示例5:

//! lock function
void* CD3D8Texture::lock(bool readOnly)
{
	if (!Texture)
		return 0;

	HRESULT hr;
	D3DLOCKED_RECT rect;
	if(!IsRenderTarget)
	{
		hr = Texture->LockRect(0, &rect, 0, readOnly?D3DLOCK_READONLY:0);
	}
	else
	{
		D3DSURFACE_DESC desc;
		Texture->GetLevelDesc(0, &desc);
		if (!RTTSurface)
		{
			hr = Device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &RTTSurface);
			if (FAILED(hr))
			{
				os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
				return 0;
			}
		}

		IDirect3DSurface8 *surface = 0;
		hr = Texture->GetSurfaceLevel(0, &surface);
		if (FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
			return 0;
		}
		hr = Device->CopyRects(surface, 0, 0, RTTSurface, 0);
		surface->Release();
		if(FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
			return 0;
		}
		hr = RTTSurface->LockRect(&rect, 0, readOnly?D3DLOCK_READONLY:0);
		if(FAILED(hr))
		{
			os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
			return 0;
		}
		return rect.pBits;
	}
	if (FAILED(hr))
	{
		os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
		return 0;
	}

	return rect.pBits;
}
开发者ID:RealBadAngel,项目名称:irrlicht.netcp,代码行数:56,代码来源:CD3D8Texture.cpp


示例6: d3d8_shmem_capture_copy

static void d3d8_shmem_capture_copy(int idx)
{
	IDirect3DSurface8 *target = data.copy_surfaces[idx];
	D3DLOCKED_RECT rect;
	HRESULT hr;

	if (data.surface_locked[idx])
		return;

	hr = target->LockRect(&rect, nullptr, D3DLOCK_READONLY);
	if (SUCCEEDED(hr)) {
		shmem_copy_data(idx, rect.pBits);
	}
}
开发者ID:AlexNe,项目名称:obs-studio,代码行数:14,代码来源:d3d8-capture.cpp


示例7: getTextureSizeFromSurfaceSize

void CD3D8Texture::createRenderTarget()
{
	TextureSize.Width = getTextureSizeFromSurfaceSize(TextureSize.Width);
	TextureSize.Height = getTextureSizeFromSurfaceSize(TextureSize.Height);

	// get backbuffer format to create the render target in the
	// same format

	IDirect3DSurface8* bb;
	D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8;

	if (!FAILED(Device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &bb)))
	{
		D3DSURFACE_DESC desc;
		bb->GetDesc(&desc);
		d3DFormat = desc.Format;

		if (d3DFormat == D3DFMT_X8R8G8B8)
			d3DFormat = D3DFMT_A8R8G8B8;

		bb->Release();
	}
	else
	{
		os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.",
			ELL_WARNING);
		return;
	}

	// create texture
	HRESULT hr;

	hr = Device->CreateTexture(
		TextureSize.Width,
		TextureSize.Height,
		1, // mip map level count, we don't want mipmaps here
		D3DUSAGE_RENDERTARGET,
		d3DFormat,
		D3DPOOL_DEFAULT,
		&Texture);

	// get irrlicht format from D3D format
	ColorFormat = getColorFormatFromD3DFormat(d3DFormat);

	if (FAILED(hr))
		os::Printer::log("Could not create render target texture");
}
开发者ID:3di,项目名称:3di-viewer-rei-libs,代码行数:47,代码来源:CD3D8Texture.cpp


示例8: defined

RageSurface* RageDisplay_D3D::CreateScreenshot()
{
#if defined(XBOX)
	return NULL;
#else
	/* Get the back buffer. */
	IDirect3DSurface8* pSurface;
	g_pd3dDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pSurface );

	/* Get the back buffer description. */
	D3DSURFACE_DESC desc;
	pSurface->GetDesc( &desc );

	/* Copy the back buffer into a surface of a type we support. */
	IDirect3DSurface8* pCopy;
	g_pd3dDevice->CreateImageSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, &pCopy );

	D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_DEFAULT, 0 );

	pSurface->Release();

	/* Update desc from the copy. */
	pCopy->GetDesc( &desc );

	D3DLOCKED_RECT lr;

	{
		RECT rect; 
		rect.left = 0;
		rect.top = 0;
		rect.right = desc.Width;
		rect.bottom = desc.Height;
		pCopy->LockRect( &lr, &rect, D3DLOCK_READONLY );
	}

	RageSurface *surface = CreateSurfaceFromPixfmt( FMT_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
	ASSERT( surface );

	/* We need to make a copy, since lr.pBits will go away when we call UnlockRect(). */
	RageSurface *SurfaceCopy = 
		CreateSurface( surface->w, surface->h,
			surface->format->BitsPerPixel,
			surface->format->Rmask, surface->format->Gmask,
			surface->format->Bmask, surface->format->Amask );
	RageSurfaceUtils::CopySurface( surface, SurfaceCopy );
	delete surface;

	pCopy->UnlockRect();
	pCopy->Release();

	return SurfaceCopy;
#endif
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:53,代码来源:RageDisplay_D3D.cpp


示例9: CreateSurfaceFromPixfmt

RageSurface* RageDisplay_D3D::CreateScreenshot()
{
	// Get the back buffer.
	IDirect3DSurface8* pSurface;
	g_pd3dDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pSurface );

	// Get the back buffer description.
	D3DSURFACE_DESC desc;
	pSurface->GetDesc( &desc );

	// Copy the back buffer into a surface of a type we support.
	IDirect3DSurface8* pCopy;
	g_pd3dDevice->CreateImageSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, &pCopy );
	
	// Aldo_MX: D3DXLoadSurfaceFromSurface requires d3dx8core.h, I replaced it with CopyRects to
	// remove this dependency so its possible to compile SM with any DirectX SDK up to Aug 2007
	D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_DEFAULT, 0 );
	//g_pd3dDevice->CopyRects( pSurface, NULL, 0, pCopy, NULL );

	pSurface->Release();

	// Update desc from the copy.
	pCopy->GetDesc( &desc );

	D3DLOCKED_RECT lr;

	{
		RECT rect; 
		rect.left = 0;
		rect.top = 0;
		rect.right = desc.Width;
		rect.bottom = desc.Height;
		pCopy->LockRect( &lr, &rect, D3DLOCK_READONLY );
	}

	RageSurface *surface = CreateSurfaceFromPixfmt( PixelFormat_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
	ASSERT( surface );

	// We need to make a copy, since lr.pBits will go away when we call UnlockRect().
	RageSurface *SurfaceCopy = 
		CreateSurface( surface->w, surface->h,
			surface->format->BitsPerPixel,
			surface->format->Rmask, surface->format->Gmask,
			surface->format->Bmask, surface->format->Amask );
	RageSurfaceUtils::CopySurface( surface, SurfaceCopy );
	delete surface;

	pCopy->UnlockRect();
	pCopy->Release();

	return SurfaceCopy;
}
开发者ID:SamDecrock,项目名称:stepmania5-http-post-scores,代码行数:52,代码来源:RageDisplay_D3D.cpp


示例10: hook_present

static HRESULT STDMETHODCALLTYPE hook_present(IDirect3DDevice8 *device,
		CONST RECT *src_rect, CONST RECT *dst_rect,
		HWND override_window, CONST RGNDATA *dirty_region)
{
	IDirect3DSurface8 *backbuffer;
	HRESULT hr;

	backbuffer = d3d8_get_backbuffer(device);
	if (backbuffer) {
		d3d8_capture(device, backbuffer);
		backbuffer->Release();
	}

	unhook(&present);
	present_t call = (present_t)present.call_addr;
	hr = call(device, src_rect, dst_rect, override_window, dirty_region);
	rehook(&present);

	return hr;
}
开发者ID:AlexNe,项目名称:obs-studio,代码行数:20,代码来源:d3d8-capture.cpp


示例11: ReplaceTextureLevel

void ReplaceTextureLevel(IDirect3DTexture8* srcTexture, IDirect3DTexture8* repTexture, UINT level)
{
    IDirect3DSurface8* src = NULL;
    IDirect3DSurface8* dest = NULL;

    if (SUCCEEDED(srcTexture->GetSurfaceLevel(level, &dest))) {
        if (SUCCEEDED(repTexture->GetSurfaceLevel(level, &src))) {
            //DumpTexture(srcTexture);
            if (SUCCEEDED(D3DXLoadSurfaceFromSurface(
                            dest, NULL, NULL,
                            src, NULL, NULL,
                            D3DX_DEFAULT, 0))) {
                //LogWithNumber(&k_boot,"ReplaceTextureLevel: replacing level %d COMPLETE", level);

            } else {
                //LogWithNumber(&k_boot,"ReplaceTextureLevel: replacing level %d FAILED", level);
            }
            src->Release();
        }
        dest->Release();
    }
}
开发者ID:kitserver,项目名称:kitserver5,代码行数:22,代码来源:bootserv.cpp


示例12: if

//! Regenerates the mip map levels of the texture. Useful after locking and
//! modifying the texture
void CD3D8Texture::regenerateMipMapLevels(void* mipmapData)
{
	if (mipmapData)
	{
		core::dimension2du size = TextureSize;
		u32 level=0;
		do
		{
			if (size.Width>1)
				size.Width /=2;
			if (size.Height>1)
				size.Height /=2;
			++level;
			IDirect3DSurface8* mipSurface = 0;
			HRESULT hr = Texture->GetSurfaceLevel(level, &mipSurface);
			if (FAILED(hr) || !mipSurface)
			{
				os::Printer::log("Could not get mipmap level", ELL_WARNING);
				return;
			}
			D3DSURFACE_DESC mipDesc;
			mipSurface->GetDesc(&mipDesc);
			D3DLOCKED_RECT miplr;

			// lock mipmap surface
			if (FAILED(mipSurface->LockRect(&miplr, NULL, 0)))
			{
				mipSurface->Release();
				os::Printer::log("Could not lock texture", ELL_WARNING);
				return;
			}

			memcpy(miplr.pBits, mipmapData, size.getArea()*getPitch()/TextureSize.Width);
			mipmapData = (u8*)mipmapData+size.getArea()*getPitch()/TextureSize.Width;
			// unlock
			mipSurface->UnlockRect();
			// release
			mipSurface->Release();
		} while (size.Width != 1 || size.Height != 1);
	}
	else if (HasMipMaps)
	{
		// create mip maps.
#ifndef _IRR_USE_D3DXFilterTexture_
		// The D3DXFilterTexture function seems to get linked wrong when
		// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
		// So mipmapgeneration is replaced with my own bad generation in d3d 8 when
		// compiling with both D3D 8 and 9.
		HRESULT hr  = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT , D3DX_DEFAULT );
		if (FAILED(hr))
#endif
		createMipMaps();
	}
}
开发者ID:Lumirion,项目名称:pseuwow,代码行数:56,代码来源:CD3D8Texture.cpp


示例13: createMipMaps

// The D3DXFilterTexture function seems to get linked wrong when
// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
// So mipmapgeneration is replaced with my own bad generation in d3d 8 when
// compiling with both D3D 8 and 9.
bool CD3D8Texture::createMipMaps(u32 level)
{
	if (level==0)
		return true;

	IDirect3DSurface8* upperSurface = 0;
	IDirect3DSurface8* lowerSurface = 0;

	// get upper level
	HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface);
	if (FAILED(hr) || !upperSurface)
	{
		os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING);
		return false;
	}

	// get lower level
	hr = Texture->GetSurfaceLevel(level, &lowerSurface);
	if (FAILED(hr) || !lowerSurface)
	{
		os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING);
		upperSurface->Release();
		return false;
	}

	D3DSURFACE_DESC upperDesc, lowerDesc;
	upperSurface->GetDesc(&upperDesc);
	lowerSurface->GetDesc(&lowerDesc);

	D3DLOCKED_RECT upperlr;
	D3DLOCKED_RECT lowerlr;

	// lock upper surface
	if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0)))
	{
		os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING);
		upperSurface->Release();
		lowerSurface->Release();
		return false;
	}

	// lock lower surface
	if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0)))
	{
		os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING);
		upperSurface->UnlockRect();
		upperSurface->Release();
		lowerSurface->Release();
		return false;
	}

	if (upperDesc.Format != lowerDesc.Format)
	{
		os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING);
	}
	else
	{
		if (upperDesc.Format == D3DFMT_A1R5G5B5)
			copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits,
							lowerDesc.Width, lowerDesc.Height,
							upperlr.Pitch, lowerlr.Pitch);
		else
		if (upperDesc.Format == D3DFMT_A8R8G8B8)
			copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits,
							lowerDesc.Width, lowerDesc.Height,
							upperlr.Pitch, lowerlr.Pitch);
		else
			os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING);
	}

	bool result=true;
	// unlock
	if (FAILED(upperSurface->UnlockRect()))
		result=false;
	if (FAILED(lowerSurface->UnlockRect()))
		result=false;

	// release
	upperSurface->Release();
	lowerSurface->Release();

	if (!result || upperDesc.Width < 3 || upperDesc.Height < 3)
		return result; // stop generating levels

	// generate next level
	return createMipMaps(level+1);
}
开发者ID:Lumirion,项目名称:pseuwow,代码行数:91,代码来源:CD3D8Texture.cpp


示例14: loadBitmap

IDirect3DSurface8* loadBitmap(LPCSTR filename, D3DFORMAT format) {
	//Comme d'habitude on va utiliser GDI, donc on commence par créer un DC

	HDC hdc = CreateCompatibleDC ( NULL ) ;

	//ensuite on peut charger l'image 
	HBITMAP hbmNew = ( HBITMAP ) LoadImage ( NULL , filename, IMAGE_BITMAP , 0 , 0 , LR_LOADFROMFILE ) ;

	//on récupère les dimensions de l'image
	BITMAP bmp ;
	GetObject ( hbmNew , sizeof ( BITMAP ) , &bmp );

	//et on sélectionne l'image dans notre dc
	HBITMAP hbmOld = ( HBITMAP ) SelectObject ( hdc , hbmNew ) ;

	//nous pouvons maintenant créer l'image surface pour D3D en spécifiante la taille de l'image
	IDirect3DSurface8* pSurface ;
	if (FAILED(_dd3dInter->CreateImageSurface ( bmp.bmWidth , bmp.bmHeight , format , &pSurface )))
		MessageBox(NULL, "erreur", "erreur", MB_OK);
	
	//on récupère les formats pour chaque couleur
	DWORD dwRShiftL = 8 - GetFormatRBits ( format ) ;
	DWORD dwGShiftL = 8 - GetFormatGBits ( format ) ;
	DWORD dwBShiftL = 8 - GetFormatBBits ( format ) ;
	DWORD dwRShiftR = GetFormatGBits ( format ) + GetFormatBBits ( format ) ;
	DWORD dwGShiftR = GetFormatBBits ( format ) ;

	//nous pouvons maintenant calculer les bits par pixel
	DWORD dwBytesPerPixel = ( GetFormatXBits ( format ) + GetFormatABits ( format ) + GetFormatRBits ( format ) + GetFormatGBits ( format ) + GetFormatBBits ( format ) ) / 8 ;

	//quelques variables...
	COLORREF crColor ;
	DWORD dwColor ;
	DWORD dwRed ;
	DWORD dwGreen ;
	DWORD dwBlue ;
	DWORD dwPosition;

	//nous avons tout ce qu'il faut maintenant pour remplir notre surface
	D3DLOCKED_RECT lockrect ;
	pSurface->LockRect ( &lockrect , NULL , 0 ) ;
	BYTE* pbyBuffer = ( BYTE* ) lockrect.pBits ;

	//on scanne l'image... 
	for ( int y = 0 ; y < bmp.bmHeight ; y ++ )
	{
		for ( int x = 0 ; x < bmp.bmWidth ; x ++ )
		{
			//récupération du pixel
			crColor = GetPixel ( hdc , x , y ) ;

			//calcule de sa position
			dwPosition = y * lockrect.Pitch + x * dwBytesPerPixel ;

			//récupération des couleurs
			
			dwRed = GetRValue ( crColor ) ;
			dwGreen = GetGValue ( crColor ) ;
			dwBlue = GetBValue ( crColor ) ;
			//convertions..
			
			dwRed >>= dwRShiftL ;
			dwGreen >>= dwGShiftL ;
			dwBlue >>= dwBShiftL ;

			
			dwRed <<=dwRShiftR ;
			dwGreen <<=dwGShiftR ;

			dwColor = dwRed | dwGreen | dwBlue ;
			

			//nous pouvons enfin copier le pixel
			memcpy ( &pbyBuffer [ dwPosition ] , &dwColor , dwBytesPerPixel ) ;
		}
	}
	

	//unlock la surface
	pSurface->UnlockRect ( ) ;

	//restoration du DC
	SelectObject ( hdc , hbmOld ) ;

	//destruction de la bitmap
	DeleteObject ( hbmNew ) ;

	//destruction du dc
	DeleteDC ( hdc ) ;

	//retour du pointeur sur la surface créée
	return ( pSurface ) ;
}
开发者ID:BodySplash,项目名称:bomberman,代码行数:93,代码来源:d3dtools.cpp


示例15: DXLOG

HRESULT	myIDirect3DDevice8::copyDataToMemory(IDirect3DDevice8* device)
{
	performanceDebugClock=clock();
	//===============Memory Check=======================
	HRESULT hRes = S_FALSE;
	if(badMemory)
	{
		DXLOG("Sorry !Memory!");
	
		return S_FALSE;
	}
	if(lpvMem==NULL)//Memory INIT;
	{
		badMemory=!setupSharedMemory();
		if(badMemory)
		{
			DXLOG("Sorry !Memory!");
			return S_FALSE;
		}
	}
	if(!isMemoryWritable())
	{
		DXLOG("Memory not writable");
		return S_FALSE;
	}
	//================FPS CHECK========================
	if(lastRecordTime==0)
	{
		lastRecordTime=clock();
	}
	else
	{
		long inteval=clock()-lastRecordTime;
		if(inteval<1000/MAXFPS)
		{
			//DXLOG("FPS QUICK");
			return S_FALSE;
		}
		else
		{
			//DXLOG("FPS OK");
			lastRecordTime=clock();
		}
	}
	//=================================================
	IDirect3DSurface8 *pBackBuffer;
	
	if (FAILED(device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) 
	{
		DXLOG("PBACKBUFEER");
		return hRes;
	}
	D3DSURFACE_DESC surfaceDesc;
	pBackBuffer->GetDesc(&surfaceDesc);
	dumpSurfaceSettings(surfaceDesc);
	if(pSurfLocal==NULL)
	{
		DXLOG("SURFLOCAL CREATING");
		
		hRes = device->CreateImageSurface(surfaceDesc.Width,// RWIDTH,
												surfaceDesc.Height,//RHEIGHT,
												surfaceDesc.Format,
												&pSurfLocal);
		if (FAILED(hRes))
		{
			DXLOG("SURFLOCAL CREATING FAILED");
			SafeRelease(pBackBuffer);
			return hRes;
		}
		
	}
	
	hRes=device->CopyRects(pBackBuffer,NULL,0,pSurfLocal,NULL);
	if (FAILED(hRes))
	{
		DXLOG("COPY RECT FAILED");
		SafeRelease(pBackBuffer);
		return hRes;
	}
	//device->GetRenderTargetData(pBackBuffer, pSurfLocal);
	
	D3DLOCKED_RECT lockedRect;
	if(FAILED(pSurfLocal->LockRect(&lockedRect, NULL, D3DLOCK_READONLY)))
	{
			DXLOG("Lock FAILED");
			SafeRelease(pBackBuffer);
			return hRes;
	}
	
	//================BPP ADJUSTMENT=====================
	UINT bpp=4;
	int bppformat=-1;
	switch(surfaceDesc.Format)
	{

		case D3DFMT_R5G6B5:
			bpp = 2;
			bppformat=2;
			break;
		case D3DFMT_X1R5G5B5:
//.........这里部分代码省略.........
开发者ID:polyu,项目名称:Cloud_Game,代码行数:101,代码来源:myIDirect3DDevice8.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IDirectFBDisplayLayer类代码示例发布时间:2022-05-31
下一篇:
C++ IDirect3DStateBlock9类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap