TextPrinter implementation [commited]

I read the code of the Utilities / TextPrinter, because I need a similar Begin() / End() state saving. In Begin() I see that you are calling:

//...
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
//...

I think this changes the current BlendFunc, which won't be reset afterwards in End()? Maybe it would be better to call

GL.PushAttrib(GL_COLOR_BUFFER_BIT);

before and GL.PopAttrib(GL_COLOR_BUFFER_BIT) in End().
See ManPage PushAttrib

And why is the viewport member defined to have the length 6? The viewport could only contain 4 floats or am I wrong?
See ManPage GlGet

Edit 04-07-2008:
Added tiny patch for TextPrinter:

GL.PushAttrib(AttribMask.TextureBit);
GL.PushAttrib(AttribMask.EnableBit);
GL.PushAttrib(AttribMask.ColorBufferBit);

changed to:

GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit);

This reduces the 6 calls for push / pop to 2 calls. Not that much, but better than none.

AttachmentSize
TextPrinter.zip411 bytes

Comments

Re: TextPrinter implementation
posted by the Fiddler

Thanks, good catches. Fixed.

Re: TextPrinter implementation
posted by teichgraf

I added a tiny patch to the first post (see above).

Re: TextPrinter implementation
posted by the Fiddler

Thanks, implemented. Every little bit helps :)

You forgot to change the TextPrinter.End() method from

...
GL.PopAttrib();
GL.PopAttrib();
GL.PopAttrib();
...

to one Pop.

...
GL.PopAttrib();
...

As a result I get a StackUnderflow OpenGLError, because we do just one GL.PushAttrib(...);

Oops!