SFML community forums

Help => Graphics => Topic started by: OniLinkPlus on November 01, 2009, 05:56:58 am

Title: PostFX Segmentation Fault on Ubuntu 9.10
Post by: OniLinkPlus on November 01, 2009, 05:56:58 am
Ack, I am not liking Build 1250 so far.
Here's my code:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <ctime>
int main(){
 sf::PostFX Water;
 sf::RenderWindow Window(sf::VideoMode(512, 512, 32), "Test");
 if (sf::PostFX::CanUsePostFX()){
  Water.LoadFromFile("Water.sfx");
  Water.SetTexture("screen", NULL);
  Water.SetParameter("time", (double)clock());
  Window.Draw(Water);
  Window.Display();
 }
}

Water.sfx:
Code: [Select]
texture screen
float time

effect
{
vec2 offset = vec2(cos(time/500+_in.x*10)/50, sin(time/500+_in.y*10)/50);
_out = vec4(screen(_in+offset));
}

The Window.Draw(Water) function is giving me a segmentation fault. I looked over the Shader, and it has nothing that could be causing this afaik. Did you remove the wrappers? This code worked in earlier builds. :\ Just to be sure it wasn't my code, I even tested with this Shader:
Code: [Select]
texture screen
float time

effect{
    _out = vec4(screen(_in));
}

Still get a segmentation fault.
Title: PostFX Segmentation Fault on Ubuntu 9.10
Post by: Laurent on November 01, 2009, 11:10:48 am
Did you try the post-fx sample from the SDK? Do you have any error message in the console?
Title: PostFX Segmentation Fault on Ubuntu 9.10
Post by: OniLinkPlus on November 01, 2009, 05:59:18 pm
Quote from: "Laurent"
Did you try the post-fx sample from the SDK? Do you have any error message in the console?
I tried the PostFX Sample, it gives me a segmentation fault.
Title: PostFX Segmentation Fault on Ubuntu 9.10
Post by: Laurent on November 01, 2009, 06:58:31 pm
Ok... Anyway, I'm going to rewrite the PostFx class so it will probably work after that :)
Title: I fixed it
Post by: OniLinkPlus on November 02, 2009, 02:41:12 am
Code: [Select]
////////////////////////////////////////////////////////////

/// Preprocess a SFML effect file

/// to convert it to a valid GLSL fragment shader

////////////////////////////////////////////////////////////

std::string PostFX::PreprocessEffect(std::istream& file)

{

    // Initialize output string

    std::string out = "";



    // Variable declarations

    std::string line;

    while (std::getline(file, line))

    {

        // Remove the ending '\r', if any

        if (!line.empty() && (line[line.size() - 1] == '\r'))

            line.erase(line.size() - 1);



        // Skip empty lines

        if (line == "")

            continue;



        out += line;

    }



    return out;

}

There's my temporary fix. It works. :D But it creates "stuttering", with a few frames drawing, then pausing, then a few frames drawing, then pausing.