max0180's picture

openTK + Tao.Freeglut

hi,

is it possible use Tao.Freegut in an OpenTK- Control?

and how?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Both Tao.FreeGlut and OpenTK.GLControl create OpenGL windows (stand-alone and inside WinForms respectively). Why would you need to use both at the same time?

Or maybe I misunderstood your question - do you want to use Tao.FreeGlut to create a window and OpenTK.Graphics for writing OpenGL code? If so, use OpenTK 0.9.0 or wait for the upcoming release.

max0180's picture

I only want to use freeglut for my 3d fonts!

is there an easier way to get 3d fonts?

openTK.Graphics (fonts) are "on top of the screen". I cant rotate the fonts in a 3D environment

the Fiddler's picture

Ah, then you might want to try out Tao.FtGl. It's specialized in text rendering and is simple to use.

Regarding Tao.FreeGlut, you might still be able to use it, provided it can be initialized without creating an OpenGL context. Its documentation should say if there is a way to achieve this (something like calling glutInit() but not glutCreateWindow()).

Edit: Also, do you need true 3d text (i.e. each glyph is a model built from vertices) or will rotated 2d text do? If it's the latter, OpenTK 0.9.2 will support this (i.e. you can choose to draw text inside the scene instead of on top).

haymo's picture

Ah, interesting. I had this requirement too (to draw text in world coords, no orthographic projection) I solved it relatively generic by using different renderers for it. But the result in world coords is still somehow suboptimal. most glyphs look blurry. Have you been able to improve this?

the Fiddler's picture

There are a couple of improvements regarding glyph placement and texture coordinates, but the effect is slight.

The real problem is that the typical 96dpi screen is too coarse to get good rendering at fractional pixel positions. There are three solutions:

  1. Snap text to whole pixels, which will result in crystal clear text at the expense of animation quality.
  2. Use subpixel rendering to triple the apparent resolution over simple grayscale. This is simply not possible with the current GDI+/OpenGL rasterizer in OpenTK(*).
  3. Use bigger font sizes. Above 16-18pt the steps grow thick enough that they are not affected that much.

The WPF text engine actually combines the first two: it does subpixel rendering and snaps text to whole pixels once it stops moving - but even so, many people complain about the results.

Unfortunately, you cannot have clear text and free transforms at the same time, not with current display technology.

(*) I actually did some tests with this, but GDI+ premultiplies the alpha channel with RGB, assuming a constant bg color. Even if you try to reverse that (you know the bg color, so it's possible), you end up with wrong gamma and the results are simply not good enough. I intend to play with this again in the future, but I think it's outside the scope of this project. On the other hand, true subpixel rendering would indeed help reduce the bluriness of transformed text.

haymo's picture

I see. Thanks. I assume, by "subpixel rendering" you mean something like 'cleartype'?
I guess solution 1 would work out fine for me. But how can one align vertices to framebuffer pixels - while rendering in world coords? (For performance reasons I cannot transform every vertex into screen coords nor vice versa.)