Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

282 Neutral

About jeroenb

  • Rank
    Advanced Member

Personal Information

  1. jeroenb

    Linux for game development

    I was also new to Linux development for my engine. After some investigations and the 'popularity' of Ubuntu at that time, I decided to go for that platform. Luckily it wasn't a bad experience, most libraries I used in my engine (which I originally developed with Windows) were readily available as package in the package manager. The main difficulties I experienced were getting my project generator (premake) and debugger up and running (which still isn't running as nicely as visual studio) and obviously the small differences in API's.
  2. jeroenb

    Non-trivial union

    Right, I fixed that in my code. I think I got it working with the proposal I made myself. It works both with GCC and visual studio. E.g.: Type(const Type& that) : mKind(eObject), mObject() { if ( that.mKind == eArray ) { mKind = eArray; new (&mArray.mType) std::unique_ptr<Type>(new Type())); mArray.mDimension = 1; } else { mObject.mName = that.eObject.mName; } }
  3. jeroenb

    Non-trivial union

    The Type class is used in my custom script language to specify the type of for example a variable, class, function argument, etc. To preserve memory I wanted to give this new C++11 functionality a try as that would prevent memory allocations of the structs in case a pointer is used.
  4. I am trying to get my head around the new C++11 non-trivial unions in Visual Studio 2015. Please have a look at a simplified class I created (note that this code might not compile in its current form): class Type { public: Type() : mKind(eObject), mObject() { } ? // move constructor and operator= removed Type(const Type& that) : mKind(eObject), mObject() { if ( that.mKind == eArray ) { mKind = eArray; mArray.mDimension = 1; mArray.mType.reset(new Type()); // <-- here I get crashes due to uninitialized mType } else { mObject.mName = that.eObject.mName; } } enum Kind { eArray, eObject } mKind; struct ArrayInfo { std::unique_ptr<Type> mType; int mDimension; }; struct ObjectInfo { String mName; }; union { ArrayInfo mArray; ObjectInfo mObject; }; } I read that you may only initialize one member of the union (otherwise the constructor is ill formed). In this case I choose the mObject variable. Compiling works fine and well, but at runtime when I try to assign values to the mArray part I get crashes as it seems that it has not been initialized. I have looked through numerous resources about non-trivial unions and they always only have a std::string in there. Now I wonder how I can make this work. Do I need something like: mObject.~String(); new (&mArray) ArrayInfo(); Thanks for the help.
  5. jeroenb

    big loop with big array

    I have no clue about the file format. I only can suggest to check if your variables are initialized correctly. A verification whether or not you are reading past the end might reveal a problem as well. I would also suggest to open the file as binary ("rb").
  6. Frob, thats a good idea, and indeed is much clearer. Thanks for the suggestions all, this helps a lot!
  7. That it is valid, I agree on. But now I would like to prevend that this constructor is called by accident with only a bool argument. Adding a constructor explicit Ptr(bool owned) again makes it impossible to call the constructor with the NULL value, as that will result in an ambiguous call to either constructor. Any idea's? ps. I am compiling with the microsoft compiler, which does not produce by default a warning for this.
  8. I recently encountered a piece of code like the following (not saying anything about whether it is good or not): [source lang="cpp"]class Ptr { public: Ptr(void* ptr = NULL, bool owned= true); ... } Ptr ptr(false);[/source] This seems to compile pretty well, and the false is implicitly converted to a null pointer! In case you give true as argument to this constructor, you get a compile error. Now my question is: how can you prefend that the bool is converted automatically to a null pointer. I tried an explicit constructor with only one bool argument. But that made it impossible to send NULL as pointer to the first.
  9. jeroenb

    Unit testing

    Thanks for the quotes Frob! Could you post or PM me a link to the newsgroup? I would be interested to read some of the discussions and hope to learn from it. For the rest I am already happy if I can implement some tests that prefend bugs from appearing ;-)
  10. jeroenb

    Cross platform GUI toolkit

    I have only used Qt in the past for a single application, so I can not tell to much about it. Although it is pretty big, it comes with all kinds of handy stuff you no longer have to write yourself. It has a nice wiziwig UI designer which supports the events (you can even write the whole application in one of their apps). Advantage is that multi-language has been integrated pretty well, quite easy to learn and lots of libraries cross platform available. Disadvantage I found with Qt was that I had to compile the UI and some other file type everytime it changed.
  11. When you parse your files for the statements you already should be doing some form of syntax checking, otherwise you might be processing an invalid file format. There are a lot of libraries that generate a lexer/parser for you which basicially do some form of grammar checking. Have a look at lex & yacc or antlr. For my latest script language I used Antlr and it's a very good library!
  12. jeroenb

    Serialization: from C# to C++

    Yes, that sometimes is a pain in the 'ass' as you call it. But luckily often you do not change the formats very often if you think well about them first. I have faced this problem a few times during the development. Currently I have a file format that contains a version number which makes it easier to support older versions and convert them on the fly. That way it's less painfull.
  13. jeroenb

    Compressed sound, what format to use?

    I would indeed also vote for Ogg Vorbis format. It is a good format that can be used easily in combination with OpenAL. The encoder and decoders are also not emcumbered with wierd licenses, so you can freely use it.
  14. I agree that for a game you should not need administrative rights. When it runs on a windows platform you can use the Windows API to query standard directories where you can write the save games, etc. and where the system32 and program files directories are. I am pretty sure that Linux has similar methods. As Rip-off mentioned for an installer it is allowed to ask for admin rights if you install to for example the program files directory. So, better try not to use it: users don't like the boxes.
  15. jeroenb

    Unit testing

    Thanks both for the responses. This sounds like a plausible solution. Perhaps I can make multiple build targets: a static library for the unit tests and a dll for the application. Lets see how I can get this working.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!