Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: [OpenGL] Load all OpenGL functions dynamically. #8730

Merged
merged 2 commits into from Feb 24, 2021

Conversation

michicc
Copy link
Member

@michicc michicc commented Feb 22, 2021

Motivation / Problem

Some Linux OpenGL drivers don't use the global system dispatch table.

Description

Link all OpenGL functions dynamically to make sure we use the right one.

Limitations

OpenGL headers are not uniform among systems, which might cause compile problems on more obscure systems.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@Milek7
Copy link
Contributor

Milek7 commented Feb 22, 2021

Alternative approach for consideration, use autogenerated loader instead: Milek7@127aaa9

As system OpenGL headers are not used at all, I removed library searching and linking from CMake files.
For win32 it also needs win32_v.cpp from this PR.

src/video/opengl.cpp Outdated Show resolved Hide resolved
src/video/opengl.cpp Outdated Show resolved Hide resolved
@TrueBrain
Copy link
Member

With this PR, I can remove link_package(OpenGL TARGET OpenGL::GL) from CMakeLists.txt. This has the benefit that our generic linux binaries are a lot smaller again, as it no longer drags in OpenGL.so and because of that, X11 and friends. That won't really be a generic linux binary.

Without the link_package, SDL takes care of all the dynamic loading, removing those dependencies from the binary.

I can PR that after this PR, if you like, but maybe the link_package is also not needed on other targets now?

@michicc
Copy link
Member Author

michicc commented Feb 24, 2021

It is still needed for Win32 because of the wgl calls, but opengl32.dll is a system DLL everywhere, so no problem.
OSX I'd have to check.

Copy link
Member

@frosch123 frosch123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me

@michicc michicc merged commit 311df31 into OpenTTD:master Feb 24, 2021
@michicc michicc deleted the pr/gl_dynamic branch February 24, 2021 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants