raylib-nuklear-texture.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* ===============================================================
  2. *
  3. * EXAMPLE
  4. *
  5. * ===============================================================*/
  6. /*
  7. This example shows how to use the image API from raylib nuklear.
  8. And then display it.
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <raylib.h>
  13. #define RAYLIB_NUKLEAR_IMPLEMENTATION
  14. #include "raylib-nuklear.h"
  15. int main()
  16. {
  17. InitWindow(1280, 720, "[raylib-nuklear] - Texture/Image");
  18. // Initialize the context
  19. struct nk_context* ctx = InitNuklear(20);
  20. // Load the nk_image
  21. struct nk_image img = LoadNuklearImage("resources/test-image.png");
  22. while(!WindowShouldClose())
  23. {
  24. // Input
  25. UpdateNuklear(ctx);
  26. // The window called "Image example" is opend
  27. if(nk_begin(ctx, "Image example", nk_rect(200, 200, 420, 320), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE))
  28. {
  29. // Setup the layout
  30. nk_layout_row_static(ctx, 256, 256, 1);
  31. // Draw the image
  32. nk_image(ctx, img);
  33. }
  34. nk_end(ctx);
  35. // Draw the GUI
  36. BeginDrawing();
  37. ClearBackground(RAYWHITE);
  38. DrawNuklear(ctx);
  39. EndDrawing();
  40. }
  41. // Unload the Nuklear image
  42. UnloadNuklearImage(img);
  43. CloseWindow();
  44. return 0;
  45. }