Home » Community » Forums » DirectX and XNA » D3DXCreateTexture and D3DUSAGE_RENDERTARGET error
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 D3DXCreateTexture and D3DUSAGE_RENDERTARGET error
Post New Topic  Post Reply 
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?

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

D3DUSAGE_RENDERTARGET can be only used with D3DPOOL_DEFAULT, so :

D3DXCreateTexture (Device, W,H, 0, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, TEXTURE);

Sincerely,
Arto Ruotsalainen
Dawn Bringer 3D - Tips & Tricks


 User Rating: 1069   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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



------------------------------------------------------------
Neo, the Matrix should be 16-byte aligned for better performance!

 User Rating: 1137   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Surely, the texture is created by this, but when I want to load into it an picture, the LockRect failed :( Invalidcall, because the textures that created by D3DPOOL_DEFAULT flag isn't be locked.

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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);

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Do somebody have got the D3DXCreateTextureFromFileEx function's source code? :))

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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

 User Rating: 1137   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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 ;)

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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.

 User Rating: 1047   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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?

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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



 User Rating: 1137   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I didn't say it doesn't works :))

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

So are you telling me I should to use Direct3D vertexes and quads, not ID3DXsprite?

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

OK, I did everything with vertexbuffer-rectangles. I draw every texture by "Device.DrawPrimitive". So, how to set up to render to another texture, not to backbuffer?

 User Rating: 1005   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: