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

Author Topic: PostFX Segmentation Fault on Ubuntu 9.10  (Read 2693 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
PostFX Segmentation Fault on Ubuntu 9.10
« 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
PostFX Segmentation Fault on Ubuntu 9.10
« Reply #1 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?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
PostFX Segmentation Fault on Ubuntu 9.10
« Reply #2 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
PostFX Segmentation Fault on Ubuntu 9.10
« Reply #3 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 :)
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
I fixed it
« Reply #4 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.
I use the latest build of SFML2