Hello Guest

Vulkan - Nuklear

  • 4 Replies
  • 927 Views
Vulkan - Nuklear
« on: November 19, 2018, 12:00:21 »
Hello,

I'm trying to use the Nuklear binding, and I have few questions:
- In the GLFWDemo.java:
Code: [Select]
// null texture setup
int nullTexID = glGenTextures();
null_texture.texture().id(nullTexID);

With vulkan, no glGenTextures. What should I put into the field ID (int)? I thought of an Image ID, but it's a long.

- Hard to find any code about Nuklear and Vulkan, but there is this one: https://github.com/m0ppers/nuklear-glfw-vulkan. He's using nk_font_atlas, but I don't see anything like that in the LWJGL binding, maybe I missed something?

*

Offline spasi

  • *****
  • 2052
    • WebHotelier
Re: Vulkan - Nuklear
« Reply #1 on: November 19, 2018, 14:37:28 »
Hey,

I'm not sure about the null texture.

LWJGL builds nuklear without NK_INCLUDE_FONT_BAKING, which means that the nk_font_atlas functionality is not available. Including it would bundle stb_truetype & stb_rect_pack with nuklear, but those are already available in LWJGL's stb bindings. See the GLFWDemo (lines 141-240) for an example of how you can implement the same functionality.

Re: Vulkan - Nuklear
« Reply #2 on: November 20, 2018, 12:01:22 »
Hello Spasi,

Yeah, actually I try to convert the GLFWDemo you speak about. But same question with the default_font: line 238:
Code: [Select]
.texture(it -> it
    .id(fontTexID));

fontTexID comes from:
Code: [Select]
int fontTexID = glGenTextures();
In Vulkan World, no glGenTextures, and IDs are long, not int; so I'm not sure what to use for this field.

So, for now I replace that by:
Code: [Select]
.texture(it -> it
    .ptr(vulkanImageId));

Still have a black screen for now haha.

*

Offline spasi

  • *****
  • 2052
    • WebHotelier
Re: Vulkan - Nuklear
« Reply #3 on: November 20, 2018, 18:54:55 »
Right, nk_handle is a union, you can use either id or ptr to store a handle. So, ptr is fine for a Vulkan image id.

As for why you get a black screen, note that Nuklear does not perform any rendering. You iterate the generated list of NkDrawCommand and it's up to you do the right OpenGL or Vulkan calls. For example, at line 606 of the existing demo, there's a glBindTexture(GL_TEXTURE_2D, cmd.texture().id()) call. In a Vulkan renderer, you'd use cmd.texture().ptr() instead.

Re: Vulkan - Nuklear
« Reply #4 on: November 20, 2018, 19:29:51 »
Thanks for your answer.

Yep, I saw that. I already have a functional vulkan pipeline, and I converted the opengl calls into vulkan ones. I just missed something I guess.

I'll share the code if I make it works.