Direct3D Engine Design

Started by
11 comments, last by mumpo 19 years, 6 months ago
AP was me.
[size=2]aliak.net
Advertisement
Thanks for the info. I am making a graphics manager class that has an add() method that I can add an object into. Right now the only way I can think of it is to have a vector like this

std::vector<Rectangle> m_Rect;

and then the add method would be

graphicsManager::add(Rectangle *Rect){

std::vector<Rectangle>::iterator it = m_Rect.end();

m_Rect.insert(it, &Rect);

}

But it comes up with an error saying the 2 param in the insert method needs to be const Rect &. I don't want to make a new instance, I just want to pass in an instance of the Rect I made in my init function. And then have my graphics manager handle rendering. But I still want to change my rectangle properties in my game loop and not worry about my graphics manager. Is there a better way to do this?
Quote:Original post by andyb716
Thanks for the info. I am making a graphics manager class that has an add() method that I can add an object into. Right now the only way I can think of it is to have a vector like this

std::vector<Rectangle> m_Rect;

and then the add method would be

graphicsManager::add(Rectangle *Rect){

std::vector<Rectangle>::iterator it = m_Rect.end();

m_Rect.insert(it, &Rect);

}

But it comes up with an error saying the 2 param in the insert method needs to be const Rect &. I don't want to make a new instance, I just want to pass in an instance of the Rect I made in my init function. And then have my graphics manager handle rendering. But I still want to change my rectangle properties in my game loop and not worry about my graphics manager. Is there a better way to do this?


The way I handle this sort of thing is to have a linked list with the data type of type Rectangle*. Then I just insert() a new link into the list and set that element equal to Rect. I use a custom linked list class that has served me well; it doesn't force the Rectangle* to be constant so there is no problem with that. However, there is probably a good way to do this with the std lib, but I admit I'm not as knowledgable about it as I should be so there is probably a better way to do it.

IFooBar -- I totaly agree about the messing up thing; the way I get class heirarchies right is by trial and error.

This topic is closed to new replies.

Advertisement