Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [In progress] SFML ES 2 Discussion  (Read 4152 times)

0 Members and 1 Guest are viewing this topic.

foo

  • Newbie
  • *
  • Posts: 20
    • View Profile
[In progress] SFML ES 2 Discussion
« on: November 18, 2018, 10:10:02 pm »
Hello I've been in contact lately with binary 1248 and other members on the SFML committee regarding modern OGL support.


progress

For my engine to run on mobile, as it relies on shader effects, I needed SFML to be upgraded sooner. I've forked binary's feature branch SFML and added
SFML_OPENGL_ES32
macro definitions for the new code. I've more or less standardized some ways SFML can handle the new shader requirements.

Problem is that sf::Sprite used to handle all the built ins like Texture Coordinates, Color, etc. This is no longer supported and we must provide that info. Luckily this is just one uniform property away. It would be cumbersome to force the user to bind the text coord properties for each sprite (S in SFML stands for SIMPLE). I suggest we add a function to a class higher up in the chain, like the sf::RenderWindows themselves as they are responsible for drawing in the end.

sf::RenderTexture surface;
sf::Shader shader; // load shader...
shader.setTexCoordUniformName("vTexCoord");
sf::RenderStates states;
states.shader = &shader;
surface.draw(sprite, states);
 

Open to better naming conventions



For falling back on a default shader, we could require binding a default shader to the RenderWindow and RenderSurface at initialization.

sf::Shader defaultShader; // load default vertex and frag shaders
shader.setTexCoordUniformName("vTexCoord");
sf::RenderTexture surface(defaultShader);

surface.draw(sprite, states);

...

sf::RenderWindow window(VideoMode(800, 600), "window", Style::Default, defaultShader);
 

Otherwise passing a shader in with each draw call is a must.



Finally, if backwards compatibility is a must which we can do we supply built in shaders and suggest the default variable name in the docs and also allow the user to change the property with the proposed signatures as demonstrated before:

// Not loading any shaders, using SFML provided default shaders
window.setTexCoordUniformName("vTexCoord");// but we change the name of our tex coords
window.draw(sprite);
 

« Last Edit: November 18, 2018, 10:18:01 pm by foo »

 

anything