2
\$\begingroup\$

I have some code for rendering a button in an application and I want to clip the text if it's wider than the button itself. Here a bit of code to describe what I'm doing:

GL.Enable(EnableCap.ScissorTest);
GL.Scissor(Frame.X, ScreenSize.Y - Frame.Y - Frame.Height, Frame.Width, Frame.Height);

RenderRect(Frame, Color.Red);
RenderText(Text, Color.White);

GL.Disable(EnableCap.ScissorTest);

I'm using OpenTK and QuickFont as the text rendering library. The main problem is, the rectangle gets clipped just like it should, but the text will render outside the scissor region if it's too long. I wondered what QuickFont was actually doing during the text rendering, but I couldn't find anything else than some GL.PushMatrix and GL.LoadIdentity calls that could interfere. Are these functions resetting the scissor test? Would a GL.PushMatrix call make it so that it would be possible to render outside the clipping rectangle?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.