tsoding / ded

Dramatic EDitor
MIT License
579 stars 76 forks source link

Declare fragment shader outputs, improving compatibility (macOS) #75

Open fabjan opened 1 year ago

fabjan commented 1 year ago

Problem

The build went fine without warnings or errors on my Mac, but the shaders cannot be compiled:

❯ ./ded     
GL version 3.3
WARNING: GLEW_ARB_debug_output is not availableERROR: could not compile GL_FRAGMENT_SHADER
ERROR: 0:6: Use of undeclared identifier 'gl_FragColor'

ERROR: failed to compile `./shaders/simple_color.frag` shader file

Is the program written for a different GL version than what macOS 11.7.2 provides perhaps (see caveats)?

Solution

Update each of the shaders/simple_*.frag programs to stop using gl_FragColor, instead declare out vec4 fragColor; and use that.

Fixes #65.

Compare for this fix in dlangui:

https://github.com/buggins/dlangui/commit/6cfe98a4f1f665887fc4c0cccd526a8ce9f3c19c#diff-0671d7c48bc6543434a3b3c9b6671be5b41902e679cfa0520fa7f0c780d670e4L231

Caveats

I don't write many graphical programs. Perhaps macOS is always a pain and you don't want to support it. Given that build.sh contains a uname check for "Darwin" though, I'm giving it a shot.

I used the following versions of the dependencies (latest in Homebrew):