Hi,
I got pissed at my previous asset manager last night and got rid of the whole damn thing. So I wrote a small, extensible asset management template library using C++11 to replace it. It's very RAII friendly and I thought some of the folks on here might find it useful. It's on GitHub at http://github.com/nokurn/nam. There's a tutorial for basic usage on the wiki, as well as a link to the Doxygen generated documentation.
Bug reports and feature requests are welcome. I'll be watching this topic, so feel free to ask questions. It's dead simple to use, so I doubt anyone will have issues.
If you use Nam in a project, I'd appreciate it if you mentioned it on the Projects wiki page.
Nam: A C++ Asset Management Library
Moderator: PC Supremacists
- Nokurn
- Chaos Rift Regular
- Posts: 164
- Joined: Mon Jan 31, 2011 12:08 pm
- Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
- Programming Language of Choice: Proper C++
- Location: Southern California
- Contact:
Nam: A C++ Asset Management Library
Last edited by Nokurn on Tue Jul 24, 2012 9:12 pm, edited 1 time in total.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Nam: A C++ Asset Management Library
I totally thought "asset manager" was a person for a moment there..Nokurn wrote:I got pissed at my previous asset manager last night and got rid of the whole damn thing.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Nokurn
- Chaos Rift Regular
- Posts: 164
- Joined: Mon Jan 31, 2011 12:08 pm
- Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
- Programming Language of Choice: Proper C++
- Location: Southern California
- Contact:
Re: Nam: A C++ Asset Management Library
Alright, I fixed it somewhat. There's a bug that causes shit to go crazy if the nam::store is cleared/destroyed before all of its nam::shared_ptrs, which I'm working on now. Aside from that, it's usable as far as I'm aware.
Edit: Ok, I've ironed out all of the bugs I was aware of. I'm using this in a project that I'm actively developing, so I'm testing it as I go. If anyone else uses it and finds a bug, let me know!
dandymcgee wrote:I totally thought "asset manager" was a person for a moment there..Nokurn wrote:I got pissed at my previous asset manager last night and got rid of the whole damn thing.
Edit: Ok, I've ironed out all of the bugs I was aware of. I'm using this in a project that I'm actively developing, so I'm testing it as I go. If anyone else uses it and finds a bug, let me know!
- short
- ES Beta Backer
- Posts: 548
- Joined: Thu Apr 30, 2009 2:22 am
- Current Project: c++, c
- Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
- Programming Language of Choice: c, c++
- Location: Oregon, US
Re: Nam: A C++ Asset Management Library
I'm curious, from the WIKI I am unsure how one would be utilize NAM. Could you post an example of what benefit it is providing you?
From the basic usage tutorial, it seems you write a class that writes and reads a file, and it returns to you, the user, a shared_ptr<T> (T is the type you just wrote) for the file you just wrote, which exposes the methods you (the user) just wrote... What benefits are you getting from using NAM? What code does it prevent the user from writing? That said, I do have to compliment your style and am curious to see what your answers are.
From the basic usage tutorial, it seems you write a class that writes and reads a file, and it returns to you, the user, a shared_ptr<T> (T is the type you just wrote) for the file you just wrote, which exposes the methods you (the user) just wrote... What benefits are you getting from using NAM? What code does it prevent the user from writing? That said, I do have to compliment your style and am curious to see what your answers are.
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
link: https://github.com/bjadamson
- Nokurn
- Chaos Rift Regular
- Posts: 164
- Joined: Mon Jan 31, 2011 12:08 pm
- Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
- Programming Language of Choice: Proper C++
- Location: Southern California
- Contact:
Re: Nam: A C++ Asset Management Library
The wiki definitely needs improvement, there are some things that could be clarified. I'll work on it this weekend.short wrote:I'm curious, from the WIKI I am unsure how one would be utilize NAM. Could you post an example of what benefit it is providing you?
From the basic usage tutorial, it seems you write a class that writes and reads a file, and it returns to you, the user, a shared_ptr<T> (T is the type you just wrote) for the file you just wrote, which exposes the methods you (the user) just wrote... What benefits are you getting from using NAM? What code does it prevent the user from writing? That said, I do have to compliment your style and am curious to see what your answers are.
Say you've got a lot of textures in your game that are used in multiple places. Both in terms of memory and speed, you're better off maintaining a single copy of that texture until it's no longer in use. That's what nam::store does. It keeps a map of nam::internal_ptr objects that are keyed according to your texture type (let's call it mg::texture2)'s key_type (in this example, a std::string that represents a filename). You load textures through a shared (possibly engine-wide) nam::store<mg::texture2>. When you call the get() method or use the non-const [] operator, the nam::store will search for an existing texture that matches the key you requested. If no texture with that key is found, it's loaded using mg::texture2's constructor that takes a mg::texture2::key_type. The method returns a nam::shared_ptr<mg::texture2> for that texture.
nam::shared_ptr will do reference counting on the texture's nam::internal_ptr. When the nam::shared_ptr is constructed, it adds a reference; when it's destroyed, it removes a reference. Once the nam::internal_ptr reaches 0 references, it destroys itself and resets all associated nam::shared_ptr objects.
Future features I'd like to add are explicit caching (manually adding/removing references), nam::store iteration, and possibly some variants of nam::store that are optimized for specific uses. I'm also willing to take suggestions (and patches to implement those suggestions)
Re: Nam: A C++ Asset Management Library
I will definitely have to give this a go next time I start an OpenGL project. Thanks for sharing.