Jump to content
  • Advertisement
Sign in to follow this  
idloco

[D3D10] Setting a texture to a mesh

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

Hello, im starting to port my RTS "engine" to d3d10 ( for learning purposes ) but I can't find how to bind a texture to a shader so I can use it to texture a mesh. I'm not using FX files so I can't do it the way it is done on the tutorials from the SDK. I have already created the shader resource view for the texture but I don't know to to bind it to an object on the shader. So if anybody have an idea how to do this, it will be nice. :) Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Yeah I have tried using that, but I don't know how to bind it to a specific resource in the shader.

What I have right now its something like this


ID3D10ShaderResourceView* theSRV[] = { m_d3dTexture->GetShaderResourceView()};
g_d3dDevice->PSSetShaderResources(0, 1,theSRV);


But I don't know where to tell the shader to which resource assing that texture.
Like in a FX file I will have to create a ID3D10EffectShaderResourceVariable and the do something like this:

g_pDiffuseVariable = g_pEffect->GetVariableByName( "txDiffuse" )->AsShaderResource();
g_pDiffuseVariable->SetResource( g_pTextureRV );


How can I do something like this without using FX files? ( what I want actually is the GetVariableByName to be more specific :) )

Thanks for the help

Share this post


Link to post
Share on other sites
Now I understand your problem.

You can’t tell the shader were to look for a specific resource because the compiler assigns the different resources to different resource slots. This assignment is fixed and cannot change after compilation. It is possible to tell the compiler the slot it should use for a resource. The other way would be to use reflection to get the slots for the resources.

To do this you have to create a reflection object with D3D10ReflectShader. Then you have to use GetDesc to find the number of resources used by your shader. Finally use GetResourceBindingDesc to query the details. The BindPoint and Type will tell you the slot that was used for a resource.

Share this post


Link to post
Share on other sites
Oh great!
Thanks! I will go and try to do it that way :D

EDIT:
I did that and it works perfectly!!!! YAY!!!!!!!!!!
Thank you so much!!!

[Edited by - idloco on March 24, 2007 9:57:23 PM]

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!