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

Author Topic: RenderImage drawing upside-down images  (Read 3377 times)

0 Members and 1 Guest are viewing this topic.

Jakman4242

  • Newbie
  • *
  • Posts: 18
    • MSN Messenger - ninjamasterjack@nctv.com
    • View Profile
    • http://www.vgcats.com/
RenderImage drawing upside-down images
« on: May 18, 2010, 04:19:19 am »
I'm not sure if this is just what happens, and I need to flip it myself, but yes.

Here's an example of my code:
Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");

    sf::Image etc;
    etc.LoadFromFile("image.png");
    etc.SetSmooth(true);
    sf::Sprite spr;
    spr.SetImage(etc);
    spr.SetPosition(0, 0);
    sf::RenderImage rim;
    rim.Create(800, 600, 0);

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Window closed
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key pressed
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }
        App.Clear(sf::Color::Blue);

        rim.Clear(sf::Color::White);
        rim.Draw(spr);

        sf::Sprite rimspr;
        rimspr.SetImage(rim.GetImage());
        App.Draw(rimspr);

        App.Display();
    }

    return EXIT_SUCCESS;
}


The image from the RenderWindow draws upside down, yet when I draw from a sprite directly from the image, it's in it's correct orientation.

It goes without saying I'm using SFML2, but using C::B with MinGW.

Of course, I can just use the FlipY() method.(which I'm doing right now) But, I'm wondering if it's necessary or if I'm forgetting and/or doing something incorrectly.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
RenderImage drawing upside-down images
« Reply #1 on: May 18, 2010, 08:26:00 am »
It's not supposed to be flipped, I'll test your code as soon as I can.

I also need to know what graphics card you have.
Laurent Gomila - SFML developer

l0ud

  • Newbie
  • *
  • Posts: 23
    • View Profile
RenderImage drawing upside-down images
« Reply #2 on: May 18, 2010, 03:58:05 pm »
I was getting the same results when I forgot to call renderImg.Display(). You have to call this method after any modifications in your RenderImage (before drawing).
Code: [Select]

        rim.Draw(spr);
        rim.Display();
        sf::Sprite rimspr;
        rimspr.SetImage(rim.GetImage());
        App.Draw(rimspr);
       

        App.Display();

Jakman4242

  • Newbie
  • *
  • Posts: 18
    • MSN Messenger - ninjamasterjack@nctv.com
    • View Profile
    • http://www.vgcats.com/
RenderImage drawing upside-down images
« Reply #3 on: May 19, 2010, 07:11:40 am »
Oh! That was it.

Thanks, then. :)

 

anything