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 - Mörkö

Pages: 1 ... 5 6 [7]
91
General / Re: help decrypting error message
« on: June 12, 2014, 06:59:07 am »
Where did you download the book source code from? If you got it from Packt's website then it is outdated and has issues (since some compilers don't properly implement the standard library as your original post shows).

Try downloading the latest source of the sample code from github and see if that fixes your issue. If that doesn't then something is messed up with your environment/configuration.
I was using the github samples.

But I don't understand how I could compile the samples if something were messed up in my environment. That's what lead me to believe that I had made some kind of very subtle mistake that I'm unable to catch by comparing the source from github to my own.

I can compile the the github samples without any problem, but cannot compile my own.

Anyway, I am going to test compiling on another system, and then tell you what happens.

Updated:

I tried compiling my code on another system, and failed with the same errors. I was also able to build the github code on the new system.

Tested on: OpenSuse 13.1, Fedora 20

Any more ideas?

92
General / Re: help decrypting error message
« on: June 12, 2014, 12:42:41 am »
Those errors are all in the standard library, so something is wrong with your environment/configuration, rather than your actual code.  Try reinstalling your toolchain.

Wouldn't I get the same error from the GitHub code as well if that was the case? I can compile the samples without any problems.

There is only one difference in my code from the samples. I've replaced all the instances of the FOREACH macro with C++11 style for (Type& type : container)

93
General / help decrypting error message
« on: June 12, 2014, 12:00:06 am »
I'm working through the SFML game dev book, and it's pretty great. However, when coding along to the chapter 7 - Warfare Unleashed - Implementing Gameplay I encountered this error, that I haven't been able to figure out on my own:

Quote

22:31:46: Starting: "/usr/bin/make"
g++ -c -pipe -std=c++11 -Wall -Wextra -g -Wall -W -DQT_WEBKIT -I/usr/share/qt4/mkspecs/linux-g++ -I../SFMLbook -I../SFMLbook -I. -o world.o ../SFMLbook/world.cpp
In file included from /usr/include/c++/4.8/set:60:0,
                 from ../SFMLbook/scenenode.hpp:13,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/stl_tree.h: In instantiation of 'std::_Rb_tree_node<_Val>::_Rb_tree_node(_Args&& ...) [with _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >]':
/usr/include/c++/4.8/ext/new_allocator.h:120:4:   required from 'void __gnu_cxx::new_allocator< <template-parameter-1-1> >::construct(_Up*, _Args&& ...) [with _Up = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
/usr/include/c++/4.8/bits/alloc_traits.h:254:4:   required from 'static typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > > >; typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type = void]'
/usr/include/c++/4.8/bits/alloc_traits.h:393:57:   required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Alloc = std::allocator<std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > > >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/4.8/bits/stl_tree.h:408:36:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >&}; _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:429:55:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_clone_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:1087:43:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_copy(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >*]'
/usr/include/c++/4.8/bits/stl_tree.h:659:50:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Rb_tree(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) [with _Key = Fonts::ID; _Val = std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > >; _KeyOfValue = std::_Select1st<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
/usr/include/c++/4.8/bits/stl_map.h:181:22:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = Fonts::ID; _Tp = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >; _Compare = std::less<Fonts::ID>; _Alloc = std::allocator<std::pair<const Fonts::ID, std::unique_ptr<sf::Font, std::default_delete<sf::Font> > > >]'
../SFMLbook/resourceholder.hpp:11:7:   required from here
/usr/include/c++/4.8/bits/stl_tree.h:140:49: error: use of deleted function 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = const Fonts::ID; _T2 = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >]'
    _M_value_field(std::forward<_Args>(__args)...) { }
                                                 ^
In file included from /usr/include/c++/4.8/utility:70:0,
                 from /usr/include/c++/4.8/algorithm:60,
                 from /usr/local/include/SFML/Graphics/Rect.hpp:32,
                 from /usr/local/include/SFML/Graphics/Transform.hpp:32,
                 from /usr/local/include/SFML/Graphics/Transformable.hpp:32,
                 from ../SFMLbook/scenenode.hpp:6,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/stl_pair.h:127:17: note: 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = const Fonts::ID; _T2 = std::unique_ptr<sf::Font, std::default_delete<sf::Font> >]' is implicitly deleted because the default definition would be ill-formed:
       constexpr pair(const pair&) = default;
                 ^
/usr/include/c++/4.8/bits/stl_pair.h:127:17: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = sf::Font; _Dp = std::default_delete<sf::Font>]'
In file included from /usr/include/c++/4.8/memory:81:0,
                 from ../SFMLbook/scenenode.hpp:11,
                 from ../SFMLbook/entity.hpp:4,
                 from ../SFMLbook/aircraft.hpp:4,
                 from ../SFMLbook/world.hpp:4,
                 from ../SFMLbook/world.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:273:7: error: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^
make: *** [world.o] Error 1
22:31:47: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SFMLbook (kit: Desktop)
When executing step 'Make'

I've been going over my code and comparing it to the functioning source from the LaurentGomila GitHub page, but I'm just unable to find any difference in my own code.

So from what I can tell this has something to do with std::set, but it's difficult for me to figure out anything else than that, because this traceback message doesn't actually seem to explicitly show where the problem is in my source, but points to a standard library file instead. Following the error through the files ends up at the class declaration of ResourceHolder before going into stl_tree.h.

So please help me figure out what may be causing this error.

--

