Jump to content
  • Advertisement

Demos Sema

  • Content Count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About Demos Sema

  • Rank
  1. Demos Sema

    General Engine Optimizations

    that is actually not too bad, a good start. First off be aware of memory and use smart-pointers when you want to express ownership. I think you are on the right track with thinking "this is what I want my interface to look like how do I get it". You should really be using the standard library, instead of taking a char* you should take a const std::string& and instead of storing your vertex buffer in a C style array you can use a std::vector.
  2. First of all if you are a beginner and especially a team of beginners you should really think about using something other than C++. C++ is great when you need a huge amount of performance and low-overhead access to your hardware but it is NOT good for beginners since it gives you a whole lot of rope to hang yourself. For a team of beginners it is even worse since everybody will be shooting themselves in different ways. Nobody can agree on how to write c++ and for beginners this will be even more of a problem. If you are dead set on using c++ I hear SFML is a good OO media library for games. That said OOP is not the best way to structure all programs, usually when people say "I want a library in OOP style" they mean that they want a well designed, well-documented, terse, and consistent library in /any/ style.   As for what language to use I would consider Python, or maybe Go. Go is attractive since it is really simple and good for team projects, and python has good libraries. Be aware with Go that the ecosystem is not all that great yet in terms of libraries.   unfortunately there are few really high level languages with a good type system, especially ones that are beginner-friendly.
  3. std::regex is missing from my version of libstdc++, as is std::wstring_convert. http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x has the full table.
  4. I think it is important to note that MSVC's STL (essentially dinkumware) and clang's libc++ are way more complete than GCC's libstdc++
  5. Demos Sema

    mixing unicode and non-unicode

    Oh windows. wchar_t, wide strings, and so on are NOT really the only way or even the best way to "do Unicode". In general you should expect a Unicode-aware strlen type function to step through every character of the string and compute length as it goes, even with wide characters there are some code points that will take multiple characters. The obvious and least painful solution is to just avoid taking string lengths, this is particularly good because there are some characters that may have length one or two depending on how you look at them. Another option would be to convert stuff to some massive 32bit length strings to take the length and then convert back when you are done.   In general I use Unicode mode in windows just for more static checking but IMMEDIATELY convert stuff from wchars to UTF-8 narrow strings for use inside my code. On recent versions of visual studio you can use std::wstring_convert to do the narrowing/widening. If you need to use GCC you are going to have to use the C facets library. What follows is my implementation of widen and narrow, the commented code is the same function but with std::wstring_convert and likely less bugs. The C version very likely has overrun bugs and leaks and so on (but at least is ACTUALLY narrows/widens unlike most examples on the net) inline std::string narrow(const std::wstring& wstr) { std::mbstate_t state = std::mbstate_t(); auto buffer = wstr.c_str(); size_t len = 1 + std::wcsrtombs(nullptr, &buffer, 0, &state); std::vector<char> nstrbuf(len); std::wcsrtombs(&nstrbuf[0], &buffer, nstrbuf.size(), &state); return std::string(nstrbuf.data()); //this stuff does not work in GCC, FML //std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; //return converter.to_bytes(wstr); } inline std::wstring widen(const std::string& nstr) { std::mbstate_t state = std::mbstate_t(); auto buffer = nstr.c_str(); size_t len = 1 + std::mbsrtowcs(nullptr, &buffer, 0, &state); std::vector<wchar_t> wstrbuf(len); std::mbsrtowcs(&wstrbuf[0], &buffer, wstrbuf.size(), &state); return std::wstring(wstrbuf.data()); //again does not work on GCC because reasons //std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; //return converter.from_bytes(nstr); } see http://utf8everywhere.org/ for how to handle text and an explanation of how weird windows is   Edit: I think the best bet for actually getting character lengths is to go ahead and widen your strings and then take the length of the wide string. Yes this is a lot of slow conversions but strings are slow /anyways/
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!