Results 1 to 5 of 5

Thread: C++ Exceptions & OpenGL performance

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Location
    Lancashire, England
    Posts
    18

    C++ Exceptions & OpenGL performance

    Hallo.
    Having only just recently got the hang of exceptions, I'm keen to utilise them, but I do know that there is some performance overhead associated w/ their use.
    I don't know how much, though.
    If I just ran everything in a try...catch block from the outset, would this effect speed too adversely (or at all)?
    Or would peolpe reccommend using assert until I'm very confident of my code, then turning it off?
    I hate passing bools everywhere, cuz I always lose track of them.
    Cheers for any input,
    Doug.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: C++ Exceptions & OpenGL performance

    Hi !

    The use of exceptions increase the size of the executable, but as long is not exception is thrown your code should run pretty much at the same speed as without the exception code.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2003
    Location
    Lancashire, England
    Posts
    18

    Re: C++ Exceptions & OpenGL performance

    Thanks alot, man - I'll get using them, then!
    Cheers,
    Doug.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: C++ Exceptions & OpenGL performance

    But be careful not to overuse them. Exceptions should be used for "exceptional" conditions -- things that are supposed to work but don't -- not as a substitute for return codes. Some examples (assuming you're developing a game):

    - If you can't open your game's .ini or .cfg file, that's an exception

    - If you fail to create a rendering context in Windows, that's an exception

    - If the player tries to open a door for the next room but it's locked, that's NOT an exception, it's an expected response.

    I work with Java programmers who throw exceptions around like return codes. Nothing more than a glorified "goto" if you use them that way.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2003
    Location
    Lancashire, England
    Posts
    18

    Re: C++ Exceptions & OpenGL performance

    Yeah - cheers, man.
    I'll only use them for major problems - good to hear a cautionary voice, nonetheless, cuz I have a lazy reflex like you wouldn't believe.
    Cheers,
    Doug.

Similar Threads

  1. Replies: 1
    Last Post: 04-29-2013, 03:38 PM
  2. OpenGL suppresses exceptions under Win 7 x64
    By fsgs2k in forum OpenGL: Windows
    Replies: 1
    Last Post: 01-29-2010, 05:05 PM
  3. Fatal exceptions with opengl and voodoo2
    By LordNikon in forum OpenGL: User Software
    Replies: 0
    Last Post: 02-12-2001, 12:05 AM
  4. C++ exceptions and performace
    By Succinct in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-25-2000, 10:09 PM
  5. Random silent GDI32 exceptions with OpenGL related functions
    By Voytec in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 06-27-2000, 12:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean