Git Product home page Git Product logo

Comments (4)

g012 avatar g012 commented on July 3, 2024

from microui.

ghaerr avatar ghaerr commented on July 3, 2024

Hello @zrafa,

Porting microui to a software renderer involves writing a new "renderer" that is called from your main loop, where microui is used to create windows and then the commands it generates for that are interpreted and drawn by your own code. It will call mu_next_command in a loop and switch out to your own custom draw code.

I have an example of this in https://github.com/ghaerr/microui/tree/master/demo-nano-X. See the main.c file, where the main loop does the above and switches out to drawing text, rectangles, icons and setting clip rects, that's it. This particular example ported microui to a graphics system called Microwindows that is more complicated and eventually draws into a frame buffer, but the idea is the same. You will also have to think through how you want to handle input.

Thank you!

from microui.

zrafa avatar zrafa commented on July 3, 2024

Thanks a lot for the comments. So it is clear that we must to modify/write renderer. Now, whichs function(s) exactly? And what do them do?
void r_init(void);
void r_draw_rect(mu_Rect rect, mu_Color color);
void r_draw_text(const char *text, mu_Vec2 pos, mu_Color color);
void r_draw_icon(int id, mu_Rect rect, mu_Color color);
int r_get_text_width(const char *text, int len);
int r_get_text_height(void);
void r_set_clip_rect(mu_Rect rect);
void r_clear(mu_Color color);
void r_present(void);
I mean, which of them "write" to the real screen? (or virtual, whatever, the one which you see). For example, r_clear(), clear the whole real screen? I do not know exactly what does each one.
@ghaerr : btw, I would love to use nano-x in my experiments (that was my firt choice. But it seemed me that I need sockets. Xinu has network, but I am not confident with its implementation and usage yet.

Thanks in advance for any extra help.

from microui.

ghaerr avatar ghaerr commented on July 3, 2024

I mean, which of them "write" to the real screen? For example, r_clear(), clear the whole real screen? I do not know exactly what does each one.

You can see what each one needs to do be looking at the source code for the port of microui to nano-X above. Did you look at the renderer.c source? I advise you study all the .c files, there aren't many, they tell you the answer you are looking for.

I would love to use nano-x in my experiments (that was my firt choice. But it seemed me that I need sockets.

Nano-X and microui solve two different problems. Microui's purpose is to easily build immediate-mode user interfaces. Nano-X is a graphical windowing system that can be configured without sockets. If you have a nano-X question, you can ask it over there.

from microui.

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.