Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

wip: expose gl_proc_addr and remove hard dependency on skia #12

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

limikael
Copy link

@limikael limikael commented May 3, 2023

This is an early work in progress test, just for discussion...

It is only implemented for X11 with glx... It will crash on X11/egl and Wayland, and on other platforms not even compile...

but at least the (modified) skia example starts and runs (for me)...

take a look...

@limikael
Copy link
Author

limikael commented May 3, 2023

Oh will also look at https://github.com/loki-chat/lokinit/pull/11 and see how I should do things different...

@limikael
Copy link
Author

limikael commented May 4, 2023

Added the functionality in #11. However, since the window is a global thing, and especially since the from_gl_loader already relies on it when it does window::screen_size(), there is no need for the function to take the loader function as parameter. It can simply get it as window::get_gl_proc_addr. So the signature of the function from_gl_loader is now simply:

pub fn from_gl_loader()->Self

@limikael
Copy link
Author

limikael commented May 4, 2023

alright... the X11 stuff (both glx and egl) is now considered something like release candidate level, so give it a test please...

The other platforms still remain though...

@limikael
Copy link
Author

limikael commented May 4, 2023

Moved all skia specific code into the skia example. Also made skia a feature and skia-safe an optional dependency.

Skia is only needed for the example, so it would actually be nicer if it wasn't a dependency at all. but in that case, I don't think skia can be a proper rust example. Because... I don't think there is actually any way whatsoever to a dependency specific to one single example. Or is there?

The mouse_cursor and window_conf examples have been updated to not use skia, but to use gl instead.

@limikael
Copy link
Author

limikael commented May 4, 2023

yey got it to work for windows as well, tested under wine. (i could not get skia to compile, but at least it works with gl. fairly confident it will work with skia too, but could be good to test).

rust is really cool! all you need to do on linux to test it provided you have your env set up is:

cargo run --target x86_64-pc-windows-gnu --example mouse_cursor

@limikael
Copy link
Author

limikael commented May 5, 2023

Android implemented and tested with the examples... The state of the implementation is now:

  • Android
  • Windows
  • Linux X11 & Wayland
  • iOS
  • MacOS

@limikael
Copy link
Author

limikael commented May 5, 2023

If someone wants to take a stab at the Mac/iOS stuff, this is roughly what needs to be done:

  1. Remove all the skia related stuff, i.e.:
    • Don't create any skia context in the native code.
    • Change all places where the event handler is being called and remove the skia argument from the calls.
  2. Create a closure that can get a open gl proc addr. On Android it is done here: https://github.com/limikael/lokinit/blob/c7ddf2ba2ba5b8ea6fd2f93521324c205a0b4f30/src/native/android.rs#L454 But I think it will be slightly easier on iOS/Mac because there seems to be a global function get_proc_address so maybe just use that one? There is similar code where the skia context is created, so that can be a source of inspiration. Also check the other implementations. I think the Windows one is quite straight forward but the Linux one is more hairy.
  3. Implement get_gl_proc_addr in the NativeDisplay implementation. On Android it is done here: https://github.com/limikael/lokinit/blob/c7ddf2ba2ba5b8ea6fd2f93521324c205a0b4f30/src/native/android.rs#L178

Then, check if the window_conf and mouse_cursor examples will compile and run. They don't use get_gl_proc_addr so it can be a good starting point, just to isolate potential sources of errors. Then... Check if the external_gl and skia examples run.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants