a way to save opengl default states and restore them

this could be a little bit off-topic, but does anyone know a way how I cn save and restore mos of opengl’s states? I know the glpushattrib/glpopattrib stuff, but here is the problem, I want to do the following:

save default
do something
save new states
restore default states
do something
restore new states

best regards,

You could always use the gl-getter-functions manually? This would probably be slower than pushattrib, but my guess is you don’t have to do this kind of operation very often?

You could write your own class that saves and restores the state.