Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Insentience

Pages: [1]
1
Graphics / Is it possible to 'lower' sprite LOD before drawing
« on: May 18, 2014, 09:03:59 pm »
Disclaimer: I don't really know what I'm talking about

When I zoom my sf::View outwards, more sprites are drawn and subsequently the fps drops like an anvil. Is it possible for me to set my sprites to draw at a 'lower' level of detail, speeding up the process of drawing everything?

Thanks

EDIT: Would mipmapping be the only solution?

2
General / My timestep code isn't working, completely baffled
« on: April 15, 2014, 06:53:36 pm »
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>

static const int FRAME_LIMIT = 120;

bool WINDOW_FOCUS = true;

const sf::Time TICK_INTERVAL = sf::seconds(1.0f / FRAME_LIMIT);

int main()
{
    // Create the main rendering window
    sf::RenderWindow window(sf::VideoMode(768, 768), "SFML works!");
    sf::RectangleShape Rectangle;

    Rectangle.setSize(sf::Vector2f(300, 300));
    Rectangle.setPosition(150, 150);
    Rectangle.setFillColor(sf::Color::Blue);
    Rectangle.setOutlineThickness(1.0f);
    Rectangle.setOutlineColor(sf::Color::White);

    sf::Clock clock;
    sf::Time accumulatedTime;

    clock.restart();

    //Yes, I've tried commenting out the following line. Nothing changed
    window.setFramerateLimit(FRAME_LIMIT);
   
    //LOOP UNTIL YOU DONT WANT IT TO
    while (window.isOpen())
    {
       
      //WINDOW EVENTS (ignore this)
      sf::Event event;
      while (window.pollEvent(event))
      {
        if (event.type == sf::Event::Closed)
          window.close();
      }
     
      //TIME CALCULATIONS
      accumulatedTime += clock.restart();//.asMilliseconds();
     
      //PHYSICS CODE
      while(accumulatedTime >= TICK_INTERVAL)
      {
        accumulatedTime -= TICK_INTERVAL;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
        {
          // left key is pressed: move our character
          Rectangle.move(-0.1f, 0);
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
        {
          Rectangle.move(0.1f, 0);
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
        {
          // left key is pressed: move our character
          Rectangle.move(0, -0.1f);
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
        {
          Rectangle.move(0, 0.1f);
        }
      }
     
      //DRAWING
      window.clear();
      window.draw(Rectangle);
      window.display();
    }

    return EXIT_SUCCESS;
}
 

With this code, the rectangle's movements are very choppy. I really don't know what I'm doing wrong. I tried the other way (multiplying rectangle move value by deltaTime) and the movement was awesome! Smooth! Pleasant to look at! However, multiplying by deltaTime all the time is tedious and annoying.

I would love some help.

Pages: [1]
anything