Archived

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

DirectX8 - Device Objects question

This topic is 5849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm new to the DirectX world and am using a horrible book entitled Beginning Direct3D Game Programming. The first few examples I've used make use of the Common Files overriding the functions: OneTimeSceneInit() InitDeviceObjects() RestoreDeviceObjects() InvalidateDeviceObjects() DeleteDeviceObjects() I have a couple questions. 1. Can you please define exactly when I would use each of the above functions. This book has mentioned placing my vertex data into RestoreDeviceObjects that way on a window resize the data will be put back into the vertex buffer. 2. After selecting a new device (HAL or REF), resizing the window, or changing resolutions within a DirectX app, is it necessary to free all device objects and then recreate them? If so why? This book makes exclusive use of the Common Files so after a window resize it insists upon placing release code for vertex buffers, textures, etc within the InvalidateDeviceObjects/DeleteDeviceObjects and recreation code within RestoreDeviceObjects. Now I've used the DirectX SDK tutorials which dont use the Common Files and so dont have any special functions to place release/recreation code. After window resizing the originally displayed polygon(s) is scaled to the appropaite size of the window. The vertices seem intact. Why the contradiction? Edited by - quantass on December 11, 2001 7:24:10 PM Edited by - quantass on December 11, 2001 7:26:01 PM

Share this post


Link to post
Share on other sites
This is how i interpret these functions:
OneTimeSceneInit() -- as stated on time initialization. This mean initing things that are not dependent on device objects. Game logic can be inited here.
InitDeviceObjects() -- Everything that goes with the device object -- vertex buffers, textures, etc.
RestoreDeviceObjects()-- I set lights, render states, textures.
InvalidateDeviceObjects() -- The only thing i invalidate is my font.
DeleteDeviceObjects() -- Deletes everything associated with device objects.

You should always redo everything when changing device objects. If it has worked correctly when resizing in the past, consider yourself lucky. For example, if a i resize windows in my game without properly initializing everything, my game characters appear to be ripped apart, as certain limbs shift with the resizing window while others dont.

Share this post


Link to post
Share on other sites
If you don''t Reset the device after window resizing, the device''s back buffer won''t be resized. So, the image will actually be stretched rather than being rendered with the new resolution.

Share this post


Link to post
Share on other sites