-
Notifications
You must be signed in to change notification settings - Fork 333
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
Comments
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); |
Thanks for your investigation with that I got it working. But just some thoughts: I made a second commit in my branch: |
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 ;) |
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: |
Looks good! If you want to clean it up a bit, I'd like to see it as a pull request :) |
I would make a new branch for the pull request. Should the changes to the example also be part of the pull request? |
Great. Yes, I like the little circles. |
Closing this as the issue was fixed in #106. Thanks! |
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
The text was updated successfully, but these errors were encountered: