Graphics/font/platform backends with common interfaces?

Vadim Lopatin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 25 00:30:04 PST 2015


On Wednesday, 23 December 2015 at 19:22:01 UTC, Taylor Hillegeist 
wrote:
> So I have seen alot of projects that need the same sort of 
> stuff.
>
> graphics libraries
> gui libraries
> game libraries
> ploting libaries
>
> they would all benefit from a backend solution with a common 
> interface for
>
> color
> fonts
> drawing pen_style aliasing etc.
>
> but each one i look at seems to have a built up solution with 
> various degrees of integration with things like freetype gdi 
> cairo sdl glew opengl.
>
> Shouldn't there be like a common (interface/abstract class) 
> that these back-ends can fulfill? maybe I am unaware of how 
> these things are done. And perhaps there are performance 
> reasons that many of these are baked in.
>
> perhaps it should be like:
>
> standard color implementation.
> font interface that converts glyphs into drawing strokes.
> and a standard set of drawing instructions with transforms.
>
> //probably a grotesque simplification
>
> interface font_do{
>   glyphstrokes getstrokes(string characterstoget);
> }
>
> interface draw_do{
>   drawpixel(double x,double y);
>   drawline(double x,double y);
>   drawglyph(glypstrokes g);
>   getpostdrawnsize(glypstroks g)
>   ... other things
> }

I can consider splitting of DlangUI library into platform and 
widgets.
Platform will provide window creation, initialization of OpenGL 
context when necessary, keyboard and mouse events, user events. 
As well, it has font support - FreeType and on Windows it can use 
native Windows fonts.

Currently supported platforms:
Windows: Win32 API or SDL
Linux, OSX: SDL or X11
I'm planning to make Cocoa (native OSX) and Wayland (for Linux) 
support later.



More information about the Digitalmars-d-learn mailing list