As an aside, here are some personal remarks not directly related to the issue: I'm using the book as a code along and intro to my first real C++ project. Having learnt programming in python, the transition to C++ was shocking in several ways, mostly due to the extreme complexity of the language and how frequently I must go digging for answers to things which were more or less intuitive in python. I don't have any inherent problem with complexity itself, because this technical kind of problem solving is part of why I enjoy programming so much. However, I do consider C++ a pretty awful language by modern standards, because the nature of it's complexity is that of baggage from decades ago, and implementing too many paradigms to be a good choice for anyone starting out these days.

Well, maybe people feel differently if they are given a formal education starting with C or Java, and can then proceed to view C++ as an improved or more powerful version of what they already knew, but I don't know if that's true.

I will stick with it until I have a solid understanding of `programming in C++` and feel that I'm comfortable using it to start any kind of project. I want to become a programmer and a game dev, so I think having a working knowledge of all the big daddy languages is a must, but I sure do hope I'll be able to code my own games in a more elegant and modern language than this.

94
Graphics / Re: AW: Basic window memory issue
« on: May 28, 2014, 02:17:37 am »
The more important questions are: How do you track the "leak"? And what is your graphics driver?

Leaking drivers are nothing new.
Right.

I am tracking the memory usage by nothing more scientific than launching the program and checking my system monitor.

I'm using the proprietary FGLRX drivers.

Quote from: eXpl0it3r
Don't forget the Git version is always something in development. So if you use the latest commit, then you should never be surprise if something doesn't work/is bugged. ;)

Of course. I am just probing for info anyway.

95
Graphics / Re: Basic window memory issue
« on: May 28, 2014, 01:52:37 am »
Does this happen with a normal loop where you do clear()/draw()/display() and no raw OpenGL?  Using display() without clear() is definitely not right.

Yeah it does. RenderWindow::clear() seems to implement glClear() under the hood anyway, so I didn't think there would be any practical difference in the code by calling opengl directly, even if I'm mistaken, there seems to be no change in the result / problem.

96
Graphics / Basic window memory issue
« on: May 28, 2014, 01:00:40 am »
On my system the following code seems to add 10mb or ram per second:

int main() {
    sf::RenderWindow window(sf::VideoMode(320, 240), "");
    sf::Event event;
    while (window.isOpen()) {
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        glClear(GL_COLOR_BUFFER_BIT);
        window.display();
    }
}

In my system monitor, running that shows a steady increase of +10mb memory usage every second. These are my specs:
             .;ldkO0000Okdl;.                user@box
         .;d00xl:,'....';:ok00d;.            OS: openSUSE 13.1 Bottle
       .d00l'                ,o00d.          Kernel: x86_64 Linux 3.11.10-11-desktop
     .d0Kd. :Okxol:;'.          :O0d.        Uptime: 3h 0m
    'OKKKK0kOKKKKKKKKKKOxo:'      lKO'       Packages: 2570
   ,0KKKKKKKKKKKKKKKK0d:,,,:dx:    ;00,      Shell: bash 4.2.45
  .OKKKKKKKKKKKKKKKKk..oOkdl.'0k.   cKO.     Resolution: 1920x1080
  :KKKKKKKKKKKKKKKKK: kKx..od lKd   .OK:     DE: KDE 4.11.5
  dKKKKKKKKKKKOx0KKKd ;0KKKO, kKKc   dKd     WM: KWin
  dKKKKKKKKKKKK;.;oOKx,..'..;kKKK0.  dKd     WM Theme: Oxygen
  :KKKKKKKKKKKK0o;...;cdxxOK0Oxc,.  .0K:     GTK Theme: oxygen-gtk [GTK2]
   kKKKKKKKKKKKKKKK0xl;'......,cdo  lKk      Icon Theme: oxygen
   '0KKKKKKKKKKKKKKKKKKKKK00KKOo;  c00'      Font: Sans Serif
    .kKKKOxddxkOO00000Okxoc;'.   .dKk.       CPU: AMD FX-8120 Eight-Core @ 3.1GHz
      l0Ko.                    .c00l.        GPU: AMD Radeon HD 6900 Series
       .l0Kk:.              .;xK0l.          RAM: 2517MB / 7981MB
          ,lkK0xl:;,,,,;:ldO0kl,            
              .':ldxkkkkxdl:'.  
Using the github version of SFML.

Now, I thought the increase was weird in itself, and not only because I don't quite know how to identify what the actual problem is, but I really thought a lib as established as SFML shouldn't have those kinds of issues (not bashing, just being honest.)

But what's even more weird to me is that the problem seems to be dependent on the resolution of the window, and some other factors. Here are some samples I noted from trying different resolutions:

150x150: 14.9mb memory usage, no noticeable increase.
320x240: Steady memory increase by 10mb every second.
640x480: Same as 320x240.
1600x900: 5mb per second increase.
1920x1080: This is equivalent to `fullscreen windowed mode` for me. Curiously, this shows a 3mb per second increase, but if I grab and move the window so that KDE automatically resizes it to ~1280x680, then the memory stops increasing and stays at whatever it was before I moved it. Manually setting the resolution to that value results in a 7mb per second increase.

If I limit the fps using RenderWindow::setFramerateLimit() then the increase is slowed down in proportion to the rate.

So I guess my questions are: Is this a known problem? Is the problem in my code, rather than a bug in SFML? Problem is in my system? Are there any workarounds to prevent this? Can you explain what is causing the leak? Why do the amounts vary depending on window resolution?

I appreciate any information or advice, thank you.

Pages: 1 ... 5 6 [7]
anything