Namespaces

  • crosire
  • Topic Author
More
11 years 8 months ago #1 by crosire Namespaces was created by crosire
The next update adds a new useful feature to ReShade's shader language: namespaces. Developers knowing C++, C# and similar languages are familar with the concept already. It basically allows you to encapsulate variables/functions with the same name in different naming spaces and then access them.

Example:
Code:
// global namespace float4 Func() { return float4(1, 0, 0, 1); /* red */ } namespace NS1 { // NS1 namespace float4 Func() { return float4(0, 1, 0, 1); /* green */ } namespace NS2 { // NS2 namespace float4 Func() { return float4(0, 0, 1, 1); /* blue */ } } float4 FuncCaller() { float4 color; color = Func(); // color is green, since best match is Func in the current NS1 namespace color = NS2::Func(); // color is blue, since we access Func from the NS2 namespace here color = NS1::NS2::Func(); // color is blue, same as the previous, we just specify the full name here // prefixing with "::" accesses the global namespace color = ::Func(); // color is red, since this accesses Func in the global namespace color = ::NS1::Func(); // color is green, because we access Func in the NS1 namespace here return color; } }
The following user(s) said Thank You: jmp909

Please Log in or Create an account to join the conversation.