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

Pages: [1] 2
1
General discussions / Re: Unofficial Nightly Builds
« on: January 10, 2013, 06:22:05 am »
When will the maintenance end?

2
System / Re: [2.0] sf::Thread and sf::RenderWindow::pollEvent()
« on: January 10, 2013, 04:07:15 am »
Thanks.

3
System / [2.0] sf::Thread and sf::RenderWindow::pollEvent()
« on: January 08, 2013, 06:47:03 am »
Is it possible to utilize a thread mainly for handling the close button of the application window? My current code doesn't seem to work. The window just freezes as if I wasn't checking for events, although the thread is running.

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

sf::RenderWindow appWindow( sf::VideoMode( 800,600 ),"Fox" );

void AppEvents()
{
    while( appWindow.isOpen() )
    {
        sf::Event event;
        while( appWindow.pollEvent( event ) )
        {
            if ( event.type == sf::Event::Closed )
                appWindow.close();
        }
    }
}

int main(int argc, char* argv[])
{
    //Player player;
    //Room room("res/rooms/MainMenu/room.xml");
    sf::Thread appEvents(&AppEvents);
    appEvents.launch();
    appEvents.wait();
    return EXIT_SUCCESS;
}

Any body have an idea why that might be?

4
General / Re: Trouble at Runtime
« on: December 23, 2012, 11:04:08 pm »
I forgot that it's still just an RC.

EDIT: I got it to work with the latest nightly build under GCC 4.7.1. Thank you for the link.

5
General / Re: Trouble at Runtime
« on: December 23, 2012, 10:57:21 pm »
Hmm. I have 4.7.1. I'll recompile it. Strange, this is the version that came with the newest version of Code::Blocks. Maybe you should update your CB download to support this.

6
General / Re: Trouble at Runtime
« on: December 23, 2012, 10:49:31 pm »
I was following the tutorial, like I said, which is why I didn't provide code.

copied/pasted from the tutorial page:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Sorry about the confusion.

EDIT: I just found something interesting. The documentation states that there are only three arguments (width, height, bpp) for VideoMode, but when I do
sf::VideoMode(200,200,32)
it comes up with
#0 6E182B85     sf::VideoMode::VideoMode(this=0xc8, modeWidth=200, modeHeight=32, modeBitsPerPixel=2)

The "this=0xc8" part worries me.

7
General / Trouble at Runtime
« on: December 23, 2012, 09:42:53 pm »
Hi. I've followed your tutorial for SFML-2.0 RC with Code::Blocks. I get this segmentation fault:
#0 6E182B85     sf::VideoMode::VideoMode(this=0xc8, modeWidth=200, modeHeight=32, modeBitsPerPixel=2) (D:\developpement\sfml-master\src\SFML\Window\VideoMode.cpp:50)
#1 00401418     main(argc=1, argv=0x372d80) (C:\Users\Nicolas\Documents\Projects\Fox 3\main.cpp:5)
 

