cococry / leif

Minimal, configurable & GPU accelerated Immediate Mode UI Library written with modern OpenGL
836 stars 36 forks source link

GLAD is platform specific #2

Closed gruelingpine185 closed 1 year ago

gruelingpine185 commented 1 year ago

From my understanding, GLAD is platform specific. Maybe write a section in your README to let users know that they'll have to download a version for their platform from https://glad.dav1d.de/. Same principal goes to the future dependancies. I guess, in addition to above, add it to your .gitignore so that way everyone wont have to re-download GLAD for their system every time a change to the repo occurs.

cococry commented 1 year ago

Yes so eventually, the library will just be a single c and h file that you can include to your build. You then have to handle the dependencies yourself. There will probably also be compiled libraries for the different platforms with that you can link. So the glad part will be handled by the user and prebuild for the specific platform

RHL120 commented 1 year ago

Hmm, I wonder if they have an API that can be used to download GLAD on-build with curl, wget or something like that. Would this be something you would accept? PS: I don't see anything platform specific in their options but even if it is not platform specific it would be better to download the deps on-build instead of having them bundled with the repository IMHO.

gruelingpine185 commented 1 year ago

I don't think they have an api for that. I was wondering the same thing too. I'll ask

gruelingpine185 commented 1 year ago

Here is the Issue I created: https://github.com/Dav1dde/glad/issues/435

RHL120 commented 1 year ago

I don't think they have an api for that. I was wondering the same thing too. I'll ask

When you hit the generate button a POST request is made to /generate with the following example content: language=c&specification=gl&api=gl%3D4.6&api=gles1%3D1.0&api=gles2%3Dnone&api=glsc2%3Dnone&profile=compatibility&loader=on

gruelingpine185 commented 1 year ago

from that, i can't just tack on ...&platform=macos can I? Is there docs for that?

RHL120 commented 1 year ago

from that, i can't just tack on ...&platform=macos can I? Is there docs for that?

I don't think there is an option for macos. As a side note I don't think there is anything OS specific in there. files are just C as far as I can tell. I don't think there are any docs I just used used the network tab in the dev tools on my browser but if you would like to know more the source code would probably be a good place to start: https://github.com/Dav1dde/glad-web/blob/f2659ebfb9e54b9d72c0cb806c8a27724f8719bf/gladweb/views/index.py#L116

gruelingpine185 commented 1 year ago

Alr. Thx so much.

RHL120 commented 1 year ago

This should give you back the generated url:

curl -X POST -d "language=c&specification=gl&api=gl%3D1.3&api=gles1%3Dnone&api=gles2%3Dnone&api=glsc2%3Dnone&profile=compatibility&loader=on" --max-redirs 0 https://glad.dav1d.de/generate |grep "You should" |sed -e 's|<p>.*">||g' -e 's|</a>.*||g' | tr -d '\n'

It is a bit messy, there is probably a better way to do it

Dav1dde commented 1 year ago

There is nothing platform specific which glad needs to know, it does not matter on which or for which platform you generate, you will always get the same sources and headers.

PS: I don't see anything platform specific in their options but even if it is not platform specific it would be better to download the deps on-build instead of having them bundled with the repository IMHO.

I recommend you to just include the files in your repository, faster build times, less dependencies (Python + Jinja) and nice diffs when you re-generate the files.

This should give you back the generated url:

curl -X POST -d "language=c&specification=gl&api=gl%3D1.3&api=gles1%3Dnone&api=gles2%3Dnone&api=glsc2%3Dnone&profile=compatibility&loader=on" --max-redirs 0 https://glad.dav1d.de/generate |grep "You should" |sed -e 's|<p>.*">||g' -e 's|</a>.*||g' | tr -d '\n'

I'd ask you not to do that, it's fine if you use this as a one (or two-) time script to regenerate automatically, but if it is integrated into your builds this will generate a bunch of files over and over on my server. It also may break when I update the website.

gruelingpine185 commented 1 year ago

I think the response I received from the creator of GLAD says enough. Essentially they said that it isn't platform specific, but the underlying APIs and contexts are. My bad. With that in mind, This may be a good spot to close this issue. Thanks for all of your input and support to correct my misunderstanding :)

brmarkus commented 5 months ago

Explicitely there is nothing platform-specific, as to my understanding. Implicitely it is - like what versions, what "dialect" is supported.

In my case I get the following when trying to run todo on my "platform":

$ ./todo
[LEIF ERROR]: Failed to compile vertex shader.
Leif: [INFO]: 0:1(10): error: GLSL 4.60 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

[LEIF ERROR]: Failed to compile fragment shader.
Leif: [INFO]: 0:1(10): error: GLSL 4.60 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

[LEIF ERROR]: Failed to open font file '/usr/share/todo/fonts/inter-bold.ttf'

Segmentation fault (core dumped)

It's easy to fix - just download my "platform specific GLAD" (h and c file) (compatible to up to v4.50 only instead of v4.60 todo was built with by default) and rebuild todo.

EDIT: Sorry, forgot to mention I needed to update the version information of the fragment- and vertex-shader:

https://github.com/cococry/leif/blob/main/leif.c#L433 (using 450 instead of 460) https://github.com/cococry/leif/blob/main/leif.c#L475 (using 450 instead of 460)

cococry commented 5 months ago

okay, so changing the version to 450 in the shaders made it work and didn't cause any graphical bugs?

brmarkus commented 5 months ago

At least not in the context of the todo application - I came here from one of you Youtube videos about todo.

cococry commented 5 months ago

okay. i will be testing this and if it does not cause any issues, will add it to leifs main branch.

brmarkus commented 5 months ago

hold on, hold on... this happened on one of my very constrained and embedded system plus using remote-display-X11-screen-forwarding to a very old laptop :-P just commenting on how "implicitely" GLAD can result on platform-specific behaviour/dependencies.

It works out of the box on a more modern, Ubuntu-22.04-Intel-Core-i7 based system, natively.

cococry commented 5 months ago

hahaha okay didn't know that 😅

brmarkus commented 5 months ago

Now more experiments with todo and also with lyssa with my changes to GLSL version v450 - I haven't noticed visual artifacts. But of course that might have only scratched on leif's surface... I haven't analyzed what in detail are the differences between v4.5.0 and v4.6.0.