Jump to content
  • Advertisement
Sign in to follow this  
Plumder

QUERY ~ C++ Updating Graphics

This topic is 2138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!