Advertisement
Guest User

Untitled

a guest
Jan 13th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. /*
  2.  * Copyright 2011-2013 Branimir Karadzic. All rights reserved.
  3.  * License: http://www.opensource.org/licenses/BSD-2-Clause
  4.  */
  5.  
  6. #include "common.h"
  7. #include <glm\glm.hpp>
  8.  
  9. #include <bgfx.h>
  10. #include "entry/entry.h"
  11. #include <GLFW\glfw3.h>
  12. #include <bgfxplatform.h>
  13. int _main_(int /*_argc*/, char** /*_argv*/)
  14. {
  15.     uint32_t width = 1280;
  16.     uint32_t height = 720;
  17.     uint32_t debug = BGFX_DEBUG_TEXT;
  18.     uint32_t reset = BGFX_RESET_VSYNC;
  19.  
  20.     GLFWwindow* window;
  21.  
  22.     if (!glfwInit())
  23.         return -1;
  24.  
  25.     /* Create a windowed mode window and its OpenGL context */
  26.     window = glfwCreateWindow(width, height, "Hello World", NULL, NULL);
  27.     if (!window)
  28.     {
  29.         glfwTerminate();
  30.         return -1;
  31.     }
  32.  
  33.     bgfx::glfwSetWindow(window);
  34.  
  35.     bgfx::init();
  36.     bgfx::reset(width, height, reset);
  37.  
  38.     // Enable debug text.
  39.     bgfx::setDebug(debug);
  40.  
  41.     // Set view 0 clear state.
  42.     bgfx::setViewClear(0
  43.         , BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
  44.         , 0x303030ff
  45.         , 1.0f
  46.         , 0
  47.         );
  48.  
  49.     glfwMakeContextCurrent(window);
  50.     while (!entry::processEvents(width, height, debug, reset) )
  51.     {
  52.         // Set view 0 default viewport.
  53.         bgfx::setViewRect(0, 0, 0, width, height);
  54.  
  55.         // This dummy draw call is here to make sure that view 0 is cleared
  56.         // if no other draw calls are submitted to view 0.
  57.         bgfx::submit(0);
  58.  
  59.         // Use debug font to print information about this example.
  60.         bgfx::dbgTextClear();
  61.         bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
  62.         bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
  63.  
  64.         // Advance to next frame. Rendering thread will be kicked to
  65.         // process submitted rendering primitives.
  66.  
  67.         bgfx::frame();
  68.     }
  69.  
  70.     // Shutdown bgfx.
  71.     bgfx::shutdown();
  72.  
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement