dg2d icon indicating copy to clipboard operation
dg2d copied to clipboard

Linux Support?

Open nordlow opened this issue 5 years ago • 12 comments

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.

nordlow avatar Oct 15 '20 10:10 nordlow

What would be better:

  • a solution based upon SDL and bindbc-sdl?
  • a X11 window implementation including the (unfortunately static) X11 bindings
  • keeping it as is?

p0nce avatar Oct 15 '20 12:10 p0nce

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.

cerjones avatar Oct 15 '20 17:10 cerjones

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

  • either we implement a x11 window but it's quite a lot of code, that will end up unmaintained
  • either we bring a SDL dependency, which is nice but also slow down people that just want to run the win32 example
  • arsd:simpledisplay could be an option too; possibly the simplest however configurations are used for platforms... which is an incorrect way to use dub https://github.com/adamdruppe/arsd/blob/master/dub.json#L53

p0nce avatar Oct 15 '20 18:10 p0nce

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.

cerjones avatar Oct 16 '20 23:10 cerjones

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

p0nce avatar Oct 17 '20 16:10 p0nce

Thanks, will have a look through it now.

cerjones avatar Oct 20 '20 22:10 cerjones

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.

p0nce avatar Oct 31 '20 13:10 p0nce

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.

cerjones avatar Nov 01 '20 18:11 cerjones

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

nordlow avatar Nov 03 '20 09:11 nordlow

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.

cerjones avatar Nov 03 '20 22:11 cerjones

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

WebFreak001 avatar Nov 12 '20 23:11 WebFreak001

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:

cerjones avatar Nov 13 '20 13:11 cerjones