nuklear icon indicating copy to clipboard operation
nuklear copied to clipboard

Rendering to a framebuffer instead of OpenGL

Open RossComputerGuy opened this issue 6 years ago • 10 comments

I was looking through the code because I'm wanting to use Nuklear but I don't want to use OpenGL, this is for a graphics system I'm developing. So I just need to be able to render to a framebuffer and it seems possible to render without OpenGL. Can I please get some help with rendering to a framebuffer if it's possible.

RossComputerGuy avatar Sep 30 '19 17:09 RossComputerGuy

Sure, that's one of the main goals of Nuklear - to have extremely easily pluggable backends. Just look at the demo/ folder where you'll find all currently functional backends (there might be some also in pull requests to this repository). If you need more help, don't hesitate and ask :wink:.

dumblob avatar Oct 01 '19 08:10 dumblob

Ok, it looks pretty straight forward. I'll leave the issue open if I need help.

RossComputerGuy avatar Oct 01 '19 13:10 RossComputerGuy

opticsgs/libopnuk on  master [!?] took 38m 28s
[I] ➜ ../build/demos/opnuk/demo-opnuk
** Message: 10:27:38.505: Using /run/user/1000/slatewm.sock for IPC path
demo-opnuk: /home/ross/RonixOS/opticsgs/libopnuk/nuklear/nuklear.h:16325: nk_begin_titled: Assertion `win->seq != ctx->seq' failed.

Got this error creating just doing this:

    if (nk_begin(&ctx.nkctx, "Overview", nk_rect(10, 10, 400, 600), NK_WINDOW_BORDER)) {
    }
    nk_end(&ctx.nkctx);

RossComputerGuy avatar Oct 01 '19 17:10 RossComputerGuy

I took the rawfb header from the X11 RawFB example and integrated it, I only see a white box.

RossComputerGuy avatar Oct 01 '19 18:10 RossComputerGuy

Got this error creating just doing this: ...

This is weird. Please post the full source code somewhere (pastebin, your github repo, ...) so that we can take a look.

I took the rawfb header from the X11 RawFB example and integrated it, I only see a white box.

Same as above - post the full source and I'll try to find some time to dig through it during the next two or three weeks.

dumblob avatar Oct 01 '19 20:10 dumblob

https://github.com/ronixos/opticsgs is the repository I'm doing this all in, libopnuk is doing the Nuklear rendering stuff and demos/opnuk/src/main.c is where libopnuk is being used.

RossComputerGuy avatar Oct 01 '19 21:10 RossComputerGuy

The code of the opnuk demo I'm working on.

  libopticsgs_win_t* win;
  if ((r = libopticsgs_window_create(&win, 0, 0, 0, 640, 480, 0)) != LIBOPTICSGS_ERROR_NONE) {
    g_error("Failed to create window: %s", libopticsgs_strerror(r));
    return EXIT_FAILURE;
  }
  opnuk_context_t ctx;
  if ((r = opnuk_init(win, OPNUK_RENDER_GL2, &ctx)) < OPNUK_ERROR_NONE) {
    libopticsgs_window_destroy(win);
    g_error("Failed to initialize opnuk: %d", r);
    return EXIT_FAILURE;
  }
  while (1) {
    struct nk_context* nk = opnuk_getnk(&ctx);
    if (nk_begin(nk, "Overview", nk_rect(0, 0, win->width, win->height), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
      nk_layout_row_dynamic(nk, 20, 1);
      if (nk_button_label(nk, "button")) {}
    }
    nk_end(nk);
    if (ctx.renderer == OPNUK_RENDER_GL2) {
      glViewport(0, 0, win->width, win->height);
      glClear(GL_COLOR_BUFFER_BIT);
      glClearColor(0.10f, 0.18f, 0.24f, 1.0f);
    }
    opnuk_render(ctx);
  }

The green border is the window frame in the screenshots bellow.

Rendering with rawfb: image In this, it is rendering outside of the space its supposed to in the bottom and right.

Rendering with OpenGL 2.0: image In this, nothing is rendering

RossComputerGuy avatar Oct 02 '19 14:10 RossComputerGuy

https://github.com/ronixos/opticsgs error 404??

hbiblia avatar Oct 23 '19 17:10 hbiblia

I stopped developing that since it wouldnt work

RossComputerGuy avatar Oct 23 '19 18:10 RossComputerGuy

I stopped developing that since it wouldnt work

oka, nad closes this thread if it is no longer necessary.

hbiblia avatar Oct 24 '19 13:10 hbiblia