Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the sfml2 example #103

Closed
hachmeister opened this issue Jul 2, 2020 · 8 comments
Closed

Problem with the sfml2 example #103

hachmeister opened this issue Jul 2, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@hachmeister
Copy link
Contributor

I added a drawing command with a CircleShape to the sfml2 example. After that the window is only black if I start the sfml2 example.

See my changes:
master...hachmeister:sfml-drawing

@mikke89
Copy link
Owner

mikke89 commented Jul 2, 2020

I played around with it for a bit. Looks like you need to (re)set the viewport before issuing SFML rendering commands. Eg. something along these lines:

sf::View View;
View.setViewport(sf::FloatRect(0, 0, 1, 1));
MyWindow.setView(View);

MyWindow.draw(circle);

@hachmeister
Copy link
Contributor Author

Thanks for your investigation with that I got it working.

But just some thoughts:
It would be nice not to have to adapt your program when using RmlUi.
In der RmlUiSFMLRenderer::Resize method a view is set. If I comment this out the example is still working, even with the circle. Is this view really necessary?

I made a second commit in my branch:
master...hachmeister:sfml-drawing

@mikke89
Copy link
Owner

mikke89 commented Jul 3, 2020

Yeah, I'm not sure exactly why it is done like that. Perhaps it has something to do with the input handling? I don't want to just remove it until we know its implications. I'm sure there is room for improvements though, pull requests are very much welcome when you find something that works well ;)

@hachmeister
Copy link
Contributor Author

I looked at the source code of SFML what happens when one sets a new view.

If the RenderInterface class from RmlUi and the SFML application sets a new view the last one will win.

If I set a view in a SFML application every frame this will also affect the RmlUi gui. Scales the view the SFML scene, then the RmlUi gui is also scaled. This is something I wouldn't expect.

I made a new branch in my RmlUi fork with the following changes:

The sfml example uses a view to display the scene and the window can be resized. It shows the scene with the same aspect ratio when you resize the window. You can use the keys 1, 2 and 3 to display the scene with different scale factors, 2 is the default factor.

The RenderInterface class set the Opengl viewport directly before the gui is drawn and not when the window is resized. So it does not interfere with the SFML view.

See my changes:
master...hachmeister:sfml-renderer

@mikke89
Copy link
Owner

mikke89 commented Jul 6, 2020

Looks good! If you want to clean it up a bit, I'd like to see it as a pull request :)

@hachmeister
Copy link
Contributor Author

I would make a new branch for the pull request. Should the changes to the example also be part of the pull request?

@mikke89
Copy link
Owner

mikke89 commented Jul 6, 2020

Great. Yes, I like the little circles.

@mikke89
Copy link
Owner

mikke89 commented Jul 12, 2020

Closing this as the issue was fixed in #106. Thanks!

@mikke89 mikke89 closed this as completed Jul 12, 2020
@mikke89 mikke89 added the enhancement New feature or request label Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants