help on shading toggle

i am drawing a set of primitives to random positions on the screen. spacebar is meant to toggle between smooth and flat shading but when i hit space it clears the screen(and also changes the shading mode for the next primitave)how do i change the shading of the shapes already drawn without clearing them?
any help would be great. thanks

Sounds like you are drawing them directly to the screen without an actual redisplay of previously rendered objects.

You will have to rerender all your objects after changing shading mode. It only affects objects rendered after the call.