Commits

Javier Aravena committed 5070726

Updated to sfml 1.99

Comments (0)

Files changed (8)

     sf::Event event;
 
     while(running) {
-        clock.Restart();
-        while(window->PollEvent(event)) {
+        clock.restart();
+        while(window->pollEvent(event)) {
             OnEvent(event);
         }
 
         OnLoop();
         OnRender();
-        frameTime = clock.GetElapsedTime().AsSeconds();
+        frameTime = clock.getElapsedTime().asSeconds();
     }
 
     OnCleanup();

CApp_OnCleanup.cc

 
 void CApp::OnCleanup()
 {
-    window->Close();
+    window->close();
 }
 
 void CApp::OnEvent(sf::Event & event)
 {
-    switch(event.Type) {
+    switch(event.type) {
         case sf::Event::Closed:
             running = false;
             break;
         case sf::Event::KeyPressed:
-            OnKeyPress(event.Key);
+            OnKeyPress(event.key);
             break;
         case sf::Event::Resized:
-            glViewport(0, 0, event.Size.Width, event.Size.Height);
+            glViewport(0, 0, event.size.width, event.size.height);
             glMatrixMode(GL_PROJECTION);
             glLoadIdentity();
-            gluPerspective(90, event.Size.Width/event.Size.Height, 0.1, 1000);
+            gluPerspective(90, event.size.width/event.size.height, 0.1, 1000);
             glMatrixMode(GL_MODELVIEW);
             glEnable(GL_TEXTURE_2D);
             break;
 }
 
 void CApp::OnKeyPress(sf::Event::KeyEvent key) {
-    switch(key.Code){
+    switch(key.code){
         case sf::Keyboard::Escape:
         case sf::Keyboard::Q:
             running = false;
     //const int height=600;
     //sf::VideoMode videoMode(width, height, 32);
 
-    sf::VideoMode videoMode = sf::VideoMode::GetDesktopMode();
-    int width = videoMode.Width;
-    int height = videoMode.Height;
+    sf::VideoMode videoMode = sf::VideoMode::getDesktopMode();
+    int width = videoMode.width;
+    int height = videoMode.height;
 
 
-    if(!videoMode.IsValid()) {
+    if(!videoMode.isValid()) {
         std::cerr << "Invalid video mode" << std::endl;
         return false;
     }
 
 void CApp::OnLoop()
 {
-    sf::Vector2i position(sf::Mouse::GetPosition(*window));
+    sf::Vector2i position(sf::Mouse::getPosition(*window));
     for(IEntity * entity : entities) {
         entity->OnLoop(frameTime, position.x, position.y);
     }

CApp_OnPicking.cc

 
 void CApp::OnPicking()
 {
-    sf::Vector2i position(sf::Mouse::GetPosition(*window));
+    sf::Vector2i position(sf::Mouse::getPosition(*window));
 
     glLoadIdentity();
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     }
 
     glReadBuffer(GL_BACK);
-    glReadPixels(position.x, window->GetHeight() - position.y, 1, 1, GL_RGB, GL_FLOAT, pickedColour);
+    glReadPixels(position.x, window->getSize().y - position.y, 1, 1, GL_RGB, GL_FLOAT, pickedColour);
 
     glEnable(GL_TEXTURE_2D);
     glEnable(GL_LIGHTING);
         glPopMatrix();
     }
 
-    window->Display();
+    window->display();
 
 }
 
 bool Cube::OnEvent(sf::Event & event)
 {
-    switch(event.Type) {
+    switch(event.type) {
         case sf::Event::MouseButtonPressed:
-            previous_y = original_y = event.MouseButton.Y;
-            previous_x = original_x = event.MouseButton.X;
+            previous_y = original_y = event.mouseButton.y;
+            previous_x = original_x = event.mouseButton.x;
             //Clicked on the background
             if(pickedColour[0] == 0.f && pickedColour[1] == 0.f && pickedColour[2] == 0.f) {
-                if(event.MouseButton.Button == sf::Mouse::Right) {
+                if(event.mouseButton.button == sf::Mouse::Right) {
                     dragStatus = MOVE_XZ;
                 }
             }
             dragStatus = NO_DRAG;
             break;
         case sf::Event::KeyPressed:
-            if(dragStatus==MOVE_XZ && event.Key.Code == sf::Keyboard::Z){
+            if(dragStatus==MOVE_XZ && event.key.code == sf::Keyboard::Z){
                 dragStatus = MOVE_Y;
             }
-            else if(dragStatus == NO_DRAG && event.Key.Code == sf::Keyboard::R) {
+            else if(dragStatus == NO_DRAG && event.key.code == sf::Keyboard::R) {
                 translate_x = 0;
                 translate_y = 0;
                 translate_z = 0;
                 angle_z = 0;
                 scale = 1;
             }
-            else if(dragStatus == NO_DRAG && event.Key.Code == sf::Keyboard::W) {
+            else if(dragStatus == NO_DRAG && event.key.code == sf::Keyboard::W) {
                 std::cout << "Saving Settings..." << std::endl;
                 saveSettings();
             }
             break;
         case sf::Event::KeyReleased:
-            if(dragStatus == MOVE_Y && event.Key.Code == sf::Keyboard::Z)
+            if(dragStatus == MOVE_Y && event.key.code == sf::Keyboard::Z)
                 dragStatus = MOVE_XZ;
             break;
         case sf::Event::MouseWheelMoved:
-            scale = scale + 0.01*event.MouseWheel.Delta;
+            scale = scale + 0.01*event.mouseWheel.delta;
             break;
         default:
             break;