Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


QUERY ~ C++ Updating Graphics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Plumder   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 December 2013 - 08:00 AM

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



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5164

Like
0Likes
Like

Posted 15 December 2013 - 02:42 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS