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

Pages: [1]
1
Graphics / difference between a Sprite and a Shape.
« on: May 16, 2013, 05:57:08 pm »
I everyone,
another noob question from vams :
What's the difference between a Sprite and a Shape with an attached texture?
More precisely, what are Sprite needed for if I can just put the same texture on a rectangular shape?


2
Graphics / Re: Plot widget
« on: May 16, 2013, 04:25:47 pm »
That's what I was looking for, thanks!
Now I can create my widget plot class, just joining together a vertexarray class, some sort of abstract function class and a method to draw.

3
Graphics / Plot widget
« on: May 16, 2013, 03:05:41 pm »
Hi,
There's a fast way to implement a widget that plot a function?
I'd like to use it to keep track of some quantities in a game.

Thanks in advance!

4
Graphics / [SOLVED] Re: Button class help
« on: May 14, 2013, 05:39:55 pm »
Ok i got the problem by copying here the code.
As it is here works but i had
while(window.isOpen()){
        while(window.pollEvent(event)){
            if (event.type == Event::Closed) window.close();
            button.processEvent(window,event);
                        if (button.active) {
                         
                         
        }
    window.clear(Color::Black);
    cout << "button active " << endl; //some sort of output
    button.reset() //optional, get the button possible to be re-activated
    window.display();
    }
}

with the "cout " outside the pollEvent loop

5
Graphics / Button class help
« on: May 14, 2013, 05:27:47 pm »
Hi,
I want to create a button that "activates" has he get clicked on.
Here's the algorirm-implementing function of the class :

void reset(){activated = false;}

bool Button::isMouseHere(Window& window){
        double mouse_pos_x = Mouse::getPosition(window).x;
        double mouse_pos_y = Mouse::getPosition(window).y;

        return getGlobalBounds().contains(Vector2f(mouse_pos_x,mouse_pos_y));
}
bool Button::isClicked(Window& window){
        return (isMouseHere(window) && Mouse::isButtonPressed(Mouse::Left));
}

void Button::processEvent(const Event& event,Window& window) {
        if (isClicked(window)){
                if (!old_state) {
                        old_state = true;
                        changed++;
                }
        }
        else if (old_state) {
                changed++;
                old_state = false;
        }

        if (changed > 1) {
                activated = true;
                changed = 0;
        }
}
 

And here's the code in which it's used

while(window.isOpen()){
                while(window.pollEvent(event)){
                        if (event.type == Event::Closed) window.close();
                        button.processEvent(window,event);
                        if (button.active) {
                          cout << "button active " << endl; //some sort of output
                          button.reset() //optional, get the button possible to be re-activated
                }
        window.clear(Color::Black);
       
        window.display();
        }
}
 

Button reacts this way:
1) as you click in is area (and keep the button pressed) he doesn't anything (right)
2) as you release the button it starts yelling "button activated" (wrong, should just once)
3) as you leave his area with mouse the button stop yelling.
4) you can repeat steps 1,2,3 as many time u want.

Any ideas?

6
Graphics / Re: graphics module needs libglew 1.5, i have newer.
« on: May 13, 2013, 02:31:13 am »
Thank you guys!

First time ever i post something for help in linux -> solved in 1 hour -> faith in humanity restored :)


7
Graphics / Re: graphics module needs libglew 1.5, i have newer.
« on: May 13, 2013, 01:50:36 am »
Ok, forgive me for the upcoming question but actually I'm quite new with linux systems.
In order to "build" SFML i can simply following this tutorial, right ? http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php
Before following that tutorial, do I have to remove, and how, the actual installation of SFML libraries? (May I simply remove all the libsfml-xxx and headers i've manually installed? )


8
When i try to compile this simple code (taken from a tutorial) :
#include <SFML/Graphics.hpp>

int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        // window.draw(...);

        // end the current frame
        window.display();
    }

    return 0;
}

I create the .o , called refwindow.o and  I use this command in linking :

g++ refwindow.o -L/usr/lib/x86_64-linux-gnu/ -ljpeg -lGLEW -lsfml-graphics -lsfml-window -lsfml-system -o refwindow.x
 

But i get this :
/usr/bin/ld: warning: libGLEW.so.1.5, needed by /usr/local/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libjpeg.so.62, needed by /usr/local/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)

Well, i searched for those libraries in the /usr/lib/x86_64-linux-gnu/ directory and it turns out I have different version for both:
version 1.8 for glew and .8 for jpeg.

I've tried to apt-get install libglew1.5 but it says i've already have a newer version.
What should i do?
May I get to work SFML with these different versions or can I install in some way the needed versions?
Should the latter be the way, is it possible to mantain both versions for a particular library? The reason is that I have to work with CUDA on my pc and It was quite tricky to get the compiler to work. I'd prefer to change the least possible since I'm afraid to break the unknown reason for why the CUDA compiler works at the moment :)


Additional info:
os : ubuntu 13.04
gcc version = 4.7.x (don't remember which x)
sml libraries version = 2.0

The installation of SFML was a little messy: i've tried also to install 1.6 version before succeding. But i'm quite sure all of the 1.6 libraries are gone now, since i can't find them anymore with "locate" command.

I've installed it following these instructions (tutorial SMFL and linux, version2.0) :
"Finally, option 2 is a good compromise for a quick installation if SFML is not available as an official package. Download the SDK from the download page, unpack it and copy the files to your preferred location: either a separate path in your personal folder (like /home/me/sfml), or a standard path (like /usr/local). "

Pages: [1]