helloworld.cpp 1.3 KB

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