'--------------------------------------------------------------------------------------------- INCLUDE canvas INCLUDE canvas-plugin-nuklear PRAGMA INCLUDE stb-master/stb_image.h : ' Include the stb_image header file PRAGMA OPTIONS -DSTB_IMAGE_IMPLEMENTATION -DSTBI_FAILURE_USERMSG : ' Enable graphical functions and user friendly error messages file$ = DIRNAME$(ME$) & "/BaCon.png" '--------------------------------------------------------------------------------------------- SUB Show_Gui() LOCAL canvas TYPE nuklear_buffer* LOCAL space TYPE nuklear_rect LOCAL col TYPE nuklear_color LOCAL data TYPE unsigned char* LOCAL width, height, channels TYPE int LOCAL texture = 0 TYPE static int LOCAL myImage = { 0 } TYPE static nuklear_image ' Create texture if it is not available yet IF NOT(texture) THEN ' Load picture using 4 channels (RGBA) data = stbi_load(file$, &width, &height, &channels, 4) texture = nk_canvas_tex(data, width, height) ' Create Nuklear Image id myImage = nk_image_id(texture) stbi_image_free(data) ENDIF ' (1) First query all mouse events for this window nk_canvas_events(&win) ' (2) Then create window IF nk_begin(&win.ctx, "Nuklear Picture", nk_rect(100, 100, 300, 300), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|NK_WINDOW_CLOSABLE|NK_WINDOW_TITLE|NK_WINDOW_MINIMIZABLE) THEN 'nk_layout_row_dynamic(&win.ctx, 200, 1) 'nk_button_image(&win.ctx, myImage) canvas = nk_window_get_canvas(&win.ctx) space = nk_window_get_content_region(&win.ctx) col = nk_rgba(255, 255, 255, 255) nk_draw_image(canvas, space, &myImage, col) ENDIF nk_end(&win.ctx) ' (3) Verify if there were changes in the GUI, if so, then clear screen and draw it. IF nk_canvas_changed(&win) THEN INK(100, 100, 100, 255) CLS nk_canvas_render(&win) ENDIF ' Quit if window is closed IF nk_window_is_hidden(&win.ctx, "Nuklear Picture") THEN nk_canvas_free(&win) nk_canvas_tex_free(texture) QUIT ENDIF END SUB '--------------------------------------------------------------------------------------------- DECLARE win TYPE nuklear_type WINDOW("Nuklear Demonstration 2", 1024, 768) win = nk_canvas_new() CALLBACK(20, Show_Gui) WAITKEY '---------------------------------------------------------------------------------------------