helloworld.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2011-2012 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/dbg.h"
  8. void fatalCb(bgfx::Fatal::Enum _code, const char* _str)
  9. {
  10. DBG("%x: %s", _code, _str);
  11. }
  12. int _main_(int _argc, char** _argv)
  13. {
  14. bgfx::init(fatalCb);
  15. bgfx::reset(1280, 720);
  16. // Enable debug text.
  17. bgfx::setDebug(BGFX_DEBUG_TEXT);
  18. // Set view 0 default viewport.
  19. bgfx::setViewRect(0, 0, 0, 1280, 720);
  20. // Set view 0 clear state.
  21. bgfx::setViewClear(0
  22. , BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
  23. , 0x303030ff
  24. , 1.0f
  25. , 0
  26. );
  27. while (true)
  28. {
  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. }