helloworld.cpp 1.2 KB

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