Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 Oct 2008
Offline Last Active Oct 01 2012 06:49 PM

Posts I've Made

In Topic: SFINAE equivalent in C#?

28 September 2012 - 06:45 PM

Ja, I'm quickly starting to miss C++ templates.

I'm going to have to unlearn my template-centric coding style for C#.

There's a number of aspects of C++ templates that bug me. Stuff like this in particular:
[source lang="cpp"]void function(const std::vector<Objects*>&){}void constFunction(const std::vector<const Objects*>&){}std::vector<Objects*> objectList;function(objectList);constFunction(objectList); // compile error[/source]

Do C# generics let you do that sort of stuff easily?

There is no such thing as "const" in C#, so that's a non issue.
However, it's normal that it doesn't work in c++. An array of const objects is not all all the same type as an array of non const objects. You can't expect implicit conversion of those two types. If you want to guarantee what I suspect is your wanted behavior, you should use a container where the element access function/operator returns const member if the container is const:

[source lang="cpp"]object* array &lt object* &gt ::operator[](int i);const object* array &lt object* &gt ::operator[](int i) const;[/source]
with those two functions:
[source lang="cpp"]void function(array &lt objects* &gt &){}void constFunction(const array &lt objects* &gt &){}[/source]

In Topic: Game Engine Problem with loading multiple textures- HELP!

27 June 2012 - 11:29 AM

From what i see, your texture list is vector<cTexture>, so your textures are held by value. If you add a new one, you might reallocate the vector's buffer which will copy then destroy all your existing textures. I don't know how your cTexture class handles being copied, but it has a good chance to be the issue. You should insert the textures in the manager by pointer, by dynamically allocating them with new/delete (or something that wraps those, I won't get in the smart pointer topic here Posted Image ) This way reallocating the vector will only move the pointers around, which won't destroy/affect the texture objects themselves.

In Topic: Deprecated matrixes

24 April 2012 - 03:29 PM

Not using shader by itself is deprecated in OpenGL >= 3.0. So if you want to get up to date you have to move to using them.

If you want a replacement for the old gl matrices functions, you might want to look at something like glm (http://glm.g-truc.net). Its a math library focused on interacting nicely with opengl, so it might be close to the old interface. I haven't used it myself though.

In Topic: deleting dynamic memory error

08 February 2012 - 03:10 PM

We would need more code/context to see. And what is the assert?

It could be that someone else is illegally writing in/around that memory block, going outside its bound and corrupting the heap, so the delete/free function can't find a valid memory block header or something like that.

In Topic: delete kills my operator=

30 January 2012 - 07:52 PM

In your constructor, name = "" makes it point to memory that is NOT heap-allocated (with new[]). It points probably to static memory. And you should NEVER delete this memory. You should strdupnew your empty string too.