Hello,
Newcomer to sfml. I installed it this week and managed to port some code that creates various GUI widgets with container capabilities in order to test both my C++ and SFML understanding. I managed to get it work 100%. Now I am moving on to shaders. I have experience with shaders only from GameMaker so I'd like a few pointers for the following question:
I am writing a simple test shader to move a vertex X pixels in the x-axis and Y pixels in the y-axis. I found out that SFML vertices operate in some sort of normalized coordinates. A solution was to convert pixels to the coordinate space that SFML uses and transform them before passing them as a uniform. Example:
shader.setUniform("pos",sf::Glsl::Vec2(200.f*(2.f/1024.f),0.f));
Assuming a window size of 1024, this indeed moves the vertex 200 pixels to the right.
My question is: I'd like some help on how to set up a matrix or some other workaround to simply pass pixels to any shader without translating them to normalized coords in the uniform. As an example, I'd like to write:
shader.setUniform("pos",sf::Glsl::Vec2(200.f,0.f));
Of course, in the shader I could add:
gl_Position.x+=pos.x*(2./1024.);
Where 1024 the x-resolution which can also be a uniform.
However this requires also passing the window size/resolution to each shader. What should I do to set up a transformation matrix which substitutes gl_ModelViewProjectionMatrix that works with pixel coordinates directly?