here is the entire code...
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
sf::Shader testShader;
sf::RectangleShape testShape;
sf::RenderTexture renderTexture;
sf::Texture texture;
sf::Sprite sprite;
sf::Clock time1;
float lastTime;
int main(){
sf::RenderWindow Window;
Window.create(sf::VideoMode(1280, 720, 32), "Test");
//Window.setFramerateLimit(60);
sf::Event event;
testShape.setSize(sf::Vector2f(500,500));
testShader.loadFromFile("wave2.vert",sf::Shader::Fragment);
renderTexture.create(500,500);
while (Window.isOpen())
{
while (Window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
Window.close();
}
/** When the user left-mouse-click, add a box into the world */
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
Window.close();
}
Window.clear(sf::Color::Black);
testShader.setParameter("resolution",100,100);
testShader.setParameter("time",time1.getElapsedTime().asSeconds());
renderTexture.clear();
renderTexture.draw(testShape,&testShader);
renderTexture.display();
texture = renderTexture.getTexture();
sprite.setTexture(texture);
Window.draw(sprite);
Window.display();
float currentTime = time1.getElapsedTime().asSeconds();
float fps = 1.f / (currentTime - lastTime);
lastTime = currentTime;
cout<<"FPS: "<<fps<<"\n";
}
return 0;
}
does this look wrong to anybody? the fps I'm getting is about 7 without a framerate limit. If this looks right I guess it could be the shader itself. I implented the one shown here:
http://glsl.heroku.com/e#8067.3i just wanted to see if i could get a shader working at all, but it is really slow. Does anybody have answers?