SFML community forums
Help => Graphics => Topic started by: OniLinkPlus on November 01, 2009, 05:56:58 am
-
Ack, I am not liking Build 1250 so far.
Here's my code:
#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:
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:
texture screen
float time
effect{
_out = vec4(screen(_in));
}
Still get a segmentation fault.
-
Did you try the post-fx sample from the SDK? Do you have any error message in the console?
-
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.
-
Ok... Anyway, I'm going to rewrite the PostFx class so it will probably work after that :)
-
////////////////////////////////////////////////////////////
/// 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.