Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actuallipsryme

Posted 03 March 2013 - 06:47 AM

Hi hodgman,
Great post, the example with the material is actually how I did it but again with each one having a connection to each other.

But let's take the other example of let's say the application class that is being created inside the entry function.
Another question on the side. I've read that it's always preferred to create objects on the stack instead of the heap / dynamically allocated, with that in mind would it make sense to create the application class or components of my engine like the timer class as an object on the stack or a pointer to this object as a dynamically allocated object?

Now getting back to the example...when I think about the engine class I think about it having every single component inside it. Now let's say this class creates an instance of another class that also at one point creates a class that needs to have a reference of some kind to use functions of e.g. the timer class. So the best way of doing that would then be passing the timer class inside the second class, just so it can provide the third class with this reference ?

And why is it that I should pass regular types like floats or ints per value and not per reference? I thought you should always try to pass things by reference as doing it per value is much slower because it creates a copy of this object.

#2lipsryme

Posted 03 March 2013 - 06:47 AM

Hi hodgman,
Great post, the example with the material is actually how I did it but again with each one having a connection to each other.
But let's take the other example of let's say the application class that is being created inside the entry function.
Another question on the side. I've read that it's always preferred to create objects on the stack instead of the heap / dynamically allocated, with that in mind would it make sense to create the application class or components of my engine like the timer class as an object on the stack or a pointer to this object as a dynamically allocated object?

Now getting back to the example...when I think about the engine class I think about it having every single component inside it. Now let's say this class creates an instance of another class that also at one point creates a class that needs to have a reference of some kind to use functions of e.g. the timer class. So the best way of doing that would then be passing the timer class inside the second class, just so it can provide the third class with this reference ?

And why is it that I should pass regular types like floats or ints per value and not per reference? I thought you should always try to pass things by reference as doing it per value is much slower because it creates a copy of this object.

#1lipsryme

Posted 03 March 2013 - 06:46 AM

Hi hodgman,

Great post, the example with the material is actually how I did it.

 

But let's take the other example of let's say the application class that is being created inside the entry function.

Another question on the side. I've read that it's always preferred to create objects on the stack instead of the heap / dynamically allocated, with that in mind would it make sense to create the application class or components of my engine like the timer class as an object on the stack or a pointer to this object as a dynamically allocated object?

 

Now getting back to the example...when I think about the engine class I think about it having every single component inside it. Now let's say this class creates an instance of another class that also at one point creates a class that needs to have a reference of some kind to use functions of e.g. the timer class. So the best way of doing that would then be passing the timer class inside the second class, just so it can provide the third class with this reference ?

 

And why is it that I should pass regular types like floats or ints per value and not per reference? I thought you should always try to pass things by reference as doing it per value is much slower because it creates a copy of this object.


PARTNERS