Sign in to follow this  
sofakng

Why does IDirect3DTexture9.LockRect return D3DERR_INVALIDCALL?

Recommended Posts

I'm using a DirectX v9.0 wrapper for Delphi called Asphyre v4.1 and I'm having problems locking a render target. From what I've gathered, a render target is simply a texture that has been set to the rendering target with IDirect3DDevice9.SetRenderTarget() but I could be mistaken. Anyways, here is what I'm doing: // This call works fine and returns a Surface who has a resource type of D3DUSAGE_RENDERTARGET Devices[0].Images.Image['terrain'].Texture[0].Tex9.GetSurfaceLevel(0, Surface); // This calls fails with D3DERR_INVALIDCALL. I've tried passing different flags instead of '0' but none of them work Surface.LockRect(LockedRect, nil, 0); I can successfully lock the backbuffer and read pixels from it, so I somewhat have a clue about what I'm doing but I may not understand rendering targets competely. What am I doing wrong?

Share this post


Link to post
Share on other sites
Quote:
Original post by sofakng
What am I doing wrong?
Not using the debug runtimes, which will TELL YOU what the error is and why it happened [smile]

Share this post


Link to post
Share on other sites
Although if I had to guess, I'd say it probably has something to do with this snip from the documentation on surface's Lock:
Quote:
This method cannot retrieve data from a surface that is is contained by a texture resource created with D3DUSAGE_RENDERTARGET because such a texture must be assigned to D3DPOOL_DEFAULT memory and is therefore not lockable. In this case, use instead IDirect3DDevice9::GetRenderTargetData to copy texture data from device memory to system memory.

Share this post


Link to post
Share on other sites
Ahhh, thank you. That seems to describe my situation almost exactly.

Also, I have the debug runtimes installed (and I've used the directx control panel to enable them), but how do they provide me with more information?

The LockRect() call still returns the same error code :(

Share this post


Link to post
Share on other sites
Quote:
Original post by sofakng
Ahhh, thank you. That seems to describe my situation almost exactly.

Also, I have the debug runtimes installed (and I've used the directx control panel to enable them), but how do they provide me with more information?

The LockRect() call still returns the same error code :(
In Visual C++, they output stuff to the debug output window. I've heard that you need to use something like DbgView with C#.

LockRect() probably returns the same error because you still can't lock a D3DPOOL_DEFAULT surface [smile]

Share this post


Link to post
Share on other sites
Ahh... I'm using Delphi so I don't have a debug window per-se.

I've tried using DebugView but nothing shows up in there.

I'm pretty sure the debug runtime is active because in the DirectX control panel I enabled "Break on D3DERR" (or something like that), and when I run my application (inside the Delphi IDE), the program will break as soon as it sees a D3DERR.

It would be really nice to see the debug messages though :)

Share this post


Link to post
Share on other sites

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