Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


madRenEGadE

Member Since 01 Feb 2006
Offline Last Active May 14 2014 01:41 PM

Posts I've Made

In Topic: Cleaning up a vector of pointers?

10 May 2012 - 01:33 PM

Seeing as OP has commented multiple times they are not very strong with programming, this may be pointing them to a completely different direction, especially when I am under the impression that if they figure out this problem, they will learn more about memory management than they will from the moving to the new C++ standard.


You are totally right! The hard way is sometimes better (that's why we c++ nerds are often better programmers ;)

In Topic: Cleaning up a vector of pointers?

10 May 2012 - 12:37 PM

If you want to avoid manual deletion of the pointers you could use a vector of smart pointers instead of raw pointers. C++11 offers you std::shared_ptr.

In Topic: Is this a valid usage for unions?

09 May 2012 - 02:14 PM

Really good explanation!!!

So best choice for e.g vector normalization would be a free function in the Math namespace which takes a const reference to a vector and to have a member function
which does not take parameters but normalizes the vector instance itself?

In Topic: Is this a valid usage for unions?

09 May 2012 - 01:51 PM

Inlining would work, but IMO you're going to end up doing lots of work wrapping all the functions provided by glm without any real purpose

The purpose for me is that all my code looks consistent and that I could change the math library later on. And fortunately is is not that much work because I would just wrap the functions I actually need.

Thanks to both of you for the help Posted Image

In Topic: Is this a valid usage for unions?

09 May 2012 - 01:34 PM

Member functions would fit better to the rest of my code. But for the free functions I would rather like to use something like Vector3::normalize(v). So I would need to
use inheritance + static methods?! The typedefs would also be fine but Is it possible to typedef the free functions of glm (never done something like that)?

I think of:
namespace Math
{
	typedef glm::dvec3 Vector3;
	typedef glm::normalize Normalize;
};

Maybe I could just write inline functions for my desired "renaming":

namespace Math
{
	inline Vector3 Normalize(const Vector3& v)
	{
		return glm::normalize(v);
	}
}

PARTNERS