Hey all,
I know that to save/restore matrix state you use standard push/pop operations. I haven't been able to find a decent convention for saving/restoring state such as when using glLineWidth() or glColor4ub().
It seems not really necessary as long as you set your line width or color up properly whenever you want to draw anything but I can see an example of where you are in your own drawing function, call some separate drawing function that changes the line width on you without your knowledge, and then when you go to continue drawing have it come out not as expected.
To fix that you can reset your line width after you call any function that you don't know what it does but that seems inelegant and I feel that there should be already be a solution to this but that I've missed it somehow.
For my own code I've been doing this at the beginning of every drawing function:
GLfloat savedLineWidth = 1.0f;
glGetFloatv(GL_LINE_WIDTH, &savedLineWidth);
glLineWidth(lineWidth);
And then restoring the state at the end of the drawing function like so:
glLineWidth(savedLineWidth);
That doesn't really help me though unless I assume that every drawing function that I don't know the insides of is nice and restores the state on its own.
Should I make that assumption? Or am I missing something?