-
Notifications
You must be signed in to change notification settings - Fork 18
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
Self Masking for Vector Layers #584
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,9 +98,21 @@ void PolygonGroup2dOpenGl::render(const std::shared_ptr<::RenderingContextInterf | |
if (!ready) | ||
return; | ||
|
||
GLuint stencilMask = 0; | ||
GLuint validTarget = 0; | ||
GLenum zpass = GL_KEEP; | ||
if (isMasked) { | ||
glStencilFunc(GL_EQUAL, isMaskInversed ? 0 : 128, 128); | ||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | ||
stencilMask += 128; | ||
validTarget = isMaskInversed ? 0 : 128; | ||
} | ||
if (renderPass.isPassMasked) { | ||
stencilMask += 127; | ||
zpass = GL_INCR; | ||
} | ||
|
||
if (stencilMask != 0) { | ||
glStencilFunc(GL_EQUAL, validTarget, stencilMask); | ||
glStencilOp(GL_KEEP, GL_KEEP, zpass); | ||
Comment on lines
+101
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation of stencil operations in the
Consider adding comments to explain the rationale behind the chosen stencil operation values, especially the significance of |
||
} | ||
|
||
std::shared_ptr<OpenGlContext> openGlContext = std::static_pointer_cast<OpenGlContext>(context); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,9 +193,21 @@ void Quad2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &co | |
|
||
glUseProgram(program); | ||
|
||
GLuint stencilMask = 0; | ||
GLuint validTarget = 0; | ||
GLenum zpass = GL_KEEP; | ||
if (isMasked) { | ||
glStencilFunc(GL_EQUAL, isMaskInversed ? 0 : 128, 128); | ||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | ||
stencilMask += 128; | ||
validTarget = isMaskInversed ? 0 : 128; | ||
} | ||
if (renderPass.isPassMasked) { | ||
stencilMask += 127; | ||
zpass = GL_INCR; | ||
} | ||
|
||
if (stencilMask != 0) { | ||
glStencilFunc(GL_EQUAL, validTarget, stencilMask); | ||
glStencilOp(GL_KEEP, GL_KEEP, zpass); | ||
Comment on lines
+196
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The modifications to the
Adding comments to explain the rationale behind the chosen stencil operation values and ensuring that the implementation is robust against all possible combinations of masking conditions would improve code clarity and maintainability. |
||
} | ||
|
||
if (usesTextureCoords) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
The modifications to the
render
method for handling stencil operations based on masking conditions are well-intended for enhancing rendering flexibility. However, consider the following:stencilMask
andvalidTarget
should be thoroughly tested to ensure it behaves as expected under all combinations ofisMasked
andrenderPass.isPassMasked
.128
and127
for modifyingstencilMask
values appears arbitrary without context. Ensure these values are documented to explain their significance and how they contribute to the intended stencil operations.GL_INCR
forzpass
assumes a specific usage pattern of the stencil buffer. Confirm that this approach is compatible with the overall rendering strategy and does not risk stencil buffer overflow, which could lead to rendering issues.Adding detailed comments to explain the logic behind the chosen values and operations would greatly aid in the maintainability of this code. Additionally, consider edge cases where the combined stencil operations might not produce the expected results and adjust or document as necessary.