Code Monkey home page Code Monkey logo

Comments (3)

vurtun avatar vurtun commented on May 18, 2024

Hey and thanks for the issue,

Would it be possible to append a zr_handle user_data to struct zr_context, struct zr_draw_command and struct zr_command. The handling could be similar to zr_set_font.

Do you mean same the userdata for zr_context, zr_draw_command and zr_command or each having their own? Other than that I don't see a problem of adding it per se but it will blow up the memory consumption for zr_command and to some extend in zr_draw_command as well. So if I will add userdata to zr_command and zr_draw_command I will also add defines to make sure not everyone has to pay for the additional costs.
But can I ask for what this is needed? I thought I made everything abstract enough so that you only need the zr_context struct to draw everything?

from nuklear.

richi avatar richi commented on May 18, 2024

or each having their own?

No, no, one for them all would be enough, just like setting a font.

But can I ask for what this is needed?

Imagine one wants to draw a bunch of buttons each using a different shader:

for (i = buttonCount; i > 0; i -= 1) {
    zr_set_userdata(context, (zr_handle)shader_for_button(i));
    do_button(i);
    zr_set_userdata(context, (zr_handle)default_shader);
    do_decoration(...);
}

And in the draw loop:

zr_draw_foreach(cmd, context, &cmds)  {
   shader = (shader_id)cmd->user_data; 
   bind_shader(shader);
   draw_elements(...);
   ...
}

I will also add defines to make sure not everyone

That would be perfect!

from nuklear.

dumblob avatar dumblob commented on May 18, 2024

I actually think it's worth adding, because tracking the data outside of the draw list would be too cumbersome. So I agree with making it conditional and adding it's use into demos.

from nuklear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.