GL/SDL2 examples: Make it build on Visual Studio

Chun-wei Fan requested to merge fanc999/gstreamer:sdl-msvc-fix into main

Hi,

In recent releases SDL2's CMake build produces pkg-config files for us, which will enable the GL/SDL examples to build. So this attempts to make such builds work, by:

  • Updating the C sources so that they will compile on Visual Studio:

  • Change WIN32 to _WIN32, since _WIN32 is always defined for compilers targeting Windows.

  • Include stdio.h for stderr.

  • Define GL_CLAMP_TO_EDGE if needed, as Windows's stock GL/gl.h may not have supported that.

  • Update the Meson build files to link to SDL2main.lib on Visual Studio-like compilers, since it's required, and Meson's SDL2 support does not yet cover using CMake, so we can't use the components: keyword in the dependency... call.

The code still needs some update to work under Windows, but at least the code now builds.

With blessings, thank you!

Merge request reports