Alright, so I got everything working with sf::Shader, and went to test the differences. Here's what I've found:
-Native Linux sf::Shader is very laggy
-Emulated Windows game with sf::PostFX runs perfectly at full speed
Why is it that an Emulated Game can run more efficiently than a Native Test? Here's another problem. When I used sf::PostFX, I used this shader:
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));
}
This was meant to make a watery effect by stretching and shrinking the screen. It worked perfectly, every part of the screen was stretched and shrunk, and there were no blank spaces in the screen. I used this code:
#include <SFML/Graphics.hpp>
int main(){
sf::RenderWindow Window(sf::VideoMode(512, 512, 32), "Test");
sf::Image imgBackground;
imgBackground.LoadFromFile("Random512x512image.png");
sf::Sprite sprBackground;
sprBackground.SetImage(imgBackground);
sf::PostFX WaterShader;
WaterShader.LoadFromFile("WaterShader.sfx");
while (Window.IsOpened()){
// Process Events here, close on sf::Event::Close
Window.Clear();
Water.SetTexture("screen", NULL);
Water.SetParameter("time", (double)clock());
Screen.Draw(sprBackground);
Screen.Draw(Water);
Screen.Display();
}
}
It works like a charm. However, with sf::Shader, I translated the Shader file to this:
uniform sampler2D screen;
uniform float time;
void main(){
vec2 offset = vec2(cos(time/500+gl_TexCoord[0].x*10)/50, sin(time/500+gl_TexCoord[0].y*10)/50);
gl_FragColor = vec4(texture2D(screen, gl_TexCoord[0].xy+offset));
}
And the test's code to this:
#include <SFML/Graphics.hpp>
int main(){
sf::RenderWindow Window(sf::VideoMode(512, 512, 32), "Test");
sf::Image imgBackground;
imgBackground.LoadFromFile("Random512x512image.png");
sf::Sprite sprBackground;
sprBackground.SetImage(imgBackground);
sf::Shader WaterShader;
WaterShader.LoadFromFile("WaterShader.sfx");
while (Window.IsOpened()){
// Process Events here, close on sf::Event::Close
Window.Clear();
Water.SetTexture("screen", sf::Shader::CurrentTexture);
Water.SetParameter("time", (double)clock());
Screen.Draw(sprBackground, Water);
Screen.Display();
}
}
And it works, but I get blank spots on the sides of the screen, and there is much lag. What could be causing this change?