Graphics Library for D

Adam Wilson flyboynw at gmail.com
Mon Jan 6 22:17:24 PST 2014


On Mon, 06 Jan 2014 07:49:27 -0800, Ola Fosheim Grøstad  
<ola.fosheim.grostad+dlang at gmail.com> wrote:

> On Monday, 6 January 2014 at 04:11:07 UTC, Adam Wilson wrote:
>> The logical phases as I can see them are as follows, but please suggest  
>> changes:
>>
>> - Windowing and System Interaction (Including Keyboard/Mouse/Touch  
>> Input)
>> - Basic Drawing (2D Shapes, Lines, Gradients, etc)
>> - Image Rendering (Image Loading, Rendering, Modification, Saving, etc.)
>> - 3D Drawing (By far the most complex stage, so we'll leave it for last)
>
> I suggest you start working the other way. Because if you want  
> performance you will most likely want everything in the render path to  
> be based on shaders:
>
> 1. Fonts and monochrome icons based on distance-fields.

Typically it's easier to use TrueType/OpenType fonts. Although Pathing  
support for icons is a must.

> 2. All fills based on shaders, with the ability to convert D into GLSL  
> etc.

If possible I want to hand this off to a system library like OpenGL or  
DirectX.

> 3. Render to texture, with caching mechanism.

My understanding is that it is best to let the GPU drivers handle caching,  
but somebody with Game Dev experience might be able to shed some light.

> 4. Simplistic mesh rendering from native D arrays.

Good idea.

> 5. The ability to attach native 3D code paths (GL/DX) to the engine for  
> advanced meshes.

Good idea.

>
> Then you build 2D on top of this.
>
> Rendering and input should be completely separate.

While I can't speak for the OpenGL library, from a performance standpoint  
using 3D drawing for 2D surfaces is actually not an efficient method for  
anything other than perfect square, as soon as you want curves performance  
tanks. Microsoft actually built an entire 2D/3D rendering engine using  
DirectX9 called MilCore. Now, DirectX9 has no native 2D capability and  
MilCore is the rendering core for WPF. So how did they draw a 2D circle?  
They draw over 1000 triangles. Needless to say that if you do this a few  
dozen times you tank GPU performance on anything less than a discrete GPU  
of some expense.

On Windows, we have access to Direct2D, which does not have those  
limitations. And Direct2D will inter-operate with Direct3D seamlessly.

-- 
Adam Wilson
IRC: LightBender
Aurora Project Coordinator


More information about the Digitalmars-d mailing list