• Content count

  • Joined

  • Last visited

Community Reputation

134 Neutral

About BiTwhise

  • Rank
  1. Struct or Class ?

    As a side note, if you ever plan to move over to .net structs are value types, while classes are reference types (objects) in general, I personally prefer using structs only for PODs, and classes for anythings else, just for consistency
  2. Fun macro hackery

    The problem is a very general one (traverse all the elements of a container, and apply a function to them), and as such I think making some hard coded macro to perform the action is unessesary. The board could for instance be kept in some STL container, on which you could apply for_each in much the same manner (with some more generality) as in mine and Erzengeldeslichtes' example. Personally I find readability to be clearer too, and if you come to debugging any of this, you'll truly appriciate why macros are so bad :P It is to some extent a personal preference, but there's also a trueism to macros being generally bad practice. @Erzengeldeslichtes: Ye, I took it you probably thought about it, and the patterns is just the same. I just felt I should bring it up when the question of performance was brought in.
  3. Fun macro hackery

    You can avoid the virtual function call overhead by making a similar templated function which takes in some form of function object. It could then be fully inlined and optimized. ("stole" Erzengeldeslichtes' code, and changed it a bit) template<class _Functor> void ApplyToBoard(_Functor& f) { for(int i = WALL_SIZE ; i < 9 + WALL_SIZE ; ++i) { for(int j = WALL_SIZE ; j < 9 + WALL_SIZE ; ++j) { if(f(g_Array[i][j])) return; } } } all you'd need to do is override the () operator on the function object and stick to your argument and return type convention for the method struct SomeFunctorToApply { SomeFunctorToApply( /* could have state members to initialize */ ) { } inline bool operator(Cell& boardCell) const { /* do operations on cell */ if(breakCondition) return true; return false; } }; void SomeRandomMethodDoingStuffWithBoard { ApplyToBoard(SomeFunctorToApply()); }
  4. Resizing arrays

    if you want resizable arrays, use something like std::vector (#include <vector>
  5. Worries...

    OGL still doesn't have (to my knowledge) a meta language for shaders (like HLSL's FX format) I guess that will come shortly though
  6. Worries...

    Agreeing with the AP. The most important thing when new to things like this, do not get caught up in the whole "which is the best API" war.. it's redicioulus. Learn the concepts, and apply them through whichever API you chose (or is chosen for you)
  7. function pointers + virtual

    pointers to virtual functions store the offset into the vtable rather than the pointer to the actual function, and thus works as described above. go here, for a in depth description of function pointers and a fast delegate implementation
  8. Eclipse newbie - I have some questions

    1. If it marks it red, your statement is probably not complete (or syntactically wrong.. or you're missing an import). Maybe there's some way to turn it off.. just started using eclipse myself, so I don't know. 2. String is not a basic type, it's a class. Well, java has some String specific features to simplify using the class, but it's still a class, not a basic type.
  9. try changing 'int' to 'size_t' (which is defined as the size of a pointer)
  10. Is assembler used in modern game programming?

    Assembly is still used to some degree.. mostly for exploiting CPU specific instructionsets, such as SSE, SSE2, SSE3, 3DNow, MMX, etc Have a look at, for instance, the Doom3 SDK which is just out, for a real project example
  11. complexity of bubble sort

    Quote:O() assumes you look at massive data sets, so n gets SO big none of the other numbers matter. Erm.. not really.. The reason O encapsulates all the constants in the expression, is the notation is given to measure the performance characteristics of the algorithm relative to the size of its dataset.
  12. Processor Pack for VS6 SP6?

    Your best of getting VS7.1, or at least the VC7.1 compiler (if it's optimisation, multimedia instruction support, and intrinsics you're after)
  13. [answered]classes Namespaces

    Just thought I'd mention it. Namespaces are a very nice way of structuring big projects, so you're likely to be including and depending on other namespaces in your header declerations
  14. [answered]classes Namespaces

    I would personally advice not to use the 'using' derictive in the global scope of header files, since that would force the user/the translation unit using your header file to be using the namespace.. destroying the very meaning of namespaces, namely to prevent name crashes. The directive is scope local though, so you could use it within class declerations, functions, etc. Another way of shortening the names, is namespace aliases. You could say namespace short_name = some_long_name_namespace; This could also be used to switch between implementations compile time. Say you have two implemenations, in 'namespace Impl1' and 'namespace Impl2', then you could go 'namespace Impl = Impl#'