How can I use setNamedConstant in C#? Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

How can I use setNamedConstant in C#?

Post by r0ut »

Ogre Version: 1.12

The following code was working with Mogre:

Code: Select all

MaterialPtr ret;
ret = baseMat.clone(matName);
ret.getTechnique(0).getPass(0).getVertexProgramParameters().setNamedConstant("isBump", 0f);
However in Ogre there's no method called setNamedConstant() inside VertexProgramParameters and FragmentProgramParameters. Is there any workaround?
loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: How can I use setNamedConstant in C#?

Post by loath »

just realized you said C# :)

use the arrow operator instead of the dot:

Code: Select all

auto vparams = pass->getVertexProgramParameters ();
vparams->setNamedConstant ("worldScale", scale);
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: How can I use setNamedConstant in C#?

Post by r0ut »

Unfortunately this doesn't work in C#
loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: How can I use setNamedConstant in C#?

Post by loath »

ah makes sense. i'm sure paroj will have a fix shortly if it's broken.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: How can I use setNamedConstant in C#?

Post by paroj »

a SharedPtr instantiation like:
https://github.com/OGRECave/ogre/blob/6 ... gre.i#L502

is missing for GpuProgramParameters
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: How can I use setNamedConstant in C#?

Post by r0ut »

Will this be fixed? Or there are few workarounds I can do?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: How can I use setNamedConstant in C#?

Post by paroj »

yes, its fixed in master. However, you should familiarize yourself with SWIG and how to build Ogre locally, so you can fix these minor issues on your own (and create a PR when you do).
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: How can I use setNamedConstant in C#?

Post by r0ut »

Thank you once again, paroj!
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: How can I use setNamedConstant in C#?

Post by r0ut »

paroj wrote: Fri Mar 05, 2021 1:38 pm yes, its fixed in master. However, you should familiarize yourself with SWIG and how to build Ogre locally, so you can fix these minor issues on your own (and create a PR when you do).
I had this error when selecting I wanted to build the C# stuff

Code: Select all

CMake Warning at Components/Csharp/CMakeLists.txt:3 (message):
  Csharp Component disabled because SWIG or Csharp was not found
I've downloaded SWIG but where should I put it to make it work?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: How can I use setNamedConstant in C#?

Post by paroj »

see this on how the SDK is built by our CI:
https://github.com/OGRECave/ogre/blob/5 ... ke#L41-L68
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: How can I use setNamedConstant in C#?

Post by r0ut »

Thanks! I've installed SWIG through Chocolatey and worked like a charm!
However, the Visual Studio project doesn't have any .cs extension file BUT there's an Ogre.dll inside csharp folder. Is this DLL up to date or should I compile it again somewhere?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: How can I use setNamedConstant in C#?

Post by paroj »

that dll should be up to date. But to be sure, use the INSTALL target to create the same package as what you would download:
https://ogrecave.github.io/ogre/api/lat ... otoc_md249
Post Reply