Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include "core.h"
  2.  
  3. class Window_Render {
  4. private:
  5.     sf::RenderWindow window;
  6.     int fps, c_bit_deph;
  7.     int w_wight, w_height;
  8.     bool v_sync;
  9.     std::string w_title;
  10.  
  11. public:
  12.     Window_Render(int w, int h, bool v, std::string title);
  13.     ~Window_Render();
  14.  
  15.     void window_add()
  16.     {
  17.         window.create(sf::VideoMode(w_wight, w_height, c_bit_deph), w_title);
  18.         window.setFramerateLimit(fps);
  19.         window.setVerticalSyncEnabled(v_sync);
  20.     }
  21.  
  22.     void loop()
  23.     {
  24.         fm_load();
  25.  
  26.         while (window.isOpen())
  27.         {
  28.             sf::Event zdarzenie;
  29.             while (window.pollEvent(zdarzenie))
  30.             {
  31.                 if (zdarzenie.type == sf::Event::KeyPressed && zdarzenie.key.code == sf::Keyboard::Escape)
  32.                 {
  33.                     window.close();
  34.                 }
  35.             }
  36.  
  37.             window.display();
  38.         }
  39.     }
  40. };
  41.  
  42. Window_Render::Window_Render(int w, int h, bool v, std::string title)
  43.     :fps(60), c_bit_deph(32), w_wight(w), w_height(h), v_sync(v), w_title(title)
  44. {
  45.     std::cout << "Tworzenie RENDER WINDOW" << std::endl;
  46. }
  47.  
  48. //Wczytywanie ustawień
  49. void inplementacja()
  50. {
  51.     typedef boost::property_tree::ptree boost_ptree;
  52.  
  53.     boost_ptree tree;
  54.     boost :: property_tree::read_json("conf.json", tree);
  55.  
  56.     Window_Render r_window(tree.get<int>("w"), tree.get<int>("h"), tree.get<bool>("v_sync"), "SFML Render TEST");
  57. }
  58.  
  59.  
  60. Window_Render::~Window_Render()
  61. {
  62.     std::cout << "Destrukcja RENDER WINDOW" << std::endl;
  63.     fps = NULL;
  64.     c_bit_deph = NULL;
  65.     w_wight = NULL;
  66.     w_height = NULL;
  67.     v_sync = NULL;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement