本文整理汇总了C++中LPDIRECT3DDEVICE9::CreateOffscreenPlainSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::CreateOffscreenPlainSurface方法的具体用法?C++ LPDIRECT3DDEVICE9::CreateOffscreenPlainSurface怎么用?C++ LPDIRECT3DDEVICE9::CreateOffscreenPlainSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::CreateOffscreenPlainSurface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
RageSurface* RageDisplay_D3D::CreateScreenshot()
{
#if defined(XBOX)
return NULL;
#else
RageSurface * result = NULL;
// Get the back buffer.
IDirect3DSurface9* pSurface;
if( SUCCEEDED( g_pd3dDevice->GetBackBuffer( 0, 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.
IDirect3DSurface9* pCopy;
if( SUCCEEDED( g_pd3dDevice->CreateOffscreenPlainSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCopy, NULL ) ) )
{
if( SUCCEEDED( D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_FILTER_NONE, 0) ) )
{
// 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 != NULL );
// We need to make a copy, since lr.pBits will go away when we call UnlockRect().
result =
CreateSurface( surface->w, surface->h,
surface->format->BitsPerPixel,
surface->format->Rmask, surface->format->Gmask,
surface->format->Bmask, surface->format->Amask );
RageSurfaceUtils::CopySurface( surface, result );
delete surface;
pCopy->UnlockRect();
}
pCopy->Release();
}
pSurface->Release();
}
return result;
#endif
}
示例2: LoadSurface
LPDIRECT3DSURFACE9 LoadSurface(char *filename, D3DCOLOR transcolor)
{
LPDIRECT3DSURFACE9 image = NULL;
D3DXIMAGE_INFO info;
HRESULT result;
result = D3DXGetImageInfoFromFile(filename, &info);
result = d3ddev->CreateOffscreenPlainSurface(
info.Width,
info.Height,
D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT,
&image,
NULL);
result = D3DXLoadSurfaceFromFile(
image,
NULL,
NULL,
filename,
NULL,
D3DX_DEFAULT,
transcolor,
NULL);
return image;
}
示例3: LoadSurface
/*This Function creates a surface object from a bitmap file. Find the dimensions of the bitmap,
create the plain surface, then load the bitmap into the new surface object*/
LPDIRECT3DSURFACE9 LoadSurface(string filename) {
LPDIRECT3DSURFACE9 image = NULL;
//Get width and Height of bitmap
D3DXIMAGE_INFO info;
HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
if (result != D3D_OK) return NULL;
//creates a new surface object
result = d3ddev->CreateOffscreenPlainSurface(
info.Width,
info.Height,
D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT,
&image,
NULL);
if (result != D3D_OK) return NULL;
//load the surface from the file into the newley created surface object
result = D3DXLoadSurfaceFromFile(
image,
NULL,
NULL,
filename.c_str(),
NULL,
D3DX_DEFAULT,
D3DCOLOR_XRGB(0, 0, 0),
NULL);
if (result != D3D_OK) return NULL;
return image;
}
示例4: D3DUtil_SetDeviceCursor
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetDeviceCursor
// Desc: Gives the D3D device a cursor with image and hotspot from hCursor.
//-----------------------------------------------------------------------------
HRESULT D3DUtil_SetDeviceCursor( LPDIRECT3DDEVICE9 pd3dDevice, HCURSOR hCursor,
BOOL bAddWatermark )
{
HRESULT hr = E_FAIL;
ICONINFO iconinfo;
BOOL bBWCursor;
LPDIRECT3DSURFACE9 pCursorSurface = NULL;
HDC hdcColor = NULL;
HDC hdcMask = NULL;
HDC hdcScreen = NULL;
BITMAP bm;
DWORD dwWidth;
DWORD dwHeightSrc;
DWORD dwHeightDest;
COLORREF crColor;
COLORREF crMask;
UINT x;
UINT y;
BITMAPINFO bmi;
COLORREF* pcrArrayColor = NULL;
COLORREF* pcrArrayMask = NULL;
DWORD* pBitmap;
HGDIOBJ hgdiobjOld;
ZeroMemory( &iconinfo, sizeof(iconinfo) );
if( !GetIconInfo( hCursor, &iconinfo ) )
goto End;
if (0 == GetObject((HGDIOBJ)iconinfo.hbmMask, sizeof(BITMAP), (LPVOID)&bm))
goto End;
dwWidth = bm.bmWidth;
dwHeightSrc = bm.bmHeight;
if( iconinfo.hbmColor == NULL )
{
bBWCursor = TRUE;
dwHeightDest = dwHeightSrc / 2;
}
else
{
bBWCursor = FALSE;
dwHeightDest = dwHeightSrc;
}
// Create a surface for the fullscreen cursor
if( FAILED( hr = pd3dDevice->CreateOffscreenPlainSurface( dwWidth, dwHeightDest,
D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCursorSurface, 0 ) ) )
{
goto End;
}
pcrArrayMask = new DWORD[dwWidth * dwHeightSrc];
ZeroMemory(&bmi, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biWidth = dwWidth;
bmi.bmiHeader.biHeight = dwHeightSrc;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
hdcScreen = GetDC( NULL );
hdcMask = CreateCompatibleDC( hdcScreen );
if( hdcMask == NULL )
{
hr = E_FAIL;
goto End;
}
hgdiobjOld = SelectObject(hdcMask, iconinfo.hbmMask);
GetDIBits(hdcMask, iconinfo.hbmMask, 0, dwHeightSrc,
pcrArrayMask, &bmi, DIB_RGB_COLORS);
SelectObject(hdcMask, hgdiobjOld);
if (!bBWCursor)
{
pcrArrayColor = new DWORD[dwWidth * dwHeightDest];
hdcColor = CreateCompatibleDC( hdcScreen );
if( hdcColor == NULL )
{
hr = E_FAIL;
goto End;
}
SelectObject(hdcColor, iconinfo.hbmColor);
GetDIBits(hdcColor, iconinfo.hbmColor, 0, dwHeightDest,
pcrArrayColor, &bmi, DIB_RGB_COLORS);
}
// Transfer cursor image into the surface
D3DLOCKED_RECT lr;
pCursorSurface->LockRect( &lr, NULL, 0 );
pBitmap = (DWORD*)lr.pBits;
for( y = 0; y < dwHeightDest; y++ )
{
for( x = 0; x < dwWidth; x++ )
{
if (bBWCursor)
//.........这里部分代码省略.........
示例5: InitD3D
HRESULT InitD3D( HWND hWnd )
{
HRESULT hr ;
// Create the D3D object, which is needed to create the D3DDevice.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
MessageBox(NULL, "Create D3D9 object failed!", "Error", 0) ;
return E_FAIL;
}
D3DDISPLAYMODE ddm;
hr = g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&ddm) ;
if(FAILED(hr))
{
MessageBox(NULL, "Unable to Get Adapter Display Mode", "Error", 0) ;
return E_FAIL;
}
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.BackBufferCount = 1 ;
d3dpp.BackBufferWidth = ddm.Width ;
d3dpp.BackBufferHeight = ddm.Height ;
d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
// Create device
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ;
return E_FAIL;
}
// Create Semaphore variable
g_hMutex = CreateMutex(NULL,FALSE,NULL);
g_hFullSemaphore = CreateSemaphore(NULL, g_PoolSize - 1, g_PoolSize - 1, NULL);
g_hEmptySemaphore = CreateSemaphore(NULL, 0, g_PoolSize - 1, NULL);
// Get back buffer
g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackBuffer) ;
// Create surface
for (int i = 0; i < g_PoolSize; ++i)
{
g_SurfPool[i] = NULL ;
if (FAILED(hr = g_pd3dDevice->CreateOffscreenPlainSurface(d3dpp.BackBufferWidth,
d3dpp.BackBufferHeight, d3dpp.BackBufferFormat, D3DPOOL_SYSTEMMEM, &g_SurfPool[i], NULL)))
{
return hr;
}
}
return S_OK;
}
示例6: InitGraphics
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void InitGraphics(int width, int height )
{
InitWindow(width, height);
D3DPRESENT_PARAMETERS d3dp;
ZeroMemory(&d3dp, sizeof(d3dp));
d3dp.BackBufferWidth = width;
d3dp.BackBufferHeight = height;
d3dp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dp.BackBufferCount = 1;
d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dp.Windowed = TRUE;
d3dp.hDeviceWindow = (HWND)GetHandle();
d3dp.EnableAutoDepthStencil = TRUE;
d3dp.AutoDepthStencilFormat = D3DFMT_D16;
#if __PerformanceCheckMode
d3dp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
#endif
g_d3d = Direct3DCreate9(D3D_SDK_VERSION);
g_d3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
(HWND) GetHandle(),
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dp,
&g_d3d_device );
{// 市松模様の背景画像を作る
g_d3d_device->CreateOffscreenPlainSurface( width, height,
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &g_d3d_clearing_image, NULL );
D3DLOCKED_RECT lockedRect;
g_d3d_clearing_image->LockRect( &lockedRect, NULL, 0 );
CreateCheckeredPattern( width, height, (uint32_t*)lockedRect.pBits );
g_d3d_clearing_image->UnlockRect();
}
g_renderer = ::EffekseerRendererDX9::Renderer::Create( g_d3d_device, 2000 );
g_renderer->SetProjectionMatrix( ::Effekseer::Matrix44().PerspectiveFovRH( 90.0f / 180.0f * 3.14f, (float)width / (float)height, 1.0f, 50.0f ) );
g_renderer->SetDistortingCallback( new DistortingCallback(
(EffekseerRendererDX9::Renderer*)g_renderer, g_d3d_device, width, height ) );
g_manager->SetSpriteRenderer( g_renderer->CreateSpriteRenderer() );
g_manager->SetRibbonRenderer( g_renderer->CreateRibbonRenderer() );
g_manager->SetRingRenderer( g_renderer->CreateRingRenderer() );
g_manager->SetModelRenderer( g_renderer->CreateModelRenderer() );
g_manager->SetTrackRenderer( g_renderer->CreateTrackRenderer() );
g_manager->SetCoordinateSystem( ::Effekseer::CoordinateSystem::RH );
g_manager->SetTextureLoader( g_renderer->CreateTextureLoader() );
g_manager->SetModelLoader( g_renderer->CreateModelLoader() );
}
示例7: loadSurface
bool Surface::loadSurface(LPDIRECT3DDEVICE9 device, std::string filename)
{
imageScale = 100; //set our image scale to 100%
//record the height and width
HRESULT hResult;
// Get the width and height of the image
D3DXIMAGE_INFO imageInfo;
hResult = D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo);
if FAILED (hResult){
return false;
}
height = imageInfo.Height;
width = imageInfo.Width;
//create the Off Screen Surface
hResult = device->CreateOffscreenPlainSurface(width, //surface width
height, //surface height
D3DFMT_A8R8G8B8, //surface format, D3DFMT_A8R8G8B8 is a 32 bit format with 8 alpha bits
D3DPOOL_DEFAULT, //create it in the default memory pool
&surface, //the pointer to our surface
NULL
);
if (FAILED(hResult))
return false;
//load the surface from the a file
hResult = D3DXLoadSurfaceFromFile(surface, //the surface we just created
NULL, //palette entry, NULL for non 256 color formats
NULL, //dest rect, NULL for the whole surface
filename.c_str(), // the file we wish to load
NULL, // Source Rect, NULL for the whole file
D3DX_DEFAULT, //Filter
0, // Color key, color that should be used as transparent.
NULL // pointer to a D3DXIMAGE_INFO structure, for holding info about the image.
);
if (FAILED(hResult))
return false;
//set rects
destRect.left = 0;
destRect.top = 0;
destRect.bottom = destRect.top + height;
destRect.right = destRect.left + width;
srcRect.left = 0;
srcRect.top = 0;
srcRect.bottom = destRect.top + height;
srcRect.right = destRect.left + width;
return true;
}
示例8:
HRESULT HookIDirect3DDevice9::CreateOffscreenPlainSurface(LPVOID _this,
UINT Width,
UINT Height,
D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DSurface9** ppSurface,
HANDLE* pSharedHandle)
{
LOG_API();
return pD3Dev->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle);
}
示例9: LoadSurface
LPDIRECT3DSURFACE9 LoadSurface(char* fileName, D3DCOLOR transColor) {
LPDIRECT3DSURFACE9 image = NULL;
D3DXIMAGE_INFO info;
HRESULT hr;
hr = D3DXGetImageInfoFromFile(fileName, &info);
if (hr != D3D_OK)
return NULL;
hr = d3dDev->CreateOffscreenPlainSurface(info.Width, info.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &image, NULL);
if (hr != D3D_OK)
return NULL;
hr = D3DXLoadSurfaceFromFile(image, NULL, NULL, fileName, NULL, D3DX_DEFAULT, transColor, NULL);
if (hr != D3D_OK)
return NULL;
return image;
}
示例10: LoadSurface
LPDIRECT3DSURFACE9 LoadSurface(string filename)
{
LPDIRECT3DSURFACE9 image = NULL;
//get width and height from bitmap file
D3DXIMAGE_INFO info;
HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
if (result != D3D_OK)
{
return NULL;
}
//create surface
result = d3ddev->CreateOffscreenPlainSurface(
info.Width,
info.Height,
D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT,
&image,
NULL);
if (result != D3D_OK) return NULL;
//load surface from file into newly created surface
result = D3DXLoadSurfaceFromFile(
image,
NULL,
NULL,
filename.c_str(),
NULL,
D3DX_DEFAULT,
D3DCOLOR_XRGB(0,0,0),
NULL);
//make sure file was loaded okay
if (result != D3D_OK)
{
return NULL;
}
return image;
}
示例11: load
bool Background::load(LPDIRECT3DDEVICE9 Device, std::wstring filename)
{
imageScale = 100;
HRESULT hr;
D3DXIMAGE_INFO imageInfo;
hr = D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo);
if(FAILED(hr))
{
return false;
}
height = imageInfo.Height;
width = imageInfo.Width;
hr = Device->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &background, NULL);
if(FAILED(hr))
{
return false;
}
//load from file
hr = D3DXLoadSurfaceFromFile(background, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL);
if(FAILED(hr))
{
return false;
}
//Set Rects
scrRect.left = 0;
scrRect.top = 0;
scrRect.bottom = 0;
scrRect.top = 0;
destRect.left = 0;
destRect.top = 0;
destRect.bottom = 0;
destRect.right = 0;
return true;
}
示例12: screengrab
String screengrab(String filename)
{
if(filename=="" || filename == " () ")
{
filename.sprintf("%s_%5.5d_.png",(const char*)screengrabprefix,screengrabcount);
screengrabcount++;
}
if(!IsOneOf('.',filename))
filename << ".png";
HRESULT hr;
// get display dimensions
// this will be the dimensions of the front buffer
D3DDISPLAYMODE mode;
if (FAILED(hr=g_pd3dDevice->GetDisplayMode(0,&mode)))
{
return "fail getdisplaymode";
}
// create the image surface to store the front buffer image
// note that call to GetFrontBuffer will always convert format to A8R8G8B8
static LPDIRECT3DSURFACE9 surf=NULL;
if (!surf && FAILED(hr=g_pd3dDevice->CreateOffscreenPlainSurface(mode.Width,mode.Height,
D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&surf,NULL)))
{
return "fail createimagesurface";
}
// Next, this surface is passed to the GetFrontBuffer() method of the device, which will copy the entire screen into our image buffer:
// read the front buffer into the image surface
if (FAILED(hr=g_pd3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&surf)))
{
surf->Release();
return "fail getfrontbuffer";
}
//Finally, we call D3DXSaveSurfaceToFile() to create the BMP file, and release the temporary image surface:
// write the entire surface to the requested file
hr=D3DXSaveSurfaceToFile(filename,D3DXIFF_PNG,surf,NULL,NULL);
// release the image surface
// surf->Release();
// return status of save operation to caller
return (hr==D3D_OK)? filename + " exported!" : "something failed";
}
示例13: CreateSurfaceFromFile
LPDIRECT3DSURFACE9 CreateSurfaceFromFile(LPDIRECT3DDEVICE9 d3ddv, LPWSTR FilePath)
{
D3DXIMAGE_INFO info;
HRESULT result = D3DXGetImageInfoFromFile(FilePath,&info);
if (result!=D3D_OK)
{
trace(L"[ERROR] Failed to get image info '%s'",FilePath);
return NULL;
}
LPDIRECT3DSURFACE9 surface;
d3ddv->CreateOffscreenPlainSurface(
info.Width, // width
info.Height, // height
D3DFMT_X8R8G8B8, // format
D3DPOOL_DEFAULT,
&surface,
NULL);
result = D3DXLoadSurfaceFromFile(
surface, // surface
NULL, // destination palette
NULL, // destination rectangle
FilePath,
NULL, // source rectangle
D3DX_DEFAULT, // filter image
D3DCOLOR_XRGB(0,0,0), // transparency (0 = none)
NULL); // reserved
if (result!=D3D_OK)
{
trace(L"[ERROR] D3DXLoadSurfaceFromFile() failed");
return NULL;
}
return surface;
}
示例14: LoadSurface
LPDIRECT3DSURFACE9 LoadSurface(string filename)
{
LPDIRECT3DSURFACE9 image = NULL;
//get width and height from bitmap file
D3DXIMAGE_INFO info;
HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
if (result != D3D_OK)
return NULL;
//create surface
result = d3ddev->CreateOffscreenPlainSurface(
info.Width, //width of the surface
info.Height, //height of the surface
D3DFMT_X8R8G8B8, //surface format
D3DPOOL_DEFAULT, //memory pool to use
&image, //pointer to the surface
NULL); //reserved (always NULL)
if (result != D3D_OK) return NULL;
//load surface from file into newly created surface
result = D3DXLoadSurfaceFromFile(
image, //destination surface
NULL, //destination palette
NULL, //destination rectangle
filename.c_str(), //source filename
NULL, //source rectangle
D3DX_DEFAULT, //controls how image is filtered
D3DCOLOR_XRGB(0,0,0), //for transparency (0 for none)
NULL); //source image info (usually NULL)
//make sure file was loaded okay
if (result != D3D_OK) return NULL;
return image;
}
示例15: Game_Init
/*
* Game initialization function
*/
bool Game_Init(HWND window)
{
//initialize Direct3D
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!d3d)
{
MessageBox(window, "Error initializing Direct3D", "Error", MB_OK);
return false;
}
//set Direct3D presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREENW;
d3dpp.BackBufferHeight = SCREENH;
d3dpp.hDeviceWindow = window;
//create Direct3D device
d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
if (!d3ddev)
{
MessageBox(window, "Error creating Direct3D device", "Error", MB_OK);
return 0;
}
//clear the backbuffer to black
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
//create surface
HRESULT result = d3ddev->CreateOffscreenPlainSurface(
SCREENW, //width of the surface
SCREENH, //height of the surface
D3DFMT_X8R8G8B8, //surface format
D3DPOOL_DEFAULT, //memory pool to use
&surface, //pointer to the surface
NULL); //reserved (always NULL)
if (!SUCCEEDED(result)) return false;
//load surface from file into newly created surface
result = D3DXLoadSurfaceFromFile(
surface, //destination surface
NULL, //destination palette
NULL, //destination rectangle
"legotron.bmp", //source filename
NULL, //source rectangle
D3DX_DEFAULT, //controls how image is filtered
0, //for transparency
NULL); //source image info
//make sure file was loaded okay
if (!SUCCEEDED(result)) return false;
return true;
}