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

Author Topic: window has no member draw error  (Read 7581 times)

0 Members and 1 Guest are viewing this topic.

metulburr

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
window has no member draw error
« on: November 11, 2013, 08:08:51 am »
I was going through a video tutorial, and the person first shows drawing an image to the screen. However the put window.draw(image_obj) to draw to their screen...when i do the same i get an error for sf::Window has no member draw? My intentions was that is what is suppose to draw the image to screen as shown on the tutorial. The video is using sfml 2.0 and i am using 2.1.

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

class Control{
    public:
        sf::Window window;
        sf::Time time;
        sf::Clock clock;
        sf::Sprite player;
        sf::Texture texture;
       
        Control(){
            window.create(sf::VideoMode(600,400), "Title");
            window.setKeyRepeatEnabled(false);
            if(!(texture.loadFromFile("/home/metulburr/Pictures/explode.jpeg")))
                std::cout << "could not load image" << std::endl;
            player.setTexture(texture);
        }
       
        void run(){
            while (window.isOpen()){
                sf::Event event;
                while(window.pollEvent(event)){
                    if (event.type == sf::Event::Closed){
                        window.close();
                    }
                }
                window.clear(sf::Color::Black);
                window.draw(player);
                window.display();
                time = clock.restart();
            }
        }
};

int main(){
    Control app;
    app.run();
}

 

and i get the error:
est.cpp: In member function ‘void Control::run()’:
test.cpp:29:24: error: ‘class sf::Window’ has no member named ‘clear’
                 window.clear(sf::Color::Black);
                        ^
test.cpp:30:24: error: ‘class sf::Window’ has no member named ‘draw’
                 window.draw(player);
                        ^


 


OS Ubuntu 13.04, Arch Linux, Gentoo, Windows 7/8
SFML 2.1
Ati Radeon HD 6770

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: window has no member draw error
« Reply #1 on: November 11, 2013, 08:23:52 am »
sf::Window doesn't, but sf::RenderWindow does. (see http://www.sfml-dev.org/tutorials/2.1/graphics-draw.php#the-drawing-window )
PS: video tutorials are shitty.

metulburr

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: window has no member draw error
« Reply #2 on: November 11, 2013, 08:31:22 am »
wow, i read straight through that without catching the fact they had RenderWindow instead of Window.

Thanks

OS Ubuntu 13.04, Arch Linux, Gentoo, Windows 7/8
SFML 2.1
Ati Radeon HD 6770

 

anything