• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Portability of PowerBASIC applications - GRAPHIC FONTS

Started by Chris Holbrook, August 26, 2013, 01:01:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Holbrook

Thinking ahead to when/if I need to port PB applications, I come up against GRAPHIC FONTS, which are not interchangeable with Windows fonts. Also, my alternative target platform is an as-yet-undefined ~UX whichh will have its own ideas about fonts, and if I use OpenGL to recreate my retro-looking forms, I find that fonts are undefined.

It would be really great to be able to leave all this stuff behind and just use one of the fonts built in to the VT (selectable by a dip switch), but that is a future to which we cannot yet return.

Any ideas?

Patrice Terrier

#1
Chris

On this link: http://www.jose.it-berater.org/smfforum/index.php?topic=4530.msg16884#msg16884
you can see 5 fonts in action altogether, some drawn in 2D (always facing the camera) and some in 3D.

The tip is to create on the fly a texture with the font you want to use, and render the font in the texture DC.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Chris Holbrook

Thanks again, Patrice.

Maybe someone should create a GDI-like library to sit on top of OpenGL. It could reduce the sum of human suffering more than the United Nations.

Brice Manuel

Chris:  How retro of a GUI you are wanting to create?  Crazy Eddie's GUI is very portable and works with OpenGL and can be skinned so you can get just about any look you would want.  I have only used the PureBasic implementation, but although it is aimed at games, it can be used for apps.  Personally, I prefer to write my own GUIs.

As to fonts, if you are using OpenGL, can't you use bitmap fonts, which would look the same on any system?

Patrice Terrier

QuoteMaybe someone should create a GDI-like library to sit on top of OpenGL. It could reduce the sum of human suffering more than the United Nations.

Hmm, by the way, this is what my GDImage is doing, using state of the art antialias, as you can see from the charting screen shot.

If you want to look at a few OpenGL examples, you can start with some of the BassBox plugins, that are available in PB source code from this forum.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Chris Holbrook

This thread has really got me thinking. My technical competence with graphics is about 25 years behind the curve. OTOH all I need is the primitive capabilities of a CGA graphics system (someone must remember that!).

The UI - as realised mostly using PB GRAPHICS - has the usual keyboard and mouse handling, and a modal window stack. Colours are all solid, I could get by with 16 colours. My framework comprises classes for each control type (not Windows controls). Applications use character, not pixel, coordinates, pixels are all behind the curtain, character sizes are taken from the font in use, one font per window/control. Proportional fonts are permitted. Controls are input boxes, hot keys (like buttons), list boxes, vertical menus, horizontal menus. Fonts and windows resize on a keypress. Literal text and static images are drawn direct on the window. My applications are boring old commercial and accountancy ones.

PB GRAPHICs are just a convenient wrapper for GDI. I could code a GDI class to do what I need in a couple of days.

Brice, thanks for mentioning Crazy Eddy's GUI, it may have possibilities. I see that it has some hooks for LUA, which is on my list of scripting languages to investigate. ISTR someone on the PB forums is/was quite keen on LUA.

I wonder how Free Pascal does simple graphics on non-Windows targets. ISTR that its screen painting was too slow on MSDOS, though that is unlikely still to be the case.


Brice Manuel

Quote from: Chris Holbrook on August 26, 2013, 11:28:03 PM
The UI - as realised mostly using PB GRAPHICS - has the usual keyboard and mouse handling, and a modal window stack. Colours are all solid, I could get by with 16 colours. My framework comprises classes for each control type (not Windows controls). Applications use character, not pixel, coordinates, pixels are all behind the curtain, character sizes are taken from the font in use, one font per window/control. Proportional fonts are permitted. Controls are input boxes, hot keys (like buttons), list boxes, vertical menus, horizontal menus. Fonts and windows resize on a keypress. Literal text and static images are drawn direct on the window. My applications are boring old commercial and accountancy ones.

I was using PB Graphics in the past for a custom GUI for an old project.  However, I am using PB for a new project and I am using a combination of EZSprite and PB Graphics for the GUI.

Chris Holbrook

Quote from: Chris Holbrook on August 26, 2013, 11:28:03 PMI wonder how Free Pascal does simple graphics on non-Windows targets.
Hm, looks like OpenGL.

Brice, mine is a sprite-free zone. Animating the figures would only upset the users!

Brice Manuel

Quote from: Chris Holbrook on August 27, 2013, 12:13:19 AM
Brice, mine is a sprite-free zone. Animating the figures would only upset the users!

I am not using any animation.

Chris Holbrook

#9
Font rendering - this link helps me to understand Patrice's advice re. textures: http://www.opengl.org/archives/resources/faq/technical/fonts.htm

This looks promising: Glut http://www.opengl.org/resources/libraries/glut/

Christopher Boss

EZSprite is not about games, nor animation. It is about integrating non-rectangular graphic objects into the PB graphic control. The sprites are kept separate from the PB graphic controls image buffer and they are merged together during the controls WM_PAINT message. This allows you to move graphic objects around the control without corrupting the controls image buffer.

One could use sprites for button controls or some other UI element on the PB graphic control. There is hit testing (collision testing in sprite terms) included so you can determine which sprite object a mouse clicked on. Alphablending allows you to do some fancy tricks in a GUI too. Someone with a lot of imagination could build a totally unique UI using just the graphic control and sprites.



Brice Manuel

Quote from: Christopher Boss on August 28, 2013, 03:28:33 AM
EZSprite is not about games, nor animation. It is about integrating non-rectangular graphic objects into the PB graphic control. The sprites are kept separate from the PB graphic controls image buffer and they are merged together during the controls WM_PAINT message. This allows you to move graphic objects around the control without corrupting the controls image buffer.

One could use sprites for button controls or some other UI element on the PB graphic control. There is hit testing (collision testing in sprite terms) included so you can determine which sprite object a mouse clicked on. Alphablending allows you to do some fancy tricks in a GUI too. Someone with a lot of imagination could build a totally unique UI using just the graphic control and sprites.

You left out anti-aliasing which is also very beneficial to custom GUIs.  Custom GUIs are one of the reasons I bought EZSprite and requested certain features when it was being developed.  At the end of the day, a sprite is simply an image and does not need to be animated or moved.  EZSprite simply makes it easier to interact with an image, which is why it is the backbone of my custom GUI system.  EZSprite is also very useful for custom font systems. 

I only mentioned it to Chris Holbrook because I have "been there" and this was a solution that fit my needs. 

Chris Holbrook

Chris and Brice, forgive me for applying my understanding of the term "sprite"** to EZsprite. what I'm aiming for is a migration path for some legacy applications, using as far as possible the same code on Windows and ~UX. My requirements are minimal and it seems that they can be satisfied entirely using the OpenGL library. As it happens, I have prototyped the UI using PB's GRAPHIC features, and I will probably use this UI as part of a PowerBASIC application in my initial W7 version.

Although I have played with sprites (see DIB class posted elsewhere)  they have never been part of my commercial work.

** "In computer graphics, a sprite ... is a two-dimensional image or animation that is integrated into a larger scene." Wikipedia, "Sprite (computer graphics)

James C. Fuller

Chris,
  I suggest you do your homework if you plan a Linux port using a gui library.
None of the cross platform libraries; Gtk, wxWidgets, IUP, FTLK, Qt, ... position controls the way you are used to with Windows. There is no exact x,y positioning. Everything is a box within a box within a box .....
While there are exact placement api's it is not the norm and is frowned on.

James

Chris Holbrook

Quote from: James C. Fuller on August 28, 2013, 03:14:47 PMI suggest you do your homework if you plan a Linux port using a gui library.
Thanks James,  I don't plan to use them. I'm writing a class based on OpenGL which provides a suitable subset of GRAPHIC functionality. When it is working, I will port it to Free Pascal and try it out on Debian. Then I will have some idea of the issues.