-
Notifications
You must be signed in to change notification settings - Fork 578
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
New image handling and image types #466
base: master
Are you sure you want to change the base?
Conversation
Generally this looks like a promising approach to me.
This though is a bit too strict in my opinion. I can not imagine myself tracking dimensions of each image, icon, ... I use in my app. Why actually not emulate the current "old" API (which was extremely limited but did not require specifying dimensions) using this your new API? Actually I dare to think this new approach could be implemented in a backwards compatible way (i.e. just extending the current API) without the need to introduce 5.x.y version. What do you all think? |
Huh... Now that you mention it, maybe that is too strict. So keep the old commands, always defaulting to NK_IMAGE_STRETCH and create a set of new ones, where you have to specify size I guess?
Isn't that always automatically known when you load the image? |
Yes, right now that would be my preference. But I have a weird feeling I am missing something so please come up with other ideas if you have any 😉.
Yes. What I meant though is the syntactical pollution of maintaining variables (scalars, arrays, maps, whatever...) holding the dimensions for no apparent benefit. Does that make more sense now? |
Created two sets of commands, one with type in the name, reverted changes to old commands, removed [5.x] tag from issue titled, since there is no more API break. |
Nice, thanks. Do you still plan to work on the last TODO items in the initial post above or shall we make our hands dirty with a full-scale review already? |
I really like where this is going! |
Note to self: Use Nuklear's internal floor(), instead of the math.h floor(). Creates an unresolved dependancy |
Is there anything I can help with to get this merged? |
I've given you access to my repo and the branch, that this PR is connected to. Go wild, in case you have any ideas. I'll revive my Nuklear efforts over the weekend. What it got stuck on last time I wanted to contribute, are the Krita design files + nk_card code, that I couldn't publish due to being derived from company internal design guideslines. I'll recreate them over the weekend from FOSS material, post that and then return to this PR. |
…ith dynamic layouting.
I was able to start on this today. I updated the NK_IMAGE_CENTER case to use uv coords instead as it didnt work correctly on dynamic layout. I will continue with implementing the nk subimage as per @FrostKiwi todo notes. |
Many many thanks for that excellent support. Finished my Pull Request regarding the skin design file #548 and will return to look at Nuklear next week. |
@wuxxerno Ohh wow, you were right. How did I miss that. Glad to have this figured out, I really didn't want to do the math there to get it to work without scissor^^ You made changes directly to cd ../../src && sh paq.sh && cd - && make && ./bin/demo.exe I moved your contributions over to with fc97bb9 to |
I see! thank you for explaining and correcting that. |
I just finished implementing the nk_subimage handling. (All but NK_IMAGE_TILE)
Did you mean something totally generic like a function that swaps and crops two user inputted buffers that the user then can use upload as a new texture for a new nk_image? @FrostKiwi @dumblob |
That is HUGE! It was the quint essential challenge remaining to get this PR to an at least theoretically mergable state.
In short: there is no solution from the position of a backend agnostic library, because the tile needs to tile (heh). Something only the backend can do. (Except rendering a ton of nk_images to tile window, resulting in horribly wasteful performance and blowing past all kinds of buffers on a high res screen with a small tile)
Yes. A function which writes the content of an nk_subimage as defined by the subregion to a buffer, to a buffer specified by the user with a pointer. Similar to The user may then setup tiling correctly. (By uploading as a separate texture, or bundle them in a texture array). It's less of a solution and more of a convenient tool to help the user setup tiling. (technically there is no reason this couldn't be done via a custom shader with |
Hello, I've tried to reproduce your (@FrostKiwi) example code using the SDL2 Surface backend, and the whole context crashes when trying to display record.mp4Here's my modified I hope this isn't a bug in my own implementation! |
This should be really working. As mentioned in the doc,
I followed your example and implemented it in SDL_renderer, loaded up the texture via Checked I always used GLFW for my projects and never used SDL2, so from here on out I can't say why SDL2 refuses drawing a texture outside it's bounds. Here is what ChatGPT had to say on the topic:
PS: gave you commit access to this Pull Request, in-case you want to contribute a demo or fix. |
There is no crash. It's just me quitting the application and starting it again to show the bug in three different way (resize, scroll, different window). Sorry for my miscommunication.
Thank you very much, I'll do that! |
Fix minor compilation warnings in image handling
It has been officially more than 2 years since this Pull Request was opened. Is there anything we can do to help push it forwards? What else is missing? |
So far Nuklear has ignored image aspect ratio and getting images to properly display has been by hacking your way around the layout system. This PR introduces
enum nk_image_type
instruct nk_image
to remedy this and obsoletes PR #444. The new image types are demonstrated here:image_types.mp4
The image type is a setting defined upon image creation and does not need to be supplied each time nk_image is called. The API for displaying the image stays the same. nk_image() generates the
NK_COMMAND_IMAGE
with correct sizes to honor aspect ratio based on the surround layout.nuklear.h
. I think providing a utility function innuklear_util.c
to copy a the subimage rect into a new buffer, so the user may upload that buffer to create a new texture.This PR is an API break: It requires the user to provide image-size upon image creation, no exceptions.Also the image type has to be provided upon nk_image creation. This is required for any of this to work and is a long overdue change IMO. This PR is also essential for the interface element that I'm porting to Nuklear "cards" to work.Since this API break is needed, I took the chance to rename some functions for more clarity. Eg.struct nk_image nk_image_ptr(void*);
is nownk_image_from_ptr(void*, nk_ushort w, nk_ushort h, enum nk_image_type);
, to make it clear, that this function is for generating a new nk_image from a pointer, not for providing the pointer of an nk_image.Now there is no more new command type needed, as I did in PR #444, which is much nicer to maintain.
TODO:
Fix demo files to speak the new API, so the Github's build pipline does not complainMake nk_subimage versions of all the new image types, except NK_IMAGE_TILE