Hi, I am real beginner in GLSL. I have this GLSL vertex shader and it doesnt work as I want. According to me it should change the position of the rectangle by * 0.5, because SFML draw it like GL_QUAD with vertexes, but rect disapears. Can somebody help me please?
I also tried change last line to, but it doesnt work
.
gl_Position = gl_ModelViewProjectionMatrix * a;
Shader code
void main(void)
{
vec4 a = gl_Vertex;
a.x = a.x * 0.5;
a.y = a.y * 0.5;
gl_Position = a;
}
Here is my code
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode(800,600,32),"SFML");
App.SetFramerateLimit(30);
sf::Shader vertShader;
if(!vertShader.LoadFromFile("scaleshader.vert",sf::Shader::Vertex))
App.Close();
while(App.IsOpen())
{
App.Clear();
sf::Event event;
while(App.PollEvent(event))
{
if((event.Type == sf::Event::Closed) || (event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
App.Close();
}
sf::RenderStates shader(&vertShader);
sf::RectangleShape rect(sf::Vector2f(200,100));
rect.SetPosition(300,250);
rect.SetFillColor(sf::Color(255,0,0,255));
App.Draw(rect,shader);
App.Display();
}
return 0;
}