helloworld.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2011-2014 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #include "common.h"
  6. #include <bgfx.h>
  7. #include "entry/entry.h"
  8. int _main_(int /*_argc*/, char** /*_argv*/)
  9. {
  10. uint32_t width = 1280;
  11. uint32_t height = 720;
  12. uint32_t debug = BGFX_DEBUG_TEXT;
  13. uint32_t reset = BGFX_RESET_VSYNC;
  14. bgfx::init();
  15. bgfx::reset(width, height, reset);
  16. // Enable debug text.
  17. bgfx::setDebug(debug);
  18. // Set view 0 clear state.
  19. bgfx::setViewClear(0
  20. , BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
  21. , 0x303030ff
  22. , 1.0f
  23. , 0
  24. );
  25. while (!entry::processEvents(width, height, debug, reset) )
  26. {
  27. // Set view 0 default viewport.
  28. bgfx::setViewRect(0, 0, 0, width, height);
  29. // This dummy draw call is here to make sure that view 0 is cleared
  30. // if no other draw calls are submitted to view 0.
  31. bgfx::submit(0);
  32. // Use debug font to print information about this example.
  33. bgfx::dbgTextClear();
  34. bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
  35. bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
  36. // Advance to next frame. Rendering thread will be kicked to
  37. // process submitted rendering primitives.
  38. bgfx::frame();
  39. }
  40. // Shutdown bgfx.
  41. bgfx::shutdown();
  42. return 0;
  43. }