-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Added support for scissor testing. #1451
Conversation
562229f
to
4de2256
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1451 +/- ##
==========================================
+ Coverage 39.28% 39.35% +0.06%
==========================================
Files 236 236
Lines 20763 20816 +53
Branches 5151 5179 +28
==========================================
+ Hits 8157 8192 +35
- Misses 11785 11804 +19
+ Partials 821 820 -1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
4de2256
to
56e5d77
Compare
Updated to current master. |
56e5d77
to
3a78fed
Compare
Updated to current master and added tests. |
3a78fed
to
09edc92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a few items you should consider but besides that I'm cool with this PR 👍
09edc92
to
350257e
Compare
Fixed. |
08a885b
to
ef4d9dd
Compare
ef4d9dd
to
99ad9dd
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
Some small, mostly documentation comments.
Plus, we may want to document somewhere, what the difference between viewport and scissor testing is.
99ad9dd
to
4d1f927
Compare
Updated.
Added a paragraph to the |
It doesn't work well in interaction with See the result of the following code: #include <SFML/Graphics.hpp>
int main()
{
auto target = sf::RenderTexture{};
if (!target.create({400, 300}))
return 1;
auto font = sf::Font{};
// https://github.com/SFML/SFML/raw/master/test/Graphics/tuffy.ttf
if (!font.loadFromFile("tuffy.ttf"))
return 1;
auto text = sf::Text{font, "0123456789ABCDEFGHIJKLMNOPQ", 30};
text.setFillColor(sf::Color::White);
text.setPosition({0.f, 100.f});
target.clear(sf::Color{64, 64, 64});
auto scissorView = target.getDefaultView();
scissorView.setScissor({{0.1f, 0.1f}, {0.8f, 0.8f}});
target.setView(scissorView);
target.clear(sf::Color{128, 192, 128});
target.draw(text);
target.display();
if (!target.getTexture().copyToImage().saveToFile("result.png"))
return 1;
return 0;
} Below is the expected result, which I get after applying this patch (quick hack, probably not a proper solution). diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp
index 7c6df2e5..70b5286d 100644
--- a/src/SFML/Graphics/Texture.cpp
+++ b/src/SFML/Graphics/Texture.cpp
@@ -463,6 +463,8 @@ void Texture::update(const std::uint8_t* pixels, const Vector2u& size, const Vec
// Make sure that the current texture binding will be preserved
const priv::TextureSaver save;
+ glCheck(glDisable(GL_SCISSOR_TEST));
+
// Copy pixels from the given array to the texture
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glTexSubImage2D(GL_TEXTURE_2D, |
4d1f927
to
92c1cf3
Compare
Updated. Turns out scissor testing was having an affect on our texture copying when the FBO blit implementation is used. |
92c1cf3
to
5145271
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm the problem with font rendering is not there anymore. Looks good to me besides minor comments below.
Changes have been addressed
5145271
to
7966721
Compare
7966721
to
283c636
Compare
Updated. |
This is a subset of #846 and implements a part of #1.
Test with: