Got problem with CreateTexture

Started by
4 comments, last by aprilspirit89 11 years, 11 months ago
The return value is FFFFFFFF 8876086C.I tried to change parameters but it didn't work.But I Succeed in CreateOffscreenPlainSurface.Can somebody tell me the reason?
Advertisement
Most probably some parameters are wrong ? Maybe trying to create a texture in a not supported format ?

It could help when you post some more code....

Most probably some parameters are wrong ? Maybe trying to create a texture in a not supported format ?

It could help when you post some more code....

Thank you for your reply.It's just a simple render-to-texture function.I used D3DFMT_A8B8G8R8,D3DFMT_A16B16G16R16,D3DFMT_R8G8B8,etc.//And actually these code worked well yesterday...

LPDIRECT3DTEXTURE9 pRenderTexture=NULL;
LPDIRECT3DSURFACE9 pRenderSurface=NULL,pBackBuffer=NULL;

HRESULT hr=g_pd3dDevice->CreateTexture(Width,Height,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8B8G8R8,D3DPOOL_SCRATCH,&pRenderTexture,NULL);
pRenderTexture->GetSurfaceLevel(0,&pRenderSurface);

g_pd3dDevice->GetRenderTarget(0,&pBackBuffer);
g_pd3dDevice->SetRenderTarget(0,pRenderSurface);
g_pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DXCOLOR(0,0,0,1),1.0f,0);

Render(0,NULL);

g_pd3dDevice->SetRenderTarget(0,pBackBuffer);
D3DXSaveTextureToFile(pTexFileName,destFormat,pRenderTexture,NULL);

pBackBuffer->Release();

SAFE_RELEASE(pRenderSurface);
SAFE_RELEASE(pRenderTexture);
return S_OK;
[/quote]
Now it's OK with D3DFMT_R5G6B5,but still fail D3DFMT_A1R5G5B5.I need alpha...
You can't create a render target in D3DPOOL_SCRATCH. From the documentation (for the D3DUSAGE enum):

The resource will be a render target. D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT.[/quote]

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


You can't create a render target in D3DPOOL_SCRATCH. From the documentation (for the D3DUSAGE enum):

The resource will be a render target. D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT.

[/quote]
Right.Thank you ! I've fixed that.

This topic is closed to new replies.

Advertisement