Thread: Splitting hairs again

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428

    Splitting hairs again

    Hey,

    I am sure I am just splitting another hair here, but is there a significant computational difference between looking at a class's public member vs calling one of its functions?

    Basicly every class in my game has a
    Code:
    public:
       bool Active;
       void Draw(SpriteBatch SB);
    Then in the game I have a function Draw() where I have two options for checking to see if I should drawn an object... I wasn't sure if they were computationally equivalent so I figured I'd ask.

    first option
    Code:
    void Draw()
    {   
      if(ThisObject.Active)
        ThisObject.Draw(spriteBatch);
    }
    This turns into ALOT of iffs in my draw code and I was starting to get annoyed by it.
    Second option is to put the check within the Object.Draw(SB) fuction and then in the game Draw() code only call.

    Code:
    void Draw()
    {
      ThisObject.Draw(spriteBatch);
      ThatObject.Draw(spriteBatch);
      // ect
    }
    So basicly which is taking more process power?
    ThisObject.Active || ThisObject.Draw#SB)
    Last edited by Lesshardtofind; 12-08-2012 at 07:21 PM.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Splitting text
    By ripspinner in forum Windows Programming
    Replies: 1
    Last Post: 12-13-2009, 04:15 PM
  2. Argh! *pulls out hairs* Please help me.
    By Athildur in forum C++ Programming
    Replies: 14
    Last Post: 04-04-2007, 12:30 PM
  3. Splitting the Window
    By cweb255 in forum Windows Programming
    Replies: 4
    Last Post: 05-30-2005, 06:19 AM
  4. VCD splitting?
    By Fountain in forum Tech Board
    Replies: 4
    Last Post: 07-03-2003, 11:15 AM
  5. Splitting
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 08-02-2002, 04:08 PM