opcon / QuickFont

A Modern OpenGL Font Rendering Library for OpenTK
https://github.com/opcon/QuickFont
MIT License
83 stars 25 forks source link

Maintaining same size for the text #46

Open tNRevan opened 5 years ago

tNRevan commented 5 years ago

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?

opcon commented 5 years ago

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

tNRevan commented 5 years ago

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