QUERY ~ C++ Updating Graphics

Started by
0 comments, last by Jason Z 10 years, 4 months ago

Hey folks, I was thinking about two possibilities of updating graphics and other things, and I wondered what the best option may be.

The first idea was to create a thread for each update (One for graphics, one for physics, and perhaps one for keeping time).

This may be very helpful as it should, in theory, update everything at the same time.

Surely, this would have some strain on the GPU and CPU, especially if there are hundreds of thousands of polygons being rendered while doing the math for physics etc...

The second idea is more simple. Create a class which looks like so:

class Foo
{
public:
Foo(){}

~Foo(){}

void operate(){}

}

Now, class A, B, C could be used via polymorphism with Foo to update a certain part of the game, like so:

class A : public Foo
{

public:
A(){/*Do stuff*/}

A(){/*Do stuff*/}

void operate()
{/*Update graphics*/}

}

class B : public Foo
{

public:
B(){/*Do stuff*/}

B(){/*Do stuff*/}

void operate()

{/*Update Physics*/}

}

class B : public Foo
{

public:
B(){/*Do stuff*/}

B(){/*Do stuff*/}

void operate()
{/*Update time-keeping*/}

}

Which method would you recommend for casual use?

Is there a better alternative to both of them which I'm too blind to realise?

Help would be appreciated. happy.png

Advertisement

Are those two concepts supposed to be mutually exclusive? There is nothing saying that you have a class hierarchy and at the same time have a multithreaded update phase. Usually the problem with doing an update of different systems on each thread is that you are updating the same set of objects (different aspects of your game objects), which requires careful synchronization.

So for casual use, I would recommend not using threads at all - just use a simple single threaded architecture.

This topic is closed to new replies.

Advertisement