* * *

Author Topic: An opengl canvas with signed distance fonts  (Read 4461 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
An opengl canvas with signed distance fonts
« on: November 28, 2015, 06:01:19 pm »
In the past I've dropped hints that I was working on something OpenGL, well, here it is :-)

It is a simple texture with a layered overlay of primitive types (text, rectangles, lines, circles) with pan and zoom, optimized for speed in camera/vision applications. One overlay overlays the picture, one functions as HUD.

The font support is based on signed distance fonts. The test project is not multiplatform (so windows only, win64 should be ok), though many units are relatively platform independent.

http://www.stack.nl/~marcov/standaloneglv3.zip
(exe and source)

Requires Delphi XE3+ or FPC 3.1.1+/Lazarus trunk.   FPC3.0 might work, but requires the only recently committed new records-with-methods versions of TPoint(f) and TRect(f), so won't work out of the box
« Last Edit: December 05, 2015, 02:01:36 pm by marcov »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: An opengl canvas
« Reply #1 on: November 30, 2015, 01:29:32 pm »
Many thanks for sharing your code. But I wonder that yours as well as many other OpenGL toolkits is based on dglOpenGL instead of TOpenGLContext which is part of the FCL. It adds a lot of unnecessary dependency and incompatibility. For instance, if I want to adopt one your font classes I cannot just add it. I'd rather have to read and understand the code in order to replicate it for my project.
And having a project that is "not multiplatform" contradicts the idea of Freepascal, IMHO.

Please don't read the text as an insulting. To me it's a pity that a lot of work is done for nothing.
Lazarus 1.7 (SVN) FPC 3.0.0

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: An opengl canvas
« Reply #2 on: November 30, 2015, 02:33:50 pm »
Many thanks for sharing your code. But I wonder that yours as well as many other OpenGL toolkits is based on dglOpenGL instead of TOpenGLContext which is part of the FCL.

Afaik topenglcontrol is a separate component (in components/) and not part of the LCL, let alone the FCL)

But that doesn't matter, the reason is very visible in the original post, it can be compiled with Delphi, so unnecessary Lazarus components are avoided (besides, the codebase is older than the topenglcontrol component)

Quote
adds a lot of unnecessary dependency and incompatibility. For instance, if I want to adopt one your font classes I cannot just add it. I'd rather have to read and understand the code in order to replicate it for my project.

Well, if you think TOpenGLControl is great, port it to Delphi and have it added to dglopengl? If you want to make it universal, make sure it is available everywhere.

Quote
And having a project that is "not multiplatform" contradicts the idea of Freepascal, IMHO.

IMHO that is nonsense. The FPC packages and even RTL have many units that are only for one OS (-type). Yes, some common functionality is abstracted, but not all code (and even less, user's) should be multiplatform.

We are not Java with a state-in-a-state abstraction.

(though strictly speaking it quite portable, since many font solutions are based on ported X packages  and this one is not)

Quote
Please don't read the text as an insulting. To me it's a pity that a lot of work is done for nothing.

IMHO it is a redundant since the original post made the delphi and windows usage clear.  You can port it to openglcontrol and other OSes if you like/need that. 

I might test multi-OS myself one day for fun, but it is not a priority.  I've no interest in openglcontrol, unless it is ported, I think the pascal opengl community is too small to fragment
it unnecessarily over Delphi and FPC.

« Last Edit: November 30, 2015, 04:16:11 pm by marcov »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: An opengl canvas
« Reply #3 on: November 30, 2015, 03:32:53 pm »
Okay, if you start from Delphi it makes sense. I didn't touch it after 2.0. Good point to understand why people do things differently.
Lazarus 1.7 (SVN) FPC 3.0.0

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: An opengl canvas
« Reply #4 on: November 30, 2015, 03:50:39 pm »
Interesting code marcov.
I just talking about OpenGL GUI in MailList and I dont know your system can help it ot not.
Can you explain more or maybe check MailList?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: An opengl canvas
« Reply #5 on: November 30, 2015, 04:22:01 pm »
Interesting code marcov.
I just talking about OpenGL GUI in MailList and I dont know your system can help it ot not.
Can you explain more or maybe check MailList?

This is not an opengl gui or even going in that direction.  It is reasonably modern opengl use though, and if you would like an opengl GUI, you could maybe
reuse code, specially the font support. But currently it doesn't even feature wrapping (because it is an "infinite" canvas)

Moreover this demo requires quite modern GPU hardware (geometry shaders), only to accelerate uploading, and many older Socs don't do geometry shaders (or not efficiently)

So probably only as an help to learn a bit more advanced (and that depends on viewpoint) OpenGL




aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: An opengl canvas
« Reply #6 on: November 30, 2015, 04:23:44 pm »
Thank you.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: An opengl canvas with signed distance fonts
« Reply #7 on: March 17, 2016, 10:45:25 am »
I haven't done much on this the last two months, but in january I found that you can improve the look of the fonts significantly by playing with the discard cutoff in the newtextfrag shader source.

Locally I changed it from .1 to .4 and that made the fonts more streamlined andbetter looking.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus