Archived

This topic is now archived and is closed to further replies.

AvatarXY

Resizing window, blitting to TAGFImage

Recommended Posts

Hello all, Development with PowerDraw has been incredibly smooth, just running into two snags. In the first, I am using PowerDraw in windowed mode for a map editor. When the form is resized, I reset the PowerDraw''s width and height properties to the form''s ClientWidth and ClientHeight. However, this seems to require finalizing TPowerDraw, resetting its size, and reinitializing. This, in turn, requires me to reload my textures from disk, a relatively costly operation for resizing a window. Is there a way to resize the rendering window at runtime without finalizing and reinitializing, or should I just read the textures from disk into memory once, then into the TAGFImage I use to hold tiles from there? Also, is there a way to blit to a TAGFImage (from another or the same TAGFImage) ? I am storing many 32x32 tiles onto one texture for efficiency. Should I be using something other than TAGFImage that would perhaps solve one or both problems? Thanks for reading my long post ;-) TIA, Jason Morrison

Share this post


Link to post
Share on other sites
As far as I know, there is no way of resizing Direct3D screen or rendering target without re-initializing it. Depending on how you store your textures on disk, it might not speed up things much because saving textures to video memory is costly operation. There are two ways of making blits between TAGFImage - first is locking both and copying memory, second is retrieving texture surface, preparing a Canvas and then blitting between the two. You might check the method:
Texture[TexNum].GetSurfaceLevel(0, mySurface) where mySurface is IDirect3DSurface9-type. Then, you might use mySurface.GetDC to get the handle and assign it to TCanvas. After using the canvas, call mySurface.ReleaseDC method. I know this is a bit messy, but as I see now, it''s a good idea to implement in final PowerDraw 3 release!

Share this post


Link to post
Share on other sites
These textures exist as long as Direct3D Device exists. In order to finalize Direct3D Device, you need to finalize all other interfaces created by it, THAT''s why. Textures created with D3DPOOL_MANAGED ar reloaded automatically, if the device has been lost or these textures were unloaded from memory.
If you find a way of finalizing and initializing Direct3D again without finalizing Direct3D textures - please send a valid link to DirectX 9.0 SDK... so far, I couldn''t find it.

Share this post


Link to post
Share on other sites
You do not need to finalize and reinitialize the IDirect3DDevice9 interface to resize the window, just call the IDirect3DDevice9::Reset Method with a new D3DPRESENT_PARAMETERS structure.

quote:
Resets the type, size, and format of the swap chain.


Un-managed resources will have to be reinitialized, but managed resources remain in system memory even after they are flushed from video memory, so it is not necessary to reload them.

Share this post


Link to post
Share on other sites