• Advertisement

ApEk

Member
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

517 Good

About ApEk

  • Rank
    Member
  1. Note that the memory overhead caused by link pointers can be safely eliminated through the proper use of unions and type punning.
  2. std::vector of pointers

    @Crusable what SyncViews says is correct and you're trying to store temporaries in a vector, but I also see something else. Although it is harmless, you seem to be using the auto keyword in your for loop here: for(auto iter = m_Map.begin(); iter != m_Map.end(); ++iter){ (*iter)->render(scrRegion, scrSize, window); //<- does not go to the function } But why not go the distance, since you are already using c++11, and use a range based for loop instead of explicitly using iterators? for (auto tile : m_Map) { tile->render(scrRegion, scrSize, window); } Isn't this the nice?
  3. I have no experience with implementing these structures myself, but I do read alot. http://maverick.inria.fr/Members/Cyril.Crassin/ - for many excellent pdfs about everything you want to know http://www.forceflow.be/category/phd/ - excellent information about sparse voxel octrees using morton encoding   There are many more sources of good information I have not mentioned, partly because of my memory, but you could ask on http://igad2.nhtv.nl/ompf2/. These topics are probably more popular there and the people more knowledgeable about the latest white papers.   Note that ompf forums are kind of slow as of lately D:
  4. I hope you are prepared for some constructive criticism.   From what I have seen so far, 8, 10 through 13, I haven't found anything from the new c++11 standard. Don't encourage the use of using namespace directives without explaining what namespaces are, what they do, and how to use them first. Consider condensing some of the material, there are videos less than three minutes and two whole videos just for loops. Note somewhere in the playlist description, in the videos, or in the first video that c++11 won't be "covered" until "lesson 23" or some point in time.
  5. Rand is the same every time.

    FleBlanc is correct. The variable arrayChooser never changes because you only call rand() once before the loop.
  6. In the event VS2012 actually supports std::chrono, here is a timer class that uses it. http://codepad.org/vVVA7qLC
  7. Udp server on homePC

    Considering no packets reach the server, the problem could possibly be with network address translation. Look up information on "udp punch through", or "udp hole punching".
  8. game loop

    First off I would suggest you refine your whitespace and indentation syntax as well as your naming convention. [s]You are passing a constant delta time to update. Why? I don't know. Instead you should probably be calculating the delta time between previous and current frame and passing that to update. Update then uses the delta time by multiplying it by a constant.[/s] Edit: should work harder on my critical reading.
  9. [quote name='dAND3h' timestamp='1352760491' post='5000362'] Hi, I am wondering if there is a function such as SDL_GetTicks() native to windows? I want to limit how often my update and draw methods execute inside my console application. [/quote] If you are able to use the new c++11 standard try to use the new chrono date and time utilities found here: http://en.cppreference.com/w/cpp/chrono Note that using chrono is a little less than straightforward but here is a complete chrono timer class: http://codepad.org/FHkSQKiO
  10. Event System in C++

    If you are looking for libraries that implement signals and slots you have many options. You have a whole range of options from heavy, feature rich boost::signals its thread safe sibling boost::signals2, libsigc++, sigslot, cpp-events, and ting. I've actually released an extremely lightweight implementation that uses c++11 called nano-signal-slot. It all boils down to what you estimate you will need. I would not recommend an old or dead implementation as maintainability could become an issue. I would suggest boost::signals2 as that is the thread safe version of boost::signals, and performance between the two is similar. http://www.boost.org/doc/libs/1_52_0/doc/html/signals2.html
  11. I have done research on current libraries. All of them make me say why? I'm about to just store a mutex in tracked and lock for any operation. Then instead of weak_ptr::expired do weak_ptr::lock and test the shared_ptr then lock the mutex inside of the erase callback? Edit: saving thread safety for another time. could probably end up wrapping up the underlying data structure and add locking.
  12. Well got around to doing some performance testing against two other implementations, sigc++ and boost::signals. However, still wondering how the heck to make it thread safe. [img]http://s7.postimage.org/vws1tby3v/nano_signal_slot.jpg[/img] Higher is better. x axis is input size where there are N connections made and N signals fired.
  13. Hello, I'm currently working on a very small signal slot implementation and have an initial version released, however, the code will probably fail in any concurrent scenarios. Basically I'm asking for any helpful information as to what must happen to make the following code thread safe. [url="http://code.google.com/p/nano-signal-slot/source/browse/nano_signal_slot.hpp"]http://code.google.c...signal_slot.hpp[/url] I'm not sure if the problem can be easily solved with the current implementation as a signal would probably have to be locked during any operation not to mention the destructor of tracked. Lastly, any constructive criticism is welcome. For those who don't even link: [CODE] struct tracked { std::shared_ptr<std::function<void(std::uintptr_t)>> erase_callback; std::unordered_map<std::uintptr_t, std::weak_ptr<std::function<void(std::uintptr_t)>>> connections; tracked ( ) : erase_callback(new std::function<void(std::uintptr_t)>) { (*erase_callback) = [this] (std::uintptr_t connection) { this->connections.erase(connection); }; } virtual ~tracked ( ) { for (auto const& connection : connections) { if (connection.second.expired() == false) { (*connection.second.lock())(connection.first); } } } }; [/CODE] [CODE] template <typename... Args> struct signal { signal ( ) = delete; }; template <typename... Args> struct signal<void(Args...)> : private tracked { signal ( ) : tracked ( ) { (*erase_callback) = [this] (std::uintptr_t connection) { this->connections.erase(connection); this->m_slot.erase(connection); }; } //------------------------------------------------------------------------------ template<typename T> void connect(void(T::*callback)(Args...), T* instance) { std::uintptr_t hash = member_hash<T, Args...>()(callback, instance); m_slot.emplace(hash, make_function<T, Args...>(callback, instance)); derived_tracked<T>(hash, instance); } void connect(void(*callback)(Args...)) { m_free.emplace(reinterpret_cast<std::uintptr_t>(callback), callback); } //------------------------------------------------------------------------------ template<typename T> void disconnect(void(T::*callback)(Args...), T* instance) { (*erase_callback)(member_hash<T, Args...>()(callback, instance)); } void disconnect(void(*callback)(Args...)) { m_free.erase(reinterpret_cast<std::uintptr_t>(callback)); } //------------------------------------------------------------------------------ void operator() (Args... args) const { for (auto const& connection : m_slot) { connection.second(args...); } for (auto const& connection : m_free) { connection.second(args...); } } private: //----------------------------------------------------------------- template<typename T> void derived_tracked(std::uintptr_t hash, typename T::tracked* instance) { connections.emplace(hash, instance->erase_callback); instance->connections.emplace(hash, erase_callback); } template<typename T> void derived_tracked(...) { } // sfinae std::unordered_map<std::uintptr_t, std::function<void(Args...)>> m_slot; std::unordered_map<std::uintptr_t, std::function<void(Args...)>> m_free; }; [/CODE] Edit: above code is for context. current code is at the link above.
  14. [url="http://ideone.com/qiHP9"]http://ideone.com/qiHP9[/url] Default arguments in constructors should almost always be implemented as different constructors along with associating initialization lists.
  15. Help with C++

    [url="http://ideone.com/hlu8f"]http://ideone.com/hlu8f[/url] You should be using code tags so your code is properly displayed on the page. You prime your while loop but never cin to choice inside of it therefore it will never be able to quit or do anything other than create. You should never use "using namespace std" in global scope as this will import all the symbols used in the std namespace and name conflicts can occur. Your item string should be declared locally inside of the loop this way it is always constructed and destructed at the end of the scope. It seems as though you tried to reduce your code for a smaller paste size but idk.
  • Advertisement