Performance on state change

I create a childish engine for an opengl gui.
Abstract classes are ParagraphGL and FontGL and there are many implementations. For instance, for FontGL there is a VectorFontGL implemented with GL_LINES and a TextureFontGL implemented with textures.
ParagraphGL can use any type of FontGL.

Because ParagraphGL doesn’t know nothing about FontGL, it must use the following lines inside FontGL code. This means very often state change.
How this cost the performance?

glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Depends on your hardware and driver.

But think of it this way, the first two are telling OpenGL which fragment shader permutation to use. The latter two are configuring how the blend unit after the fragment shader behaves.

Generally speaking you want to avoid redundant state changes, because there’s no guarantee that the driver will do it for you. For instance, it could be that every time you execute the above two, the entire GPU pipe comes to a halt and you take the expense of switching shaders. But if you detect that they’re redundant and suppress calling OpenGL in these cases, then the GPU doesn’t need to stop and reconfigure everything. It can just keep ripping.