switch between flat and smooth shading

ShadeModelAttrib.MFlat is really designed to be applied to a model that was created with this attribute in mind. It makes each polygon render with the lighting indicated by its first (or sometimes last) vertex. A model that was created with this attribute in mind will store the polygon normal in that vertex position. However, a model that was created with smooth-shading in mind will store the appropriate vertex normal for each vertex position; the vertex normal will be close to, but not exactly, the polygon normal.

So, if you apply this attrib to a model that was designed for smooth shading, you will get a faceted appearance which will be close to, but not exactly, the appearance it would have if it were actually created as a faceted model.

But if all you’re looking for is a visual effect, there’s no problem with achieving it this way.

David