helloworld.cpp 1.3 KB

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