Resizing window, blitting to TAGFImage

Started by
4 comments, last by AvatarXY 21 years, 1 month ago
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
Advertisement
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!
If the textures are created with D3DPOOL_MANAGED then they should be reloaded automatically. Why doesn''t PowerDraw use this?
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
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.
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.
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
Thanx

This topic is closed to new replies.

Advertisement