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

Pages: [1]
1
General / Re: My First SFML App error
« on: January 30, 2015, 09:32:13 pm »
Try to delete headers in /usr/local/include/SFML

2
General / OS X: crash when resize window to minimal size
« on: January 30, 2015, 05:01:08 pm »
SFML from github (master).

When I try resize window to minimal size (i do it fast), program crashes.

UPD: I think is a bug of the OS, because with GLFW i've got same thing.

Code:

#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "OpenGL");

    bool running = true;

    while (running) {
        sf::Event event;

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

    window.close();

    return 0;
}
 

Error:

(click to show/hide)

3
i've updated my post, may be it helps
but i really have only basic thoughts about how to do this
i'm not cpp programmer, sorry =(

i think object destroyed (cause it on stack) and we need to store it on heap instead of stack (http://www.sfml-dev.org/tutorials/2.0/graphics-sprite.php#the-white-square-problem)

try this, but i'm summon good c++ programmer in this topic)

class ResourceManager
{
    public:
        template<typename Resource>
        bool      load(std::string address)
        {
            auto temporaryResource = new Resource(); // will be in memory until delete ptr
            bool success = temporaryResource->loadFromFile(address);
            resourceHolder.insert( {address, static_cast<void *>(temporaryResource)} );
            return success;
        }
        template<typename Resource>
        Resource*  get(std::string ID)
        {
            return static_cast<Resource *>(resourceHolder[ID]);
        }
    private:
        std::map <std::string, void *> resourceHolder;
};

i've tested drawing, ant it's works fine

4
im newbie in c++, but may be it will work (it seems to work):

class ResourceManager
{
    public:
        template<typename Resource>
        bool      load(std::string address)
        {
            Resource temporaryResource;
            bool success = temporaryResource.loadFromFile(address);
            resourceHolder.insert( {address, &temporaryResource} ); // insert pointer instead of value
            return success;
        }
        template<typename Resource>
        Resource*  get(std::string ID)
        {
            return static_cast<Resource *>(resourceHolder[ID]);
        }
    private:
        std::map <std::string, void *> resourceHolder; // can store pointer to anything
};

// use
ResourceManager UltimateResourceManager;
if (!UltimateResourceManager.load<sf::Texture>("img.png")) return -2;
sf::Sprite sprite(*UltimateResourceManager.get<sf::Texture>("img.png"));
 

but if the object dies, pointer to this object still be in resourceHolder

UPD

insert pointer line should be

resourceHolder.insert( {address, static_cast<void *>(&temporaryResource)} );

5
General / Re: runtime error with code from graphics tutorial
« on: January 29, 2015, 03:41:18 pm »
thank you

global atomic variable and thread.wait() works well

6
General / runtime error with code from graphics tutorial
« on: January 29, 2015, 03:29:02 pm »
code from http://www.sfml-dev.org/tutorials/2.1/graphics-draw.php:

#include <SFML/Graphics.hpp>

void renderingThread(sf::RenderWindow *window)
{
    while (window->isOpen()) {
        window->clear();
        window->display();
    }
}

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

    sf::Thread thread(&renderingThread, &window);
    thread.launch();

    while (window.isOpen()) {
        sf::Event event;

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

    return 0;
}

Error when close window: Pure virtual function called! because window is closed (and may be deleted), but pointer *window in second thread are still used

i change code, add mutex, and now it works fine, but i'm not sure is this right way to use mutex here?

// main thread
...
if (event.type == sf::Event::Closed) {
    mutex.lock();
    window.close();
    mutex.unlock();
}
...

// second thread
...
    mutex.lock();
    window->clear();
    window->display();
    mutex.unlock();
...
 

7
General / Re: Can't build simple app on OS X (SFML from master)
« on: January 29, 2015, 03:00:42 pm »
oh of course
in first time i use dylibs instead of frameworks, and copy headers from include/ dir to /usr/local/include/
now i use frameworks, but compiler still look into /usr/local/include, which contain wrong headers =)

thank you!

8
General / Can't build simple app on OS X (SFML from master)
« on: January 29, 2015, 02:19:54 pm »
Hi!

SFML compiled from sources (github master) using clang and libc++ (may be i do it wrong, but simple app with window compiles succefull).
When i try to compile anything with code:

sf::VertexArray triangle(sf::Triangles, 3);

ive get error:

Undefined symbols for architecture x86_64:
  "sf::VertexArray::VertexArray(sf::PrimitiveType, unsigned int)", referenced from:
      renderingThread(sf::RenderWindow*) in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Engine] Error 1
make[1]: *** [CMakeFiles/Engine.dir/all] Error 2
make: *** [all] Error 2

Compiled with CMake:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -stdlib=libc++")

It seems like some SFML parts compiled with 32bit arch instead of 64..

9
General / Re: Window size on OS X & Retina display
« on: January 26, 2015, 05:58:25 pm »
It works, thank you!
But now window title looks horrible.

May be exists some method, that returns OS scale modifier? Eg for OS X & Retina modifier = 2, on non-retina is 1, and i just multiply all sizes in my app by this modifier (or if it = 2, load HD images)?

10
General / Window size on OS X & Retina display
« on: January 26, 2015, 05:02:26 pm »
Hi.

Tested on 2.2 (from sources) & github master.

Code below makes window with size 400x300:

sf::Window window(sf::VideoMode(800, 600), "My window");

Of course in real (hardware) pixels it have normal size (800x600 real pixels), but by default OS X scales resolution. Same problem with sprites & other.

So can the SFML detect that need to scale all sizes automatically when i run app on retina display and non-retina display?

Pages: [1]