Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

problem with screen resizing

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

im trying to resize my directx 10 window... but it isnt resized properly (resolution doesnt change).. the image becomes stretched.. what am i doin wrong??
	void ResizeScreen(int width, int height)
	{
		pRenderTargetView_->Release();

		DXGI_SWAP_CHAIN_DESC sd;
		pSwapChain_->GetDesc(&sd);

		pSwapChain_->ResizeBuffers( sd.BufferCount, width, height, sd.BufferDesc.Format, 0);

		ID3D10Texture2D *pBackBuffer;
		HRESULT hr = pSwapChain_->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
		if (FAILED(hr))
		{
		  throw std::exception("Failed to get backbuffer.");
		}

		// create the render target view
		hr = pD3DDevice_->CreateRenderTargetView(pBackBuffer, NULL, &pRenderTargetView_);

		// release the back buffer
		pBackBuffer->Release();

		// Make sure the render target view was created successfully
		if (FAILED(hr))
		{
			throw std::exception("Failed to create render target.");
		}

		// set the render target
		pD3DDevice_->OMSetRenderTargets(1, &pRenderTargetView_, NULL);

		// create and set the viewport
		D3D10_VIEWPORT viewPort;
		viewPort.Width = width;
		viewPort.Height = height;
		viewPort.MinDepth = 0.0f;
		viewPort.MaxDepth = 1.0f;
		viewPort.TopLeftX = 0;
		viewPort.TopLeftY = 0;
		pD3DDevice_->RSSetViewports(1, &viewPort);
	}




Share this post


Link to post
Share on other sites
Advertisement
What's the return value of IDXGISwapChain::ResizeBuffers()? Do the debug runtimes produce any messages?

My guess is that you forgot to release all outstanding references to the backbuffer. Also, if you can just specify 0 for the width and height in ResizeBuffers(), which will cause the backbuffer to expand to the client area of the window.

Share this post


Link to post
Share on other sites
yea i had some references...

but now i get an error here:

HRESULT hr = pSwapChain_->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);

it fails...?


EDIT: solved it hade to set size and width to 0.... why is that?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!