opcon / QuickFont

A Modern OpenGL Font Rendering Library for OpenTK

Home Page:https://github.com/opcon/QuickFont

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maintaining same size for the text

tNRevan opened this issue · comments

I am creating a CAD-like application. In the application, there needs to be numbers near a scale. I need the numbers to have always the same (screen) size independent of the current zoom. It uses a orthographic projection in this way CreateOrthographic(WindowWidth / ZoomScale, WindowHeight / ZoomScale, ZNear, ZFar); I set the matrix to the QFontDrawing.ProjectionMatrix. But now the text also gets scaled when the user zooms in. Is there a built-in way how to do this? Or do I have to do it myself using some matrix-magic?

Hi,

If I understand correctly, I believe the best way to do this is with 2 separate projection matrices. One for your zoomed world, and a separate for the unzoomed text. The matrix you pass to QFontDrawing.ProjectionMatrix does not need to be the same matrix you use to draw the rest of your world. However you may run in to issues with the position of the text - I am not sure.

If you want to attach a screenshot, I may be able to provide some more specific advice.

Cheers

Hello,

thank you for the advice. That's actually what I've tried, but as you say, then there is a problem with the position. I've tried to use CreateOrthographic(WindowWidth, WindowHeight, ZNear, ZFar) projection for the text - If you pan the camera, the geometric objects move with a different amount than the text. I think the solution would be to multiply location of the text, but not the location of the individual vertices it consists of.

Here's a screenshot showing the order of individual parts:
image