Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Internal drawing bug #907

Open
ghost opened this issue Sep 19, 2019 · 2 comments
Open

Internal drawing bug #907

ghost opened this issue Sep 19, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 19, 2019

Hello,

So after investigating a lot, I have found that there is still some internal drawing problems on nuklear.

E.g. #347, #401, #409, #424, #479, #480

On a separate note, the commit 9a9f4f0 is introducing breaking changes on the D3D9 backend, and probably many others.

As this is a serious issue, I am thinking and gathering a maximum of information, before doing a pull request.

I am working on many nuklear project for some time now, and expect some fixes from me.

@ghost
Copy link
Author

ghost commented Sep 19, 2019

Note about the D3D9/OpenGL backend:

For a 500 x 500 pixels window,

When I revert the commit 9a9f4f0:

with NK_ANTI_ALIASING_OFF
The window is drawn at the correct size.
Bottom lines and right lines are not drawn like getting -0.5f offsets.
> result in a 500px x 500px window.

with NK_ANTI_ALIASING_ON
The window is drawn with anti-aliasing (with 0.5f offsets), but the lines are drawn without anti-aliasing.
> result in a 501px x 501px window.

When I use the commit 9a9f4f0:

with NK_ANTI_ALIASING_OFF
The window is drawn with the 0.5f offsets (1px more).
Top lines and left lines are not drawn like getting -0.5f offsets.
> result in a 501px x 501px window.

with NK_ANTI_ALIASING_ON
The window is drawn without anti-aliasing (buttons too), only lines get anti-aliased.
> result in a 500px x 500px window.

Note about other drawing bugs:

with NK_ANTI_ALIASING_OFF
When we draw with nk_stroke_rect, and that float line_thickness > 1.0f there is a bug.
float line_thickness = 0, it is not drawing our rectangle. correct.
float line_thickness = 1, it is drawing our rectange with a 1px thickness. correct.
float line_thickness > 1, it is drawing four broken edges (-1px). not correct.
When config.line_AA is set to NK_ANTI_ALIASING_ON, the bug is gone. (but it doesn't matter as we don't want anti-aliasing)

Exemple with float line_thickness = 2, at bottom right,
bug_thickness_1

Note 1: regardless of whether the anti-aliasing is enabled or not, the window should always be the same specified size.

Note 2: when disabling anti-aliasing lines, you'll probably want to disable borders in your style as well (same as Dear ImGui).


Updates:

1. I have fixed the lines not being drawn due to getting -0.5f on offset.x and offset.y.

2. About the problem with line_thickness > 1 when NK_ANTI_ALIASING_OFF is set, well this is really tricky because of too many factors (different backends as well as with/without AA), I will end up using my own function.
If you want additional information, have a look here:

@dumblob
Copy link
Contributor

dumblob commented Sep 20, 2019

Hey, we're glad you're using Nuklear in many projects.

Regarding 1px off, feel free to make a pull request with the improvement. I'm actually quite confident we shouldn't just blindly revert the commit, but come up with a better solution - any ideas? Maybe add the "anti-aliasing" also to other parts of Nuklear?

This was referenced Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant