simple.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*******************************************************************************************
  2. *
  3. * raylib-extras [ImGui] example - Simple Integration
  4. *
  5. * This is a simple ImGui Integration
  6. * It is done using C++ but with C style code
  7. * It can be done in C as well if you use the C ImGui wrapper
  8. * https://github.com/cimgui/cimgui
  9. *
  10. * Copyright (c) 2021 Jeffery Myers
  11. *
  12. ********************************************************************************************/
  13. #include "raylib.h"
  14. #include "raymath.h"
  15. #include "imgui.h"
  16. #include "rlImGui.h"
  17. int main(int argc, char* argv[])
  18. {
  19. // Initialization
  20. //--------------------------------------------------------------------------------------
  21. int screenWidth = 1280;
  22. int screenHeight = 800;
  23. SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE);
  24. InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - simple ImGui Demo");
  25. SetTargetFPS(144);
  26. rlImGuiSetup(true);
  27. // Main game loop
  28. while (!WindowShouldClose()) // Detect window close button or ESC key
  29. {
  30. BeginDrawing();
  31. ClearBackground(DARKGRAY);
  32. // start ImGui Conent
  33. rlImGuiBegin();
  34. // show ImGui Content
  35. bool open = true;
  36. ImGui::ShowDemoWindow(&open);
  37. // end ImGui Content
  38. rlImGuiEnd();
  39. EndDrawing();
  40. //----------------------------------------------------------------------------------
  41. }
  42. rlImGuiShutdown();
  43. // De-Initialization
  44. //--------------------------------------------------------------------------------------
  45. CloseWindow(); // Close window and OpenGL context
  46. //--------------------------------------------------------------------------------------
  47. return 0;
  48. }