Sign in to follow this  

Got problem with CreateTexture

This topic is 2048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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....

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1336465414' post='4938320']
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....
[/quote]
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...
[quote]
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] Edited by Tunisia hawker

Share this post


Link to post
Share on other sites
You can't create a render target in D3DPOOL_SCRATCH. From the documentation (for the D3DUSAGE enum):

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

Share this post


Link to post
Share on other sites
[quote name='mhagain' timestamp='1336468038' post='4938326']
You can't create a render target in D3DPOOL_SCRATCH. From the documentation (for the D3DUSAGE enum):

[quote]The resource will be a render target. D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT.[/quote]
[/quote]
Right.Thank you ! I've fixed that.

Share this post


Link to post
Share on other sites

This topic is 2048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this