- To clip drawing textures, would I use a fragment shader as opposed to a vertex shader (and update the bounds using parameters?) then setting the alpha to 0 if the pixel lies outside of the bounds? My current understanding of shaders says yes but more or less I'd like some confirmation that I'm not too entirely crazy.
Yes. There's even a GLSL function to discard a fragment, instead of hacking its alpha to 0.
There are other solutions for clipping but I don't think they are compatible with SFML.
- Are shaders faster/more ideal than using sf::Sprite and an sf::Texture to draw images each frame?
Shaders don't create anything, they just change how geometry and/or pixels are rendered. So you still need to feed them with geometry (sf::Sprite) and texture (sf::Texture).
You can't draw something with just shaders.
- What's the difference (internally) between drawing an sf::Sprite with a texture and just a set of polygons with a shader that draws a texture specified? Is there any advantage? If SFML isn't using a built-in shader to do this, how is SFML drawing a texture to the screen?
See my answer above. Shaders work on the provided geometry and texture, they don't replace them.
You should read more about the fixed pipeline functions and the graphics pipeline in general, probably on wikipedia.
- If shaders -are- faster, to draw an image with a shader (assuming the shader has been passed the appropriate texture as a parameter) would I just draw four points do the draw() method and then pass the shader as part of the render state?
Same answer, again.
- Are `uniform` constants (variables) in shaders just the parameters set by SFML's setParameter() method, verbatim?
Yes. But not verbatim: for example, sf::Color components are normalized. sf::Transform is passed as a 4x4 matrix.
- If so, what happens when I want to use a uniform constant that hasn't been set by the application? Is it undefined behavior?
Probably. Or maybe it has a default value of 0, I don't know.
- Are parameters sticky - meaning, if I set a parameter one frame, and not the next, does the value from the first time I set the parameter "stick" (persist) throughout the rest of the frames until it is explicitely set again?
Yes.
- Can/will shaders lock up the computer if something unexpected happens (like drivers do)?
Nop. They will just produce weird results.
- For maximum compatibility (the application in question is not a game) should I target the lowest possible shader version?
Probably. I think it's enough for most shaders -- unless you really want to implement crazy stuff.