You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.
I am trying to modify a function called icon_load() that currently is responsible for loading a .png image into memory, into a function that simply loads an image that is created in heap memory.
Here is the original source code for it, defined in example/extended.c:
Here is my modified version.
Instead of generating an image buffer from a .png file, I generated a 4 x 4 texel GL_RGBA texture on heap memory. I basically replaced stbi_load() (which returns a pointer to stbi_uc just a typedef for unsigned char)
by malloc() (which returns a void pointer but it is cast to unsigned char). I have also replaced stbi_image_free() by free()):
Looking at the output I assume that malloc() was successful.
The fact that Messi is now 32, indicates that icon_load() was successfully called 31 times for each of the icons/images in lines 821 - 829 , before any rendering was actually done.
Using good old printf() debugging I realized the crash occurs inside function nk_begin_titled():
NK_ASSERT(ctx->style.font && ctx->style.font->width && "if this triggers you forgot to add a font");
How can this be fixed?
Is there another way in nuklear to display images that are created in the heap memory?
The text was updated successfully, but these errors were encountered:
You need to initialize the font atlas and either add your own fonts or use the default font (requires NK_INCLUDE_DEFAULT_FONT define) then bake. Then don't forget to nk_style_set_font for a font.
No matter your rendering backend or how you load textures, you'll want to pass the texture id to nuklear functions as a struct nk_image. Eventually, in the draw list loop it will spit this back out in a draw command as cmd->texture, where you will call glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id);
If you need image loading library you can try DevIL.
I am trying to modify a function called icon_load() that currently is responsible for loading a .png image into memory, into a function that simply loads an image that is created in heap memory.
Here is the original source code for it, defined in example/extended.c:
Here is my modified version.
Instead of generating an image buffer from a .png file, I generated a 4 x 4 texel GL_RGBA texture on heap memory. I basically replaced stbi_load() (which returns a pointer to stbi_uc just a typedef for unsigned char)
by malloc() (which returns a void pointer but it is cast to unsigned char). I have also replaced stbi_image_free() by free()):
The output:
Looking at the output I assume that malloc() was successful.
The fact that Messi is now 32, indicates that icon_load() was successfully called 31 times for each of the icons/images in lines 821 - 829 , before any rendering was actually done.
Using good old printf() debugging I realized the crash occurs inside function nk_begin_titled():
NK_ASSERT(ctx->style.font && ctx->style.font->width && "if this triggers you forgot to add a font");
How can this be fixed?
Is there another way in nuklear to display images that are created in the heap memory?
The text was updated successfully, but these errors were encountered: