Sign in to follow this  
Plumder

QUERY ~ C++ Updating Graphics

Recommended Posts

Plumder    111

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

Share this post


Link to post
Share on other sites
Jason Z    6434

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this