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

window not drawn at correct size #480

Open
wheybags opened this issue Jul 12, 2017 · 3 comments
Open

window not drawn at correct size #480

wheybags opened this issue Jul 12, 2017 · 3 comments

Comments

@wheybags
Copy link
Contributor

nk_flags windowFlags = NK_WINDOW_TITLE | NK_WINDOW_NO_SCROLLBAR;

if (nk_begin(ctx, "asdf", nk_rect(10, 10, 100, 100), windowFlags))
{
}
nk_end(ctx);

^ The above code should produce a 100x100 box, but is actually producing a 101x101 box:
image

There seems to be some feathering around the edges, which produces the "border", even though I haven't specified NK_WINDOW_BORDER. As I understand it, this feathering shouldn't be there, as I am specifying exact pixel coordinates, and the box is axis-aligned.

Original screenshot:
image

@wheybags
Copy link
Contributor Author

This is with the sdl_opengl3 demo backend btw. Just tried with the gdip demo backend too, and the square is still 101x101, but the colour is solid all the way to the edges

@vurtun
Copy link
Owner

vurtun commented Jul 12, 2017

Hmm. At least xlib seems correct which makes this whole thing more complicated.

fuck

Honestly I have not idea what this could be. Probably a big mess that turns into a Whac-A-Mole between platforms.

@alekseyt
Copy link

alekseyt commented Aug 5, 2017

I'm pretty sure it's some sort of rounding error.

border

Note how border is messed up at the bottom-left corner (top-left corner had same effect). Code was:

nk_begin(ctx, "Demo", nk_rect(0, 0, 100, 100)

Demo was sdl_opengl2, background color was changed to (255, 0, 0).

I suspect xlib is somehow fixing rounding, for example by aligning positions to pixels, but OpenGL is interpolating pixel values instead. Apparently, in picture above, bottom border (horizontal) pixels are at x=0 or close to that, but left border (vertical) pixels probably a little bit shifted to the right. This is just my guess.

@ghost ghost mentioned this issue Sep 19, 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

3 participants