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.


Messages - gardnerj

Pages: [1]
1
Graphics / sf::View not working in latest SFML 2 revision?
« on: April 19, 2010, 04:21:54 pm »
Excellent!  That solved all the problems in my code.

2
Graphics / sf::View not working in latest SFML 2 revision?
« on: April 19, 2010, 03:26:13 am »
sf::View isn't working right for me since the latest revision(1509) (I assume due to the sf::Rect definition change).  For example, in the code below I would expect that I am defining a view starting at x,y = 1,1 with width,height = 2,2 so that that the square starting at 1,1 with width,height = 2,2 should fill the screen. Instead it fills the bottom right part only.  SetViewport has similar problems.


Code: [Select]

#include <SFML/Graphics.hpp>

int main(){
  sf::RenderWindow app;
  app.Create(sf::VideoMode(500, 500, 32), "");

  sf::View view(sf::FloatRect(1, 1, 2, 2));
  app.SetView(view);

  sf::Shape rect = sf::Shape::Rectangle(1, 1, 2, 2, sf::Color(250,0,0));

  while (app.IsOpened()){
    sf::Event event;
    while (app.GetEvent(event)){
      if (event.Type == sf::Event::Closed) app.Close();
    }

    app.Clear();
    app.Draw(rect);
    app.Display();
  }

  return EXIT_SUCCESS;
}

3
Graphics / SFML 2.0 RenderImage problem
« on: February 02, 2010, 05:05:46 pm »
Thanks!  That was fast.  Just verifying that I downloaded the sfml 2 branch just now and the fix works for me too.

4
Graphics / SFML 2.0 RenderImage problem
« on: February 02, 2010, 05:30:03 am »
In this sample code below alternating red and blue squares should be shown when space is pressed, but the red square is not displayed.  This is using the SFML 2.0 branch version from Jan. 27.  This problem doesn't occur if either the first buffer.Draw(sprite) in the code is commented or the second is uncommented.  Also, it works for an older version from Dec. 17.  (compiled using MinGW/Codeblocks in Windows XP)


Code: [Select]

#include <SFML/Graphics.hpp>
int main(){
  sf::RenderWindow window(sf::VideoMode(640, 480, 32), "");

  sf::RenderImage buffer;
  buffer.Create(640, 480);
  sf::Sprite bufsprite;
  bufsprite.SetImage(buffer.GetImage());

  sf::Image image; image.Create(1, 1);
  sf::Sprite sprite(image);

  int mode = 0;
  while (window.IsOpened()){
    sf::Event event;
    while (window.GetEvent(event)){
      if (event.Type == sf::Event::KeyPressed){
        if (event.Key.Code == sf::Key::Escape) window.Close();
        else if (event.Key.Code == sf::Key::Space) mode = 1-mode;
      }
    }

    buffer.Clear();
    if (mode == 0){
      buffer.Draw(sprite);
      buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(0,0,255)));
    }else{
      //buffer.Draw(sprite);
      buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(255,0,0)));
    }

    buffer.Display();
    window.Draw(bufsprite);
    window.Display();
  }

  return EXIT_SUCCESS;
}

Pages: [1]
anything