Michael Schwarz
2006-03-05 12:08:45 UTC
I try to learn DirectX with C++ at the momment and i dont know why the
function "CreateOffscreenPlainSurface" allways fails in the src below. I did
cut out the message handler and the windows creation. Please can somebody
explain me why the function fails and how i can get it to work.
#include <d3d9.h>
#include <d3dx9.h>
IDirect3D9* g_pD3D = NULL;
IDirect3DDevice9* g_pd3dDevice = NULL;
IDirect3DSurface9* g_Surface = NULL;
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferCount = 1;
g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
D3DXIMAGE_INFO Info;
D3DXGetImageInfoFromFile("image.bmp", &Info);
if(FAILED(g_pd3dDevice->CreateOffscreenPlainSurface(Info.Width,
Info.Height, Info.Format, D3DPOOL_DEFAULT, &g_Surface, NULL)))
{
MessageBox(hWnd,"Could not create Surface","",MB_OK);
return E_FAIL;
}
}
thx in advance
Michael
function "CreateOffscreenPlainSurface" allways fails in the src below. I did
cut out the message handler and the windows creation. Please can somebody
explain me why the function fails and how i can get it to work.
#include <d3d9.h>
#include <d3dx9.h>
IDirect3D9* g_pD3D = NULL;
IDirect3DDevice9* g_pd3dDevice = NULL;
IDirect3DSurface9* g_Surface = NULL;
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferCount = 1;
g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
D3DXIMAGE_INFO Info;
D3DXGetImageInfoFromFile("image.bmp", &Info);
if(FAILED(g_pd3dDevice->CreateOffscreenPlainSurface(Info.Width,
Info.Height, Info.Format, D3DPOOL_DEFAULT, &g_Surface, NULL)))
{
MessageBox(hWnd,"Could not create Surface","",MB_OK);
return E_FAIL;
}
}
thx in advance
Michael