Jump to content
  • Advertisement
Sign in to follow this  
Skalli

Resize of Backbuffer creates a new Thread? oO

This topic is 3609 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

Well, I'm pretty sorry if this is a stupid problem. I'm very tired so please excuse me. My problem is I wanted to catch a resize event of the window in order to get the new window size for the back buffer. That and the following backbuffer resize works fine. But when I checked the resources my programm needs in the taskmanager I was surprised: Everytime I resize the window it creates a new thread. Therefore consuming more memory (about 2 MB after every resize).
delete obj1;
		//Get new backbuffer size and set the important settings
		m_oPresentParams.BackBufferHeight = rect.bottom-rect.top;
		m_oPresentParams.BackBufferWidth = rect.right-rect.left;
		m_oPresentParams.Windowed = true;
		m_oPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
		m_oPresentParams.EnableAutoDepthStencil = TRUE;
		m_oPresentParams.AutoDepthStencilFormat = D3DFMT_D16;
		//Reset the device
		m_oDevice->Reset(&m_oPresentParams);
		m_oD3D->Release();
		//Create the device with new backbuffer settings
		m_oD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_oParent,
			D3DCREATE_SOFTWARE_VERTEXPROCESSING,
			&m_oPresentParams, &m_oDevice);
		//Initilialize device
		m_oDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
		//Disable culling
		m_oDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
		
		//Recreate test object
		obj1 = new RenderObject(m_oDevice);
Has anyone an idea what I'm doing wrong? Greetings, Skalli

Share this post


Link to post
Share on other sites
Advertisement

m_oDevice->Reset(&m_oPresentParams);
m_oD3D->Release();
//Create the device with new backbuffer settings
m_oD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_oParent,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&m_oPresentParams, &m_oDevice);

Several problems here:

- You shouldn't release the D3D object until you exit your app.
- You create a new device when you already have one!
- You don't check any return codes to detect any failures of your DirectX calls.

Share this post


Link to post
Share on other sites
Well, you were to right. After I did some other things (playing games to get my head free) I looked at the code and thought "cr**"...
Setting the device free and reinitializing was completely unneccessary...
Well thanks anyway. Now it works after I cut out the unneccessary code.
Oh well, and usually I check the return codes for errors ;) I also usually embedded the code in try/catch blocks when neccessary ;)

Greetings,
Skalli

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!