helloworld.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2011-2015 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 <bx/uint32_t.h>
  8. #include "logo.h"
  9. int _main_(int /*_argc*/, char** /*_argv*/)
  10. {
  11. uint32_t width = 1280;
  12. uint32_t height = 720;
  13. uint32_t debug = BGFX_DEBUG_TEXT;
  14. uint32_t reset = BGFX_RESET_VSYNC;
  15. bgfx::init();
  16. bgfx::reset(width, height, reset);
  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 (!entry::processEvents(width, height, debug, reset) )
  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::dbgTextImage(bx::uint16_max(width/2/8, 20)-20
  36. , bx::uint16_max(height/2/16, 6)-6
  37. , 40
  38. , 12
  39. , s_logo
  40. , 160
  41. );
  42. bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
  43. bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
  44. // Advance to next frame. Rendering thread will be kicked to
  45. // process submitted rendering primitives.
  46. bgfx::frame();
  47. }
  48. // Shutdown bgfx.
  49. bgfx::shutdown();
  50. return 0;
  51. }