gl: print GL version in help

This commit is contained in:
Martin Pulec
2025-02-10 11:29:37 +01:00
parent 7573bf24b1
commit bc47cd392c

View File

@@ -6,7 +6,7 @@
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
* Copyright (c) 2010-2024 CESNET, z. s. p. o.
* Copyright (c) 2010-2025 CESNET
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,7 @@
#include "color.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config.h" // for HAVE_SPOUT, HAVE_SYPHON
#endif
#include "debug.h"
#include "gl_context.h"
@@ -347,6 +347,7 @@ static constexpr pair<int64_t, string_view> keybindings[] = {
};
/* Prototyping */
static bool check_display_gl_version(bool print_ver);
static bool display_gl_init_opengl(struct state_gl *s);
static bool display_gl_putf(void *state, struct video_frame *frame, long long timeout);
static bool display_gl_process_key(struct state_gl *s, long long int key);
@@ -476,10 +477,6 @@ static constexpr codec_t gl_supp_codecs[] = {
};
static void gl_print_monitors(bool fullhelp) {
if (ref_count_init_once<int>()(glfwInit, glfw_init_count).value_or(GLFW_TRUE) == GLFW_FALSE) {
LOG(LOG_LEVEL_ERROR) << "Cannot initialize GLFW!\n";
return;
}
printf("\nmonitors:\n");
int count = 0;
GLFWmonitor **mon = glfwGetMonitors(&count);
@@ -511,8 +508,6 @@ static void gl_print_monitors(bool fullhelp) {
if (!fullhelp) {
cout << "(use \"fullhelp\" to see modes)\n";
}
ref_count_terminate_last()(glfwTerminate, glfw_init_count);
}
#define FEATURE_PRESENT(x) (strcmp(STRINGIFY(x), "1") == 0 ? "on" : "off")
@@ -580,8 +575,21 @@ static void gl_show_help(bool full) {
col() << "\t" << TBOLD(<< keyname <<) << "\t\t" << i.second << "\n";
}
if (ref_count_init_once<int>()(glfwInit, glfw_init_count).value_or(GLFW_TRUE) == GLFW_FALSE) {
LOG(LOG_LEVEL_ERROR) << "Cannot initialize GLFW!\n";
return;
}
gl_print_monitors(full);
col() << "\nCompiled " << SBOLD("features: ") << "SPOUT - "
color_printf("\n");
GLFWwindow *window = glfwCreateWindow(32, 32, DEFAULT_WIN_NAME, nullptr, nullptr);
if (window != nullptr) {
glfwMakeContextCurrent(window);
check_display_gl_version(true);
glfwDestroyWindow(window);
}
ref_count_terminate_last()(glfwTerminate, glfw_init_count);
col() << "Compiled " << SBOLD("features: ") << "SPOUT - "
<< FEATURE_PRESENT(SPOUT) << ", Syphon - "
<< FEATURE_PRESENT(SYPHON) << ", VDPAU - "
<< FEATURE_PRESENT(HWACC_VDPAU) << "\n";
@@ -1444,7 +1452,9 @@ static void glfw_mouse_callback(GLFWwindow *win, double /* x */, double /* y */)
}
}
static bool display_gl_check_gl_version() {
static bool
check_display_gl_version(bool print_ver)
{
auto version = (const char *) glGetString(GL_VERSION);
if (!version) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to get OpenGL version!\n");
@@ -1454,8 +1464,12 @@ static bool display_gl_check_gl_version() {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "ERROR: OpenGL 2.0 is not supported, try updating your drivers...\n");
return false;
}
log_msg(LOG_LEVEL_INFO, MOD_NAME "OpenGL 2.0 is supported...\n");
MSG(VERBOSE, "Supported OpenGL version is %s.\n", version);
if (print_ver) { // from help
color_printf(TBOLD("OpenGL version:") " %s\n", version);
} else {
MSG(INFO, "OpenGL 2.0 is supported...\n");
MSG(VERBOSE, "Supported OpenGL version is %s.\n", version);
}
return true;
}
@@ -1728,7 +1742,7 @@ static bool display_gl_init_opengl(struct state_gl *s)
}
}
#endif
if (!display_gl_check_gl_version()) {
if (!check_display_gl_version(false)) {
glfwDestroyWindow(s->window);
s->window = nullptr;
return false;