glbinding sfml version - Posted on Jun 29, 2024 - See https://glbinding.org - Logs Home - d0027
Use c++ glbinding to initialize and query opengl version.
glbinding leverages C++11 features like enum classes, lambdas, and variadic templates, instead of relying on macros; all OpenGL symbols are real functions and variables. It provides type-safe parameters, per-feature API headers, lazy function resolution, multi-context and multi-thread support, global and local function callbacks, meta information about the generated OpenGL binding and the OpenGL runtime, as well as tools and examples for quick-starting your projects. Based on the OpenGL API specification (gl.xml) glbinding is generated using scripts and templates that can be easily adapted to fit custom needs.
cpp/c++
const glbinding::Version version = glbinding::aux::ContextInfo::version();
#include <SFML/Window.hpp> #include <glbinding-aux/ContextInfo.h> // glbinding::aux::ContextInfo #include <glbinding/glbinding.h> // glbinding::initialize #include <glbinding/getProcAddress.h> // glbinding::getProcAddress #include <iostream> #include <glbinding/Version.h> // glbinding::Version #include <string> #include <memory> using std::string_literals::operator""s; int main(int argc, char * argv[]) { std::unique_ptr<sf::Window> win_uniq; if (argc == 2 && "true"s == argv[1]) win_uniq = std::make_unique<sf::Window>(sf::VideoMode{2560, 1440, 32}, "SFML Window"); glbinding::initialize(glbinding::getProcAddress, false); const glbinding::Version version = glbinding::aux::ContextInfo::version(); std::cout << "Version: " << version.toString() << '\n' << (int)version.majorVersion() << ' ' << (int)version.minorVersion() << ' ' << std::endl << std::endl ; std::cout << std::boolalpha << (version >= glbinding::Version{4, 6}) << ' ' << (version.majorVersion() >= 4) << ' ' << (version.minorVersion() >= 6) << ' ' << std::endl << std::endl; }
$ g++ version.cpp -std=c++23 -lglbinding -lglbinding-aux -lsfml-window -lsfml-system -o version $ ./version Version: -.- 0 0 false false false $ ./version true Version: 4.6 4 6 true true true $
c++ std::exception:
std::cout.write(err.data(), err.size());
std::cout << std::endl;
caught:
=================================== # The c++ programming language. # # # # Join c++ Discord: yZcauUAUyC # # Deck # ===================================