Sign in to follow this  

D3DXCreateTexture and D3DUSAGE_RENDERTARGET error

This topic is 4504 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

Hi, I don't understand this error. I want to change the rendering's target, not to backbuffer but another texture. I read when I create an texture by D3DXCreateTexture function, I must to pass the D3DUSAGE_RENDERTARGET flag, like this: D3DXCreateTexture (Device, W,H, 0, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, TEXTURE); But it returns with "invalid call". Loading texture by D3DXCreateTextureFromFileEx is correct, it accepts the D3DUSAGE_RENDERTARGET flag. What should I do?

Share this post


Link to post
Share on other sites
Hi my Hungarian mate :)

Set MIP levels to 1 and pool to D3DPOOL_DEFAULT. A RenderTarget cannot be placed in Managed. (this is also written to the debug output if you switch on debug DX. do it if you didn't before, it's very useful)

kp

Share this post


Link to post
Share on other sites
And, another textureloading function is working:

D3DXCreateTextureFromFileEx (Device,
BLABLA.BMP),
0,
0,
0,
D3DUSAGE_RENDERTARGET,
D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT,
D3DX_FILTER_NONE,
D3DX_FILTER_NONE,
D3DCOLOR_ARGB( 255, 0, 0, 0 ),
nil,
nil,
Texture);

Share this post


Link to post
Share on other sites
hi,

now I have to ask:
what do you want to do with all this?

the only reason I can see for loadind a texture to a render target is that you want some background beforte rendering to the top of it. Am I right?
If so, then just use a screen0aligned quad, and render it with your background texture.
If not, then please clear us up, what do you want to see in the end?

kp

Share this post


Link to post
Share on other sites
Yes... but the target texture & used texture, X,Y positons, ALPHA colour can be variable. Whenever...

I must use the "D3DXCreateTexture" function not "D3DXCreateTextureFromFileEx" function, because my images are in an database in custom format, not in an external .BMP files.

Well, I loaded, showed, and "burned" textures that loaded by "D3DXCreateTextureFromFileEx" function... I can't see the reason, why works the D3DUSAGE_RENDERTARGET flag by "D3DXCreateTextureFromFileEx", and why not by "D3DXCreateTexture" function... :S

(napersze, ha az angolom miatt nem értesz, akkor priviben folytathatjuk ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by BigBeginner
Yes... but the target texture & used texture, X,Y positons, ALPHA colour can be variable. Whenever...


I dont understand what that means?

But what I think kovacsp was saying is, you should just render it to a quad(2 triangles) and then render it to the screen so thats all you see(screen aligned quad).

There is no need to push a texture to a target, set a target(like back buffer) and then render the quad to it. Generally you would keep it this way, meaning render whats on screen to a surface. You can change the values of u v coords whenever you like, or the alpha colors this way as well.

Share this post


Link to post
Share on other sites
And settled our differences: the LockRect method is used when I write into an empty texture, after "ID3DXCreateTexture". I don't want to "burn" an texture into another texture by "Lockrect", no! Before using "ID3DXSprite::Draw" method I use "SetRenderTarget" method, and after drawing, I set back the backbuffer.

But the "SetRenderTarget" doesn't working except the texture is created by D3DUSAGE_RENDERTARGET method... it's ok... but, the texture that created like this, the "LockRect" method doesn't work... then, how to load an picture into this texture?? And how do the "D3DXCreateTextureFromFileEx" do it?

Share this post


Link to post
Share on other sites
I think you can do anything with the ..Ex functions that you can do with the simple ones. You just have access to more parameters that are defaulted to some value in the simple versions, but you are still able to look them up and use (thus having the same effect).

Quote:

Hm, I forgot to mention an fact: I use ID3DXSprite interface to show textures. No vertexes, no quads...

Well, try the two-big-triangles method then ;)
There is no reason to stick to something that does not work for you.

kp

Share this post


Link to post
Share on other sites

This topic is 4504 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