Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 1.34 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <SFML/Graphics.hpp>
  2.  
  3. #include <iostream>
  4. #include <sstream>
  5. #include "bar.h"
  6. #include "keyManager.h"
  7.  
  8. int main (int argc, char** argv)
  9. {
  10.         sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Pongatron");
  11.  
  12.         App.UseVerticalSync(true);
  13.         App.SetFramerateLimit(60);
  14.         App.PreserveOpenGLStates(true);
  15.  
  16.         bool running = true;
  17.  
  18.         // Set color and depth clear value
  19.         glClearDepth(1.f);
  20.         glClearColor(0.f, 0.f, 0.f, 0.f);
  21.  
  22.         // Enable Z-buffer read and write
  23.         glEnable(GL_DEPTH_TEST);
  24.         glDepthMask(GL_TRUE);
  25.  
  26.         // Setup a perspective projection
  27.         glMatrixMode(GL_PROJECTION);
  28.         glLoadIdentity();
  29.         gluPerspective(90.f, 1.f, 1.f, 500.f);
  30.  
  31.         //sf::Font MyFont;
  32.  
  33.         //if(!MyFont.LoadFromFile("arial.ttf"))
  34.         //{
  35.         //      return -1;
  36.         //}
  37.  
  38.         sf::String fpsText("FPS", sf::Font::GetDefaultFont(), 20);
  39.         fpsText.SetColor(sf::Color(255,255,255));
  40.         fpsText.SetX(20.f);
  41.         fpsText.SetY(20.f);
  42.  
  43.         Bar bar(0.f, 0.f, 0.3f, 2.5f, -3.f);
  44.         KeyManager km;
  45.  
  46.  
  47.         while (km.is_app_running)
  48.         {
  49.                 km.check_input(&App);
  50.  
  51.                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  52.                 glMatrixMode(GL_MODELVIEW);
  53.                 glLoadIdentity();
  54.  
  55.  
  56.                 bar.render();
  57.  
  58.  
  59.                 float framerate = 1.f / App.GetFrameTime();
  60.                 //std::cout << framerate << "fps" << std::endl;
  61.                
  62.                 std::stringstream framerateText;
  63.                 framerateText << int(framerate) << " fps";
  64.  
  65.                 fpsText.SetText(framerateText.str());
  66.  
  67.                 App.Draw(fpsText);
  68.                 App.Display();
  69.         }
  70.  
  71.         return 0;
  72. }