Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Call to invalid method: sfShader_Create  (Read 3526 times)

0 Members and 1 Guest are viewing this topic.

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Call to invalid method: sfShader_Create
« on: November 07, 2010, 09:59:51 pm »
The default Shader() constructor calls sfShader_Create, which doesn't seem to exist in csfml.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Call to invalid method: sfShader_Create
« Reply #1 on: November 11, 2010, 10:52:47 am »
It's fixed, thank you.
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Call to invalid method: sfShader_Create
« Reply #2 on: November 13, 2010, 07:17:24 pm »
Thanks. :)

At the risk of sounding like a butt, the following should also be removed now:

Code: [Select]
static extern IntPtr sfShader_Create();

Code: [Select]
static extern IntPtr sfImage_Create();

And I'm not sure about this one, but:

Code: [Select]
void LoadFromString(string shader)

That method is never used. Was it supposed to be public?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Call to invalid method: sfShader_Create
« Reply #3 on: November 13, 2010, 07:28:10 pm »
You'll never sound like a butt for fixing things ;)

Quote
Code: [Select]
static extern IntPtr sfShader_Create();
static extern IntPtr sfImage_Create();

I removed them.

Quote
Code: [Select]
void LoadFromString(string shader)

It's now public.

Thank you :)
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Call to invalid method: sfShader_Create
« Reply #4 on: November 13, 2010, 07:46:36 pm »
Now that we have this public LoadFromString, and you removed the default constructor, how should we go about using it without loading a shader from somewhere else first? :wink:

From what it looks like, the LoadFromString was never added since there was already a public constructor using a string (for loading from file). Maybe LoadFromString can be introduced as a public static method:

Code: [Select]
public static Shader FromString(string shader)
{
    return new Shader(sfShader_CreateFromMemory(shader));
}

Shader(IntPtr shader) : base(shader)
{
    if (This == IntPtr.Zero)
        throw new LoadingFailedException("shader");
}


Its a pretty common approach in .NET for when you have multiple constructors with very similar (or identical) parameters, but the way the parameters are used are very different.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Call to invalid method: sfShader_Create
« Reply #5 on: November 13, 2010, 08:29:49 pm »
Quote
Now that we have this public LoadFromString, and you removed the default constructor, how should we go about using it without loading a shader from somewhere else first?

Ha ha :twisted:

Quote
Its a pretty common approach in .NET for when you have multiple constructors with very similar (or identical) parameters, but the way the parameters are used are very different.

That's also what the PySFML guys chose to do. Do you think that I should do it for every constructor of every class? Or maybe only resource classes (Image, Font, SoundBuffer, Shader)?
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Call to invalid method: sfShader_Create
« Reply #6 on: November 13, 2010, 08:47:03 pm »
Quote from: "Laurent"
Do you think that I should do it for every constructor of every class? Or maybe only resource classes (Image, Font, SoundBuffer, Shader)?


Right now, every resource class has a constructor that takes a string that loads from file (at least from what I remember). So it should be fine leaving the rest as they are since the Shader is just a special scenario that just happens to be able to load from a raw string.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Call to invalid method: sfShader_Create
« Reply #7 on: November 13, 2010, 09:07:36 pm »
It's not a special scenario: images can be loaded from an array of pixels, sound buffers can be loaded from an array of samples, etc. It can also be seen as the equivalent of a "load from memory" that other classes have. So if possible I'd like to keep a consistent API between all these classes.
Laurent Gomila - SFML developer

 

anything