cerjones / dg2d

Boost Software License 1.0
19 stars 4 forks source link

Linux Support? #6

Open nordlow opened 3 years ago

nordlow commented 3 years ago

dun run under demo fails as

source/window.d(43,9): Error: undefined identifier LRESULT
source/window.d(43,9): Error: undefined identifier HWND
source/window.d(43,9): Error: undefined identifier UINT
source/window.d(43,9): Error: undefined identifier WPARAM
source/window.d(43,9): Error: undefined identifier LPARAM
source/window.d(71,17): Error: undefined identifier HWND
source/window.d(72,17): Error: undefined identifier DWORD
source/window.d(73,17): Error: undefined identifier DWORD
source/window.d(82,22): Error: undefined identifier HINSTANCE
source/window.d(84,14): Error: undefined identifier UINT_PTR
source/window.d(204,13): Error: undefined identifier LRESULT
source/window.d(204,13): Error: undefined identifier HWND
source/window.d(204,13): Error: undefined identifier UINT
source/window.d(204,13): Error: undefined identifier WPARAM
source/window.d(204,13): Error: undefined identifier LPARAM

Are there any plans for Linux support?

I'm sitting on Ubuntu 20.04.

p0nce commented 3 years ago

What would be better:

cerjones commented 3 years ago

Tbh I've never used linux so wouldn't know where to start. The only platform specific stuff is the main even loop and the Window class and a few bits that support that. I think I kept all the platform specific stuff in window.d, but there is some stuff that could be moved out into a separate module to make window.d even smaller, then I guess it's just making a linux version of that module. Assuming linux apps work similar to windows. So i have no problem with adding it if someone wants to do it, but I dont think i have the time to do it myself.

p0nce commented 3 years ago

Honestly sounds more debt than it is worth. Examples need to be maintained, and in this case:

cerjones commented 3 years ago

I'll need linux support when I come to test it on Arm i think, so if nobody has done it by then I'll look into it. Tbh all it needs is a window on screen, paint events, mouse clicks, and a message loop, just the bare bones.

p0nce commented 3 years ago

Just in case. This is a small app that displays to SDL2 using dplug:canvas (a dg2d fork). It could be useful to copy code from in case you need a SDL-based example in dg2d.

SDL2 + dg2d.zip

cerjones commented 3 years ago

Thanks, will have a look through it now.

p0nce commented 3 years ago

I had tried building an example with SDL, but there is a fundamental difference: you'd have to forego local screen update (Invalidate and WM_PAINT) to perform a full screen update at all times. So it's also about what do you want @cerjones from the example.

cerjones commented 3 years ago

The demo its just a demo, it's not intended as actual code anyone might use in production so it doesn't really matter i think. Ill probably get around to making a linux window at some point, but to be honest haven't had much time to do anything lately.

nordlow commented 3 years ago

What about making the rendering API of dg2d operate on a pixel buffer (perhaps with different format and orderings but defaulted to RGBA32) that can be queried from the window API such as SDL or Wayland [1]?

[1] https://wayland.freedesktop.org/docs/html/apb.html

cerjones commented 3 years ago

The rasterizer takes a externally supplied pixel buffer, the Canvas can be made to do so too no problem. There are a couple of requirements though... 32 bit ARGB, alpha in high 8 bits 16 byte alignment for the start of each scanline

The order of RGB could be different, but to have the alpha in say the low 8 bits would mean a fair bit of work.

WebFreak001 commented 3 years ago

made a quick and dirty x11 version in #9 to try out, but I think the demo should rather focus on rendering than on windowing backends

cerjones commented 3 years ago

Awesome thanks, tbh I haven't had time to look at it yet but hopefully tonight / tomorrow maybe, just want to check it out on my system before I merge it. Yeah the demo stuff is really just for development / testing purposes, I have no intention of windowing being part of the main lib. Thanks again :+1: