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 - metulburr

Pages: 1 2 [3] 4
31
Network / Re: downloading image for sfml resource use
« on: November 12, 2013, 08:29:06 pm »
OK now though the image is not able to open. It doenst save the image as expected? Is there something else missing that is stopping this?

32
Network / Re: downloading image for sfml resource use
« on: November 12, 2013, 03:11:48 pm »
omg, that was a stupid mistake

thank you

33
Network / Re: downloading image for sfml resource use
« on: November 12, 2013, 01:04:23 pm »
oh whoops sorry.

The error i get is:
Code: [Select]
/tmp/ccRlWxMK.o: In function `main':
test2.cpp:(.text+0x5f): undefined reference to `sf::Http::Http()'
test2.cpp:(.text+0xae): undefined reference to `sf::Http::Request::Request(std::string const&, sf::Http::Request::Method, std::string const&)'
test2.cpp:(.text+0xf0): undefined reference to `sf::Http::sendRequest(sf::Http::Request const&, sf::Time)'
test2.cpp:(.text+0xff): undefined reference to `sf::Http::Response::getBody() const'
/tmp/ccRlWxMK.o: In function `sf::TcpSocket::~TcpSocket()':
test2.cpp:(.text._ZN2sf9TcpSocketD2Ev[_ZN2sf9TcpSocketD5Ev]+0x2f): undefined reference to `sf::Socket::~Socket()'
/tmp/ccRlWxMK.o:(.rodata._ZTIN2sf9TcpSocketE[_ZTIN2sf9TcpSocketE]+0x10): undefined reference to `typeinfo for sf::Socket'
collect2: error: ld returned 1 exit status

34
Network / downloading image for sfml resource use
« on: November 12, 2013, 05:19:17 am »
I havent dabbed at all yet into network of sfml yet. My overall goal was to make a function in which could download an image for me so that i could use it as a sprite. I skimmed the network docs but i dont see such related exactly to it. I pieced together code from what i found on these forums. However the object http was not mentioned in the thread as to what is was. So i guessed as if it was sf::Http. However when doing that though i get errors. I am not sure what exactly is wrong? What am i missing?

#include <SFML/Network.hpp>
#include <fstream>

int main(){
    std::string url = "http://s1297.photobucket.com/user/metulburr/media/walker_zpsbd2d34be.png.html";
    sf::Http http;
    sf::Http::Request req(url);
    sf::Http::Response image_res = http.sendRequest(req);

    std::string body = image_res.getBody();
    std::ofstream file;
    file.open("tux.png", std::ios::binary);
    file.write(body.c_str(), body.size());
    file.close();
}

the thread i am talking about is:
http://en.sfml-dev.org/forums/index.php?topic=8160.0

35
General / Re: window has no member draw error
« 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


36
General / 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);
                        ^


 



37
General / odd error when compiling sfml
« on: November 08, 2013, 04:06:47 am »
history:
It was not 3 hours ago i was going through a tutorial on sfml and compiling it fine, then got an error saying directory was not there. Throughout the process, i had trouble with g++, so i purged g++ from my ubuntu and reinstalled.

I also reinstalled some pre-reqs, but i still get the same error:
sudo apt-get install libpthread-stubs0-dev libgl1-mesa-dev  libx11-dev libxrandr-dev libfreetype6-dev libglew1.5-dev libjpeg8-dev libsndfile1-dev libopenal-dev cmake
 

after reinstalling i now get this error:

libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
 

after putting in that argument i get this error:
g++: error: LIBGL_DEBUG=verbose: No such file or directory

I am not really sure where to go after this. I have spent the better part of tonight messing with the error i had with g++, and now that i have that working well, i seem to be stuck yet again at sfml. I am not really sure what intially sparked the problem in the first place as i was just compiling sfml between tutorials at the time, not installing, not hcanging config files, or not updating or anything. So its odd that it just seemed to happen out of thin air.


g++  -std=c++11  -Wall -o "%e" "%f" -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system &&"./%e"
sfml 2.1 on ubuntu 13.04
gcc version 4.7.3

EDIT:
i initially had g++ 4.8 earleir today, and that was working fine. But now i keep getting problems when i switch to it, thus me now having 4.7.3. I am not sure if the version differences are something or not?

38
General / Re: movement without keyboard input
« on: October 08, 2013, 07:56:24 pm »
oh im stupid, thanks

39
General / movement without keyboard input
« on: October 08, 2013, 07:25:07 pm »
in this code i tried to make a basic circle move via wasd key combo, but as soon as i start it up the circle starts moving to the left without keyboard input?

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

class Control{
    public:
        sf::RenderWindow window;
        sf::CircleShape circle;
        bool move_up, move_down, move_left, move_right;
        //int speed = 1;
       
        Control()
        : window(sf::VideoMode(600, 480), "test")
        , circle(){
            circle.setRadius(40.f);
            circle.setPosition(100.f, 100.f);
            circle.setFillColor(sf::Color::Cyan);
        }
        void run(){
            while (window.isOpen()){
                process_events();
                update();
                render();
            }
        }
        void process_events(){
            sf::Event event;
            while (window.pollEvent(event)){
                if (event.type == sf::Event::Closed){
                    window.close();
                }
                else if (event.type == sf::Event::KeyPressed){
                    handler(event.key.code, true);
                }
                else if (event.type == sf::Event::KeyReleased){
                    handler(event.key.code, false);
                }
               
            }
        }
        void handler(sf::Keyboard::Key key, bool is_pressed){
            if (key == sf::Keyboard::W)
                move_up = is_pressed;
            else if (key == sf::Keyboard::S)
                move_down = is_pressed;
            else if (key == sf::Keyboard::A)
                move_left = is_pressed;
            else if (key == sf::Keyboard::D)
                move_right = is_pressed;
        }
       
