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

XLib: stb_image support with bit transparency #512

Merged
merged 6 commits into from Sep 11, 2017

Conversation

Projects
None yet
2 participants
@DeXP
Contributor

DeXP commented Sep 4, 2017

X11 do not support transparent images itself. So the clip mask was calculated in this code. X11 ClipMask support only bit transparency.
Another negative side is a bad performace on big transparent images. But it work fast with opaque
images.

Original OpenGL render:
xlib-opengl

Xlib without transparency:
xlib-no-alpha

And final Xlib variant with bit transparency:
xlib-alpha

It's not good enough to use in games, semi-transparent images. But pretty good for UI icons, I think.

DeXP added some commits Feb 9, 2017

Fix panel clipping
`layout->bounds` cannot be used (loc 16615) since we modify it up here:
`layout->bounds.x += panel_padding.x;`  (16471)
`layout->bounds.w -= 2*panel_padding.x;` (16472)
Because of it there was no ability to `nk_draw_image` attached to window's edge. There alway was empty lines of right and left.

This code breaks the other's code. Popups, for example. My paddings are 10px. To show popup at (20,20) without this patch I must use `nk_rect(10, 20, ...`. With this patch I must use `nk_rect(20, 20, ...`, not depending on paddings. I think (20,20) is a correct constant for (20,20) coordinate.
stb_image with bit transparency
X11 do not support transparent images itself. So the clip mask is calculating in this code. X11 ClipMask support only bit transparency.
@DeXP

This comment has been minimized.

Show comment
Hide comment
@DeXP
Contributor

DeXP commented Sep 4, 2017

@vurtun

This comment has been minimized.

Show comment
Hide comment
@vurtun

vurtun Sep 11, 2017

Owner

Hey,
thanks for the PR. While I absolutely like the changes I think it would be best to introduce an additional configuration define to make it optional. My main reasoning would be that each of the nuklear_xxx should be as self contained as possible. While I provide a version of stb_image.h with this repository I don't want to directly depend on it.
So it would be great to have a define like NK_XLIB_INCLUDE_STB_IMAGE and NK_XLIB_IMPLEMENT_STB_IMAGE (or similar naming). The reason for two defines is that if a user already implements stb_image.h it would cause errors.
`

Owner

vurtun commented Sep 11, 2017

Hey,
thanks for the PR. While I absolutely like the changes I think it would be best to introduce an additional configuration define to make it optional. My main reasoning would be that each of the nuklear_xxx should be as self contained as possible. While I provide a version of stb_image.h with this repository I don't want to directly depend on it.
So it would be great to have a define like NK_XLIB_INCLUDE_STB_IMAGE and NK_XLIB_IMPLEMENT_STB_IMAGE (or similar naming). The reason for two defines is that if a user already implements stb_image.h it would cause errors.
`

@DeXP

This comment has been minimized.

Show comment
Hide comment
@DeXP

DeXP Sep 11, 2017

Contributor

I added both NK_XLIB_INCLUDE_STB_IMAGE and NK_XLIB_IMPLEMENT_STB_IMAGE to the code.

Contributor

DeXP commented Sep 11, 2017

I added both NK_XLIB_INCLUDE_STB_IMAGE and NK_XLIB_IMPLEMENT_STB_IMAGE to the code.

@vurtun vurtun merged commit 0c2a725 into vurtun:master Sep 11, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@vurtun vurtun referenced this pull request Sep 11, 2017

Closed

Vertical alignment #515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment