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 - The last Dodo

Pages: [1]
1
Window / Re: pollEvents never returns true
« on: July 02, 2012, 12:53:48 am »
Thank you :) Now it works :)

2
Window / pollEvents never returns true
« on: July 01, 2012, 07:01:30 pm »
Hi everyone,

I recently changed my Graphics-Class to a Singleton with a thread. Since that moment window->pollEvents(event) does not send any events.  But I can still draw in the window. :o

I code with Windows 7, Code::Blocks, MinGW, SFML2, Boost 1.48

I created a minimal example, that has exactly this behavior. This code may look a bit crappy, but I removed the irrelevant parts.

First, I haven't had the "window->setActive(true/false);", but I got an error message: "Failed to active the window's context".

main.cpp
#include <SFML/Window.hpp>

#include "Graphics.h"

int main()
{
        sGraphics->start();
        sGraphics->join();
    return 0;
}
 

Graphics.h
#ifndef GRAPHICS_H_
#define GRAPHICS_H_

#include <boost/thread.hpp>
#include <sfml/Window.hpp>
#include <sfml/Graphics/RenderWindow.hpp>

using namespace sf;

class Events;
class GraphicsState;

class Graphics {
    boost::thread thread;
    bool stillRunning;
    RenderWindow *window;
    int width, height;
    static Graphics* instance;

    Graphics();
public:
    static Graphics* getInstance();
    virtual ~Graphics();
    void run();
    void start();
    void join();
    void deinit();
    bool isStillRunning();
    void quit();
};

#define sGraphics Graphics::getInstance()

#endif /* GRAPHICS_H_ */
 

Graphics.cpp
#include <cstdio>
#include <SFML/Window.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include <exception>

#include "Graphics.h"

using namespace sf;
using namespace std;

Graphics::Graphics() {
        char title[50] = "";
        width = 800;
        height = 600;
        sprintf(title, "%s V%d.%d", "A Geek's Warfare", 0, 0);
        VideoMode videoMode(width, height, 32);
        unsigned int params = Style::Close | Style::Titlebar;
        if(false)
                params = Style::Fullscreen;
        window = new RenderWindow(videoMode, title, params);
        window->setActive(false);

        stillRunning = true;
}

Graphics* Graphics::instance = NULL;

Graphics* Graphics::getInstance() {
        if(!instance)
                instance = new Graphics();
        return instance;
}

Graphics::~Graphics() { }

void Graphics::run() {
        try {
                window->setActive(true);
                while(isStillRunning()) {
                        Event event;
                        window->clear();
                        while(window->pollEvent(event))
                                if(event.type == sf::Event::Closed) {
                                        quit();
                                }else if(event.type == sf::Event::KeyPressed) {
                                        if(event.key.code == sf::Keyboard::Escape)
                                                quit();
                                }
                        sf::Text text("Hello World!");
                        text.setCharacterSize(30);
                        text.setStyle(sf::Text::Bold);
                        text.setColor(sf::Color::Red);
                        text.setPosition(width / 2 - text.getGlobalBounds().width / 2, height / 2 - text.getGlobalBounds().height / 2);
                        window->draw(text);
                        window->display();
                        boost::this_thread::sleep(boost::posix_time::milliseconds(50));
                }
        } catch(exception& e) {

        } catch(...) {

        }
        deinit();
}

void Graphics::start() {
        thread = boost::thread(&Graphics::run, this);
}

void Graphics::join() {
        thread.join();
}

void Graphics::deinit() {
        window->close();
}

bool Graphics::isStillRunning() {
        return stillRunning;
}

void Graphics::quit() {
        stillRunning = false;
}
 

3
Audio / Problems with sf::Sound*
« on: February 23, 2012, 07:10:12 pm »
Hi, I just figured out, that OpenAL was linked with the 64bit version, the rest of my program was 32 bit. Ich changed that and now it works.
Just my Debugger does not work now, but I hope, I'll get that too.

4
Audio / Problems with sf::Sound*
« on: February 19, 2012, 09:04:14 pm »
Quote from: "Laurent"
You built the release libraries. If you test in debug mode, you must link to debug libraries.

Oh thank you. Just built them and edited my settings

Quote from: "Laurent"
Your executable needs the openal32.dll and libsndfile.dll files if it uses sfml-audio, so they must be available when it starts (either in a directory which is in the PATH environment variable, or in the executable directory).

Oh, just added to the PATH-Variable them, but... no effect...
I even restarted Eclipse.

Edit: I encountered the same problem with "window->ShowMouseCursor(false);", if that helps.
I can open the window, but as soon as this command is there, the entire program will not start anymore.

5
Audio / Problems with sf::Sound*
« on: February 19, 2012, 08:26:39 pm »
Quote from: "Laurent"
Are you sure that you really use the new SFML 2 libraries that you compiled?

Yes, the old files were in "D:\dev\sfml", the new ones are in "D:\dev\sfml2"
I changed all libraries to the new location. Because there are no "-d"- and "-s-d"-libraries, I changed that too.
Quote from: "Laurent"
You had to update your code, right?

Nope, all SFML-commands are commented out.
The one and only SFML-command is "new sf::Sound;"
Quote from: "Laurent"
And did you copy the new openal and sndfile DLLs?

I copied the "include"- and the "extlibs"-directories from the unpacked archive to "D:\dev\sfml2", if you mean that?

6
Audio / Problems with sf::Sound*
« on: February 19, 2012, 07:47:53 pm »
Hi, I downloaded SFML 2, compiled it and changed the project-settings to the new includes and libraries.... same problem...

7
Audio / Problems with sf::Sound*
« on: February 19, 2012, 06:35:26 pm »
Here you have a code, that reproduces the problem:

Code: [Select]
#include<sfml/Audio.hpp>

int main(int argc, char* argv[])
{
new sf::Sound;
return 0;
}


Same build-configuration like before.

I use Win7 64 bit, Eclipse CDT, MinGW, SFML 1.6

8
Audio / Problems with sf::Sound*
« on: February 19, 2012, 05:30:54 pm »
That's my problem. This must not happen! Neverever!

When I add "new sf::Sound();" as the first Command in my "int main(...)", this strange thing happens. The program will not start my code. It terminates before my code starts. The debugger will not come to the breakpoints.

I think, there is a problem with the compiler or the linker.
Here, I added some screenshots of my settings. Probably I did something wrong here...

http://imageshack.us/photo/my-images/535/librarypaths.png/
http://imageshack.us/photo/my-images/14/librariesu.png/
http://imageshack.us/photo/my-images/864/maing.png/

9
Audio / Problems with sf::Sound*
« on: February 19, 2012, 03:20:56 pm »
Hi everypony,

I've got a problem with a pointers to sf::Sound. I want to use a audio-management-class to handle all the sf::Sound and sf::Music.
This class puts all currently played sounds (and the music) in a map<unsigned int, sf::Sound*>, where the key is a random number. So I create a pointer to "new sf::Sound" and store both - the key and the pointer in the map.

But here's where the problem begins: My program terminates before the main-method is started! Usually my dbugger sets a breakpoint to the beginning of the main-method. (I even put a breakpoint to the first command manually) But these breakpoints will have no effect! The main-method simply does not start anymore!

So I commented out all methods of my Audio-Class und the includes.
Then I removed the comments one after the others. With the includes and the Header-file work properly. My program starts normally. Some methods work too. But as soon, as a method creates a pointer to a sf::Sound, the main program does not start anymore!

I also thied just "sf::Sound *s = new sf::Sound();". As soon as I I write one of this line, the program will not work anymore. Even if this method is NEVER called! "sf::Sound t()" works, but I need a sf::Sound, created with new...

Edit: I even tried "new sf::Sound();". This line will make my program not to start at all... Well... It starts, but it terminates before the main-method without any error-message.

Has someone seen something like that? O.o

Thanks,
Dodo

PS: Is use eclipse with mingw under Win7, 64 bit.

10
Graphics / Load image from file, scale it and save again
« on: February 15, 2012, 11:00:14 pm »
Okay, now everything is clear to me :)

Thank you, Laurent, for your support und your GREAT work on SFML :)

11
Graphics / Load image from file, scale it and save again
« on: February 15, 2012, 06:59:18 pm »
Hi, again

When the rendering is no problem for the GPU, I see the bottleneck at the drawing of the images (in the RAM):
When I use HD-Graphics on older computers, that do not support resolutions over 1024x768, the image has to be drawn in HD - the GPU scales it down before it is displayed, right?

Is SFML capable of drawing HD-graphics on slow computers?
(Yes, I do not want to read tutorials and documentations, before I'm absolutely sure, that I use this library) ;)

Best regards,
Dodo

12
Graphics / Load image from file, scale it and save again
« on: February 15, 2012, 06:56:16 am »
Thank you for your quick anwser,

so, what you say is, that I do not need that, because der GPU ist fast enough to scale HD-graphics? Is there an (empiric) limit, where this speed ends?

I just decided to change to SFML :D Because after three days of waiting, I didn't get ANY response/support at the official ClanLib-Forum...

Thank you,
Dodo :)

13
Graphics / Load image from file, scale it and save again
« on: February 14, 2012, 08:01:12 pm »
Hi all,

I use ClanLib for my current project, but I had to find out, that this SDK isn't capable of doing that specific task. So I'm looking for a new library. And I want to make sure, that SFML can do it, before I have to change it again later.

Here my specific problem:

I want to support different screen-resolutions (from 800x600 to HD).
My idea: I provide all graphics in HD and scale them, everytime the user sets a new resolution. These rescaled graphics will be stored on the hard drive, so that I do not have to scale everything on every startup.

Does SFML can do that?

Thanks,
Dodo

Pages: [1]