5.1.9 - D3D Drawing to bitmap is limited to display size?
I have just found a strange problem.
I use version 5.1.9 of Allegro and for some reason it fails (partially) to draw into a bitmap when using D3D.
Code is simple like this:
With this display option set:
After executing this, image in the "test.png" file is fine but only in 1024x768 region. The rest is plain white.
Setting display resolution to 800x600 results in corrupted test.png outside of 800x600 area.
Everything is fine with OpenGL. Without depth buffer it also works fine.
Is this a bug? Where I should look at to fix this?
Thanks in advance
Direct3D has the limitation that your depth buffer must be at least the same size as your render target. In this case your depth buffer is the size of the display and your texture is larger. I believe that's the problem. To correct this you have to create a depth buffer of your own the same size as the texture and set it as active when you render to that texture, or just leave it active all the time if you want. How to do that is explained well in the Direct3D 9 reference on MSDN.
Maybe we should add a flag to bitmaps telling whether they need a depth buffer when being set as target bitmap... and in that case Allegro could create one accordingly.
What if I do not need depth buffer at all when rendering to textures? Is there any easy way to disable it while drawing to texture?
Yes, you can back it up, set it to null (or whatever the null value is, can't remember) the reset it. Check the Direct3D reference.
Thanks, this helped. I am backing it up in the same manner as previous_target in d3d_disp.cpp
Something's unclear to me... does Allegro create the depth buffer by default? Is it different between backends? Should it?
Thread #614025. Printed from Allegro.cc
The only depth buffer it ever creates is the one for the backbuffer, and only if you specify ALLEGRO_DEPTH_SIZE. It's the same between backends.