I found that this issue was already reported here (http://en.sfml-dev.org/forums/index.php?topic=9598.0) with no answer. Does anybody have any idea on how to fix this?

I'm on an AMD Radeon HD 6850 if that helps.

8
Graphics / Re: Extra pixels drawn
« on: December 07, 2012, 03:04:51 am »
Thanks

9
Graphics / Extra pixels drawn
« on: December 06, 2012, 03:43:57 am »
When I try drawing anything (SFML-1.6) via sf::RenderWindow::Draw() it semi-randomly comes up with extra pixels over the image that I loaded.

Example:


This occurs for most images I try. I have a feeling SFML adds some sort of effect or blur to images when they are drawn. Else, what should I do to fix it?

10
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: December 04, 2012, 04:43:21 am »
Maybe I should. Good idea.

11
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: October 20, 2012, 04:46:44 am »
Alright! Thank you! I was planning on doing that anyway, but I didn't realize I had to.

12
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: October 18, 2012, 06:49:46 am »
Woops. I guess I should have read that first.

Anyway, here's a simple example I whipped up quickly. This should be a bit easier to read.

#include <SFML/Graphics.hpp>
#include <string>
#include <list>

struct ComplexImage
{
    sf::Image img;
    std::string file;
};

std::list<ComplexImage> buffer_image;

sf::Image GetImage( std::string filename )
{
    std::list<ComplexImage>::iterator i = buffer_image.begin();
    bool varfound = false;
    while( i != buffer_image.end() )
    {
        if( i->file == filename )
        {
            varfound = true;
            return i->img;
        }
        else ++i;
    }
    if( varfound == false )
    {
        //create new image
        ComplexImage new_image;
        new_image.img.LoadFromFile( filename.c_str() );
        new_image.file = filename;

        buffer_image.push_back( new_image );
        return GetImage( filename );
    }
}

int main( int argc, char* argv[] )
{
    sf::RenderWindow game( sf::VideoMode( 800, 600, 32 ), "App Title" );
    sf::Event event;

    sf::Sprite test_sprite;
    test_sprite.SetImage( GetImage( "ball.png" ) );
    test_sprite.SetPosition( 40, 40 );

    while( game.IsOpened() )
    {
        while( game.GetEvent( event ) )
        {
            //if window is closed or Escape key is pressed, close the game
            if( event.Type == sf::Event::Closed or ( event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Escape ) ) game.Close();
        }

        //clear display
        game.Clear( sf::Color( 100, 149, 237 ) );

        //draw sprite
        game.Draw( test_sprite );

        //update display
        game.Display();
    }

    return EXIT_SUCCESS;
}

13
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: October 17, 2012, 05:18:06 am »
Here's a modified copy of my code in a Code::Blocks project. It requires SFML 1.6.

https://sites.google.com/a/redthegreen.com/files/Flow-Dev.zip?attredirects=0&d=1

There's also a new issue of crashing that only occurs when compiling under Release. If you compile under Debug, it won't crash. Keep that in mind when testing.

14
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: October 16, 2012, 02:47:39 am »
That's something I wasn't really thinking about. I'll keep it in mind from now on.

That's now fixed, but it's still failing. Even if I use a globally-declared image, it fails.

15
Graphics / Re: Incompatibility with sf::Image and stl::list??
« on: October 15, 2012, 05:50:45 am »
Animation class
class Animation
{
    sf::Image img;
    std::list<AnimationFrame> frames;
    AnimationFrame currentFrame;
    void CheckFrames();

    public:
    void LoadFromFile( std::string filename );
    void SetPos( float x, float y );
    sf::Sprite Output();
};

Function to load image
void Animation::LoadFromFile( std::string filename )
{
    XMLDocument file;
    file.LoadFile( filename.c_str() );
    XMLElement* root = file.RootElement();
    img.LoadFromFile( root->Attribute( "image" ) );
    int w, h;
    w = root->IntAttribute( "w" );
    h = root->IntAttribute( "h" );
}
 

Function to store in list
void BuildMapFromFile( std::string filename )
{
    XMLDocument file;
    file.LoadFile( filename.c_str() );
    XMLElement* root = file.RootElement();

    //obj_animation
    for( XMLElement* animation = root->FirstChildElement( "animation" ); animation; animation = animation->NextSiblingElement( "animation" ) )
    {
        //object
        object new_object;
        new_object.type = "animation";
        int depth = animation->IntAttribute( "depth" );
        new_object.depth = depth;
       
        new_object._animation.LoadFromFile( animation->Attribute( "source" ) ); //loads image
        new_object._animation.SetPos( animation->IntAttribute( "x" ), animation->IntAttribute( "y" ) );

        std::list<object>::iterator i = q_object.begin();
        bool varadded = false;
        while( i != q_object.end() )
        {
            if( i->depth > depth )
            {
                q_object.insert( i, new_object );
                varadded = true;
                i = q_object.end();
            }
            else ++i;
        }
        if( varadded == false ) q_object.push_back( new_object );
    }
}

The animation class loads its own image, which is kept inside the class (not the best idea, I know). The class itself is moved into the list.

EDIT: I just tried setting the sprites to a globally-declared image, and it failed as well.

Pages: [1] 2
anything