helloworld.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2011-2013 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #include <bgfx.h>
  6. #include <bx/bx.h>
  7. #include "../common/entry.h"
  8. #include "../common/dbg.h"
  9. #include "../common/processevents.h"
  10. int _main_(int _argc, char** _argv)
  11. {
  12. uint32_t width = 1280;
  13. uint32_t height = 720;
  14. uint32_t debug = BGFX_DEBUG_TEXT;
  15. uint32_t reset = BGFX_RESET_NONE;
  16. // It's possible to call init/shutdown sequence multiple times inside
  17. // the same application if it is necessary. State created between one
  18. // init and shutdown doesn't carry over to another.
  19. bgfx::init();
  20. bgfx::shutdown();
  21. // Now init for real example.
  22. bgfx::init();
  23. bgfx::reset(width, height);
  24. // Enable debug text.
  25. bgfx::setDebug(debug);
  26. // Set view 0 clear state.
  27. bgfx::setViewClear(0
  28. , BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
  29. , 0x303030ff
  30. , 1.0f
  31. , 0
  32. );
  33. while (!processEvents(width, height, debug, reset) )
  34. {
  35. // Set view 0 default viewport.
  36. bgfx::setViewRect(0, 0, 0, width, height);
  37. // This dummy draw call is here to make sure that view 0 is cleared
  38. // if no other draw calls are submitted to view 0.
  39. bgfx::submit(0);
  40. // Use debug font to print information about this example.
  41. bgfx::dbgTextClear();
  42. bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
  43. bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
  44. // Advance to next frame. Rendering thread will be kicked to
  45. // process submitted rendering primitives.
  46. bgfx::frame();
  47. }
  48. // Shutdown bgfx.
  49. bgfx::shutdown();
  50. return 0;
  51. }