Jump to content
  • Advertisement
Sign in to follow this  
Meai

General naming idea behind SlimDX?

This topic is 3204 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, I'm wondering what the naming concept behind SlimDX is currently. The official SlimDX website says, that the naming is basically equal to the c++ DirectX code. But I have had a vastly different experience while learning SlimDX. For example, this is a current problem I'm having: How to set variables in shaders, how to set textures. This is probably a particular headache for me, because I'm completely new to DirectX 10. I'm reading this tutorial: http://takinginitiative.wordpress.com/2008/11/29/directx-10-tutorial-3-textures/ And getting a texture into a shader is described as such:
std::vector<ID3D10ShaderResourceView*> textureSRV;
ID3D10EffectShaderResourceVariable* pTextureSR;
D3DX10CreateShaderResourceViewFromFile(...)
[/source ]
Now, in SlimDX the equivalent seems to be "ShaderResourceView.FromFile()", so the "D3DX10Create" was dropped.

And he sets it like this:

pTextureSR->SetResource( textureSRV[textureIndex] );


In SlimDX I have to do the same twice? Once for PixelShader, and once for the VertexShader it seems? (=SetShaderResource)
I'm a little confused, you see.


Share this post


Link to post
Share on other sites
Advertisement
The naming convention is the same as the C++ naming convention for most methods, except that we .NET-ify the names (so acronyms and short-circuited words are expanded, and such). We still feel there is enough similarity there that most users will not be confused by things like changing "Desc" to "Description" and moving trivial GetFoo() methods to Foo properties.

There are of course, exceptions, because we want to prefer .NET style names as much as possible.

We use regular constructors or the named constructor idiom to deal with most creation-oriented free functions, and as such drop "Create" from the name. We don't use API prefixes, because that is implicit in the namespaces, so we drop D3DX and such.

Quote:

In SlimDX I have to do the same twice? Once for PixelShader, and once for the VertexShader it seems? (=SetShaderResource)
I'm a little confused, you see.

No, you can set it once on the effect, if the rest of your code and effect is structured appropriately. You can reproduce any native call stream with SlimDX (except where there are bugs, obviously).

Share this post


Link to post
Share on other sites
I'm reading this documentation: http://msdn.microsoft.com/en-us/library/ee415734(VS.85).aspx

Is the first way of creating a shader resource view not supported by SlimDX? I cannot find a way of creating a ShaderResourceView from a Texture2D like they similarily do in the c++ doc example.

edit: yet another edit: I figured out how to set a texture resource, here is the code. Turns out I looked at the wrong documentation. Or a distantly related one. The "Effects" system is the one I used. The question above is still valid I guess.


ShaderResourceView myTexture = ShaderResourceView.FromFile(
device, "test.bmp");
EffectResourceVariable resource =
effect.GetVariableByName("tex2D").AsResource();
resource.SetResource(myTexture);


Took me surprisingly long, hope this helps someone.

[Edited by - Meai on March 4, 2010 4:24:11 AM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!