Original Post
Hey, I am currently working on an 2d opengl-wrapper and I want to be able to switch between immidiate-mode and a cached mode, by calling a method (eg. CoreObject.SetMode(ogl_immidiate) or something). the drawing functions should stay the same (CoreObject.DrawImage(...);). I could just do a simple if-statement like: CoreObject::DrawImage(..){ if(immidiate_mode) TexMapImmidiate(..); else TexMapCached(..); } or I could have a member-function-pointer to the fundamental drawing-routines and do it like this: CoreObject::DrawImage(..){ (this->*TexMap)(..); } where the pointer either points to TexMapImmidiate() or TexMapCached() and is only change when SetMode is called. This way I wouldn't have to do the if-statement on every call. My question is: is it faster to dereference the member function pointer or to evaluate the if-statement? I know, it makes a *very* marginal difference, but I have to decide this now. Or which of this ways of solving the problem would you consider "cleaner"? thx