Hello, I am currently using the SFML library for a project of mine (a small 2D game engine) and I've run into the following problem. I am trying to create a brush system where the level designer is able to assemble geometry based on convex shapes (think Hammer editor). Part of that system is texturing. The texture can be moved, scaled and rotated to provide a way for creating impressive geometry and objects without external tools. The SFML part of the brush is represented by a sf::ConvexShape and the texture by a sf::Texture. Scaling and offsetting the texture can be done by modifying the texture rectangle, but rotation can't, since sf::Rect<T> is axis aligned.
This is what I'm trying to do:
I've had multiple ideas how to work around this. One of them was to load an sf::Image first, apply a rotation algorithm to it and then create 360 instances of the texture, for one degree each. I quickly discarded this approach since it's ugly, slow and wastefull of resources. However, I came up with another possible solution: Shaders! I have very little experience with graphics programming and have therefore never written a shader by myself. I've worked with the UDK a while back, which provides a node editor that generates HLSL code. Using this editor it was trivial to rotate materials, even in real time. Can someone help me how to archive this using SFML and GLSL? I literally have no idea where to start. For instance, should this be done in the vertex or in the fragment shader? I really don't a a clue how to proceed. Usually I would tackle this problem by learning more about the issue at hand (i.e. how to write shaders), but I am on a very tight deadline since this is a graduation project. I would appreciate if someone could help me out, or at least give me a pointer how to archive my goal.
Thanks for the help.