helloworld.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // Now init for real example.
  17. bgfx::init();
  18. bgfx::reset(width, height);
  19. // Enable debug text.
  20. bgfx::setDebug(debug);
  21. // Set view 0 clear state.
  22. bgfx::setViewClear(0
  23. , BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
  24. , 0x303030ff
  25. , 1.0f
  26. , 0
  27. );
  28. while (!processEvents(width, height, debug, reset) )
  29. {
  30. // Set view 0 default viewport.
  31. bgfx::setViewRect(0, 0, 0, width, height);
  32. // This dummy draw call is here to make sure that view 0 is cleared
  33. // if no other draw calls are submitted to view 0.
  34. bgfx::submit(0);
  35. // Use debug font to print information about this example.
  36. bgfx::dbgTextClear();
  37. bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
  38. bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
  39. // Advance to next frame. Rendering thread will be kicked to
  40. // process submitted rendering primitives.
  41. bgfx::frame();
  42. }
  43. // Shutdown bgfx.
  44. bgfx::shutdown();
  45. return 0;
  46. }