Archived

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

Carradine

Resizing a D3D Window and changing Resolution

Recommended Posts

I have a D3D resizable window that runs great, I can resize it fine, but it stays at the resolution of the inital window size. So when I increase its size, it will only stretch the image inside of the window. Is there a way to change the resolution of a D3D device, so that I do not have to go though the task of releasing all the D3D devices, then re-creating them all? (for example, attempt to avoid recreating and reloading all of my textures and vertex information, and simply just change the BackBufferWidth and BackBufferHeight of the D3DPRESENT_PARAMETERS)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
No Way! You have to recreate all your nonmanaged objects. For DirectX, a Fullscreen resolution change and a window resize is the same thing.

Tip 1: Create your objects with D3DPOOL_MANAGED attribute. You won''t need to recreate them during a device reset.

Tip 2: Write a routine that does the monkey work for you...
- Release all your D3D objects
- Reset the device
- Recreate D3D objects.

Of course, you have to keep track of every object you create

Share this post


Link to post
Share on other sites
I almost understand the process needed here. I do release my objects, then reset the device. But what exactly is still left in memory for me to access?

Lets say I have an index buffer. To create it the first time I use CreateIndexBuffer(), then I use Lock() and Unlock() to insert the index data into the index buffer. That is the whole process of creating it. Now what do I do different to re-access the index buffer after I reset the device? What functions to I have to call again, or assign?

Share this post


Link to post
Share on other sites
Essentially, you gotta call Release() on your index buffer.
Then you need to recreate it, lock, fill and then unlock it again.
What I suggest you do is to make a method (if you are using classes to encapsulate your objects) that will set up your buffers and another method which will release them.

Share this post


Link to post
Share on other sites
That is currently what I am doing right now, is resetting my Device, then I am going back through and re-create all my vertex buffer, index buffer, and texture space, then re-filling them all with the data that was in there before I recreated the device (lock - fill - unlock) then running the program again.

But that is exactly what I am trying to avoid! I don''t want to go though the method of running the program completely over again, and creating everything like it was the first time, simply to resize the window.

My Index buffer for example, I kill it, then create it, and lock(), fill, unlock() it again with the same algorithm I used the first time around. If I am using D3DPOOL_MANAGED, isnt that data that I put into the index buffer still available somewhere, instead of me filling it all in again?

Share this post


Link to post
Share on other sites
(Reviving this thread since it needed reviving)

I know exactly how you feel. It''s ridiculous to have to recreate a bunch of objects--whose vertices are in object space, not client space--when all you really need to recreate is the back buffer(s). The only reason I can think of right now to justify recreating everything is to ensure that enough video memory exists to create the back buffer in the first place. That''s fine, and a great idea for any moderate-to-large project, but I''m just messing around with some cubes here for the moment, so why not give us a way to recreate the backbuffer alone? That way, we could do it, call SetViewport() with the new dimensions, and voila'', we''re done.

From my limited experience with OpenGL,that''s how they do it. *shrug*

---
blahpers

Share this post


Link to post
Share on other sites