        void update(){
            sf::Vector2f movement(0.f, 0.f);
            if (move_up)
                movement.y -= 1.f;
            if (move_down)
                movement.y += 1.f;
            if (move_left)
                movement.x -= 1.f;
            if (move_right)
                movement.x += 1.f;
               
            circle.move(movement);
        }
       
        void render(){
            window.clear();
            window.draw(circle);
            window.display();
        }
   
};

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

40
General / Re: no windows pops up
« on: October 08, 2013, 05:52:58 am »
now after doing that process, i get compile errors:
test.cpp: In function ‘int main():
test.cpp:10:16: error:class sf::RenderWindow’ has no member named ‘IsOpened’
     while (App.IsOpened())
                ^
test.cpp:14:20: error:class sf::RenderWindow’ has no member named ‘GetEvent’
         while (App.GetEvent(Event))
                    ^
test.cpp:17:23: error:class sf::Event’ has no member named ‘Type’
             if (Event.Type == sf::Event::Closed)
                       ^
test.cpp:18:21: error:class sf::RenderWindow’ has no member named ‘Close’
                 App.Close();
                     ^
test.cpp:22:13: error:class sf::RenderWindow’ has no member named ‘Clear’
         App.Clear();
             ^
test.cpp:25:13: error:class sf::RenderWindow’ has no member named ‘Display’
         App.Display();
             ^
 
I changed it also from IsOpened to IsOpen as the docs say, but i get the same erros

41
General / no windows pops up
« on: October 08, 2013, 05:33:16 am »
I am not sure why a SFML windows does not appear when compiled and executed. I am on ubuntu, downloaded sfml from ubuntu repos. I am assuming ubuntu has the oldest version 1.6, but i am not sure on how to tell. I dont get any error messages when compiling, but no window appears.

I am compiling it via:
g++ -Wall -o "%e" "%f" -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
under geany's IDE

#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
   
    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear the screen (fill it with black color)
        App.Clear();

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}
 

42
General / better tutorial for SFML?
« on: August 29, 2011, 03:09:16 am »
is there anything wrong with this, it appears to be working?
Code: [Select]
#include <SFML/Graphics.hpp>


int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");

    sf::Image Image;
    if (!Image.LoadFromFile("ship.png"))
        return EXIT_FAILURE;

    sf::Sprite ship(Image);
    ship.SetColor(sf::Color(50, 50, 50, 255));
    ship.SetPosition(200.f, 100.f);
    ship.SetScale(0.f,0.f);
    ship.Rotate(0.f);


    // Start game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (window.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                window.Close();

            if(Event.Type == sf::Event::KeyPressed)
            {
                    switch(Event.Key.Code)
                    {
                    case sf::Key::A:
                        ship.SetRotation(270.f);
                        ship.Move(-5, 0);
                        break;
                    case sf::Key::W:
                        ship.SetRotation(180.f);
                        ship.Move(0,-5);
                        break;
                    case sf::Key::D:
                        ship.SetRotation(90.f);
                        ship.Move(5, 0);
                        break;
                    case sf::Key::S:
                        ship.SetRotation(0.f);
                        ship.Move(0,5);
                        break;
                    }
            }
        }
        window.Clear(sf::Color::White);

        window.Draw(ship);

        window.Display();
    }

    return EXIT_SUCCESS;
}

43
General / better tutorial for SFML?
« on: August 29, 2011, 01:16:05 am »
so whats wrong with this code? it does the same?

i was initially asking though that the front of the "image" always maintain 'W'
so if the user held S the ship goes down, the ship turns downwards, and if the user held D the ship turned right and moved right? all the times i tried the ship moves in the direction that i wanted but doesnt stop turning?
Code: [Select]
#include <SFML/Graphics.hpp>


int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");

    sf::Image Image;
    if (!Image.LoadFromFile("ship.png"))
        return EXIT_FAILURE;

    sf::Sprite ship(Image);

    ship.SetColor(sf::Color(0, 255, 255, 128));
    ship.SetPosition(200.f, 100.f);
    ship.SetScale(0.f, 0.f);
    ship.Rotate(0.f);


    // Start game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (window.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                window.Close();

            if(Event.Type == sf::Event::KeyPressed)
            {
                    switch(Event.Key.Code)
                    {
                    case sf::Key::A:
                        ship.Move(-1,0);
                        break;
                    }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::W:
                     ship.Move(0,-1);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::D:
                    ship.Move(1,0);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::S:
                    ship.Move(0,1);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::Q:
                    ship.Rotate(-1.f);
                    break;
                }
            }

            if(Event.Type == sf::Event::KeyPressed)
            {
                switch(Event.Key.Code)
                {
                case sf::Key::E:
                    ship.Rotate(1.f);
                    break;
                }
            }
        }
        window.Clear(sf::Color::White);

        window.Draw(ship);

        window.Display();
    }

    return EXIT_SUCCESS;
}

44
General / better tutorial for SFML?
« on: August 29, 2011, 12:15:08 am »
@Serapth
thank you very much, maybe i could make sense of (why things are there) with your rewritten code

45
General / better tutorial for SFML?
« on: August 29, 2011, 12:13:06 am »
@Atomical
of course i know what i am talking about...i am talking about myself not understanding the tutorials of this SFML site. besides that is the purpose of forums, is to get numerous explanations from different people (becuz people learn different ways)

Numerous C++ books explain in different ways...it took me at least 5 books just to learn console programming, but there seems to be only one tutorial for SFML. Different people word things that is understanding to some, but confusing to others. This tutorial just seems confusing the way its written.

Pages: 1 2 [3] 4
anything