   DX9  - D3DUSAGE_RENDERTARGET cannot render with a texture larger than screensize?
  I have been running into a quite wierd problem:I am rendering text to a texture, which I render to, before I put it on the screen. In doing so, I create the closest texture in power-of-two, that will envelop the textarea. When I made an area 790 wide on a window of 800, it created the text-texture width at 1024 - and then it refused to draw on it.Is it really necessary to monitor what the maximum size of a given texture can be, based on the screen size to do this?A bit annoying IMO. I could imagine drawing into highly detailed textures for world objects run-time, so I was quite puzzled to run into this problem. Have anyone else run into this?   
  D3D won't care what size your window is when it creates a render target. What do you mean "it refused to draw on it"? Did any D3D functions return errors? Did the debug runtimes tell you anything?Also, textures and render targets don't always need to be power-of-2 in size, it depends on the device.   ;  You can create texture greater than the screen size. However, since you have defined the viewport size as x,y, if you try to render to a rendertarget of size nx,ny where n > 1 then you will have problem since your viewport is not set accordingly.;  Check your depthbuffer. The last time I had trouble with this, I wasn't disabling the depth buffer, so the pipeline had a rendertarget and depthbuffer of different dimensions and I'm sure the results aren't exactly defined then.Do you need a depth buffer?If no, did you disable it?If yes, did you create and bind it?   ;  The problem is not creating it, the problem is rendering.I just tested on my other computer (ATI card, where my main has NVidia), and it works flawlessly.I thought first that it may have been a driver problem and updated, but it persisted. Then I checked some of the DirectX settings, that I have been using to clear with, and here I found the problem:I have in my foolish youth (code is quite a few years old) been clearing with the z-buffer enabled on all rendertargets, no matter what format they used. The problem is, that I have never gotten a fail on it, even when rendering targets without a depthbuffer, even though the documentation says I am supposed to. I guess I have never before used rendertargets larger than the screen, so I never discovered it before now.Quite bizarre IMO, that DX does not do what it is supposed to. I know that I should myself have been aware back then, but at least DX could return an error to help me as a programmer.I used this call:LPDIRECT3DDEVICE9 m_device;m_device->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB([whatever]), 1.0f, 0)Removing the D3DCLEAR_ZBUFFER from the Flags solved the problem.   ;Quote:Original post by MercenareyQuite bizarre IMO, that DX does not do what it is supposed to. I know that I should myself have been aware back then, but at least DX could return an error to help me as a programmer.I used this call:LPDIRECT3DDEVICE9 m_device;m_device->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB([whatever]), 1.0f, 0)Removing the D3DCLEAR_ZBUFFER from the Flags solved the problem.If you don't have a Z-buffer active, then Clear() will fail with an error for you (Probably D3DERR_INVALIDCALL), and the debug runtimes will also emit an error.   ;Quote:Original post by Evil SteveQuote:Original post by MercenareyQuite bizarre IMO, that DX does not do what it is supposed to. I know that I should myself have been aware back then, but at least DX could return an error to help me as a programmer.I used this call:LPDIRECT3DDEVICE9 m_device;m_device->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB([whatever]), 1.0f, 0)Removing the D3DCLEAR_ZBUFFER from the Flags solved the problem.If you don't have a Z-buffer active, then Clear() will fail with an error for you (Probably D3DERR_INVALIDCALL), and the debug runtimes will also emit an error.Ok, that solved something conceptually for me. Thanks Steve.I thought the matter was only if the texture format had a depth buffer, but it is whether the renderstate for z-buffer has been enabled or not... I tested with SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE) before I cleared the target with D3DCLEAR_ZBUFFER, and it worked.Gah, sorry for my newbishness on this matter - and thanx for the help.Edit: It did not, however, give me a warning when the zbuffer was disabled.   