Skip to content
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

How to port to another low level access graphic control #56

Open
zrafa opened this issue Nov 24, 2021 · 4 comments
Open

How to port to another low level access graphic control #56

zrafa opened this issue Nov 24, 2021 · 4 comments

Comments

@zrafa
Copy link

zrafa commented Nov 24, 2021

Hello. This is not an issue. Just a question looking for a link or help:
How I do port this great project to another lower framebuffer layer? I see that it depends on SDL y GL it seems.
I have just a memory buffer for drawing pixeles (it is a little experiment on Xinu operating system using vga in protected mode x86).
So I do not have neither SDL nor GL. But I can draw pixels (or of course, copy a memory drawing buffer to screen for example).
Should I modify the renderer.* files? Others? Any help on how to modify the current demo for a new screen control would be appreciated.

@g012
Copy link

g012 commented Nov 24, 2021 via email

@ghaerr
Copy link

ghaerr commented Nov 25, 2021

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!

@zrafa
Copy link
Author

zrafa commented Nov 25, 2021

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.

@ghaerr
Copy link

ghaerr commented Nov 25, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants