Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

RenderTargetView* error

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

Hi Guys,

I am trying to retrieve a RenderTargetView* from a class I have created, like this

ID3D11RenderTargetView* RenderTargetSelect()
{
	return renderTextureView;
}

When I try to use the pointer (as follows) I get the following error.

d3dContext->OMSetRenderTargets(1, it->RenderTargetSelect(), 0);

"ID3D11RenderTargetView *" is incompatible with parameter of type "ID3D11RenderTargetView *const *"


I tried casting it to ID3D11RenderTargetView *const * but the program just crashes. Error handling confirms that the pointer to the render target view is valid.

Not sure why this isn't compiling, so a helping hand would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement

Self solved biggrin.png

 

Apparently I needed to do this;

 

ID3D11RenderTargetView** RenderTargetSelect()
{
            return &renderTextureView;
}

Share this post


Link to post
Share on other sites
The reason that OMSetRenderTargets takes a pointer to a pointer (instead of just a pointer), is because it expects an array of pointers to render target views. This is so that you can set multiple render targets simultaneously with 1 API call. It's the same for all of the functions that set shader resource views, samplers, constant buffers, and unordered access views. I usually prefer to make an array on the stack to pass into those functions, like this:

ID3D11RenderTargetView* rtViews[] = { it->RenderTargetSelect() };
d3dContext->OMSetRenderTargets(1, rtViews, nullptr);

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!