Skip to content

Commit bc47cd3

Browse files
committed
gl: print GL version in help
1 parent 7573bf2 commit bc47cd3

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

src/video_display/gl.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @author Martin Pulec <[email protected]>
77
*/
88
/*
9-
* Copyright (c) 2010-2024 CESNET, z. s. p. o.
9+
* Copyright (c) 2010-2025 CESNET
1010
* All rights reserved.
1111
*
1212
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,7 @@
6666

6767
#include "color.h"
6868
#ifdef HAVE_CONFIG_H
69-
#include "config.h"
69+
#include "config.h" // for HAVE_SPOUT, HAVE_SYPHON
7070
#endif
7171
#include "debug.h"
7272
#include "gl_context.h"
@@ -347,6 +347,7 @@ static constexpr pair<int64_t, string_view> keybindings[] = {
347347
};
348348

349349
/* Prototyping */
350+
static bool check_display_gl_version(bool print_ver);
350351
static bool display_gl_init_opengl(struct state_gl *s);
351352
static bool display_gl_putf(void *state, struct video_frame *frame, long long timeout);
352353
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[] = {
476477
};
477478

478479
static void gl_print_monitors(bool fullhelp) {
479-
if (ref_count_init_once<int>()(glfwInit, glfw_init_count).value_or(GLFW_TRUE) == GLFW_FALSE) {
480-
LOG(LOG_LEVEL_ERROR) << "Cannot initialize GLFW!\n";
481-
return;
482-
}
483480
printf("\nmonitors:\n");
484481
int count = 0;
485482
GLFWmonitor **mon = glfwGetMonitors(&count);
@@ -511,8 +508,6 @@ static void gl_print_monitors(bool fullhelp) {
511508
if (!fullhelp) {
512509
cout << "(use \"fullhelp\" to see modes)\n";
513510
}
514-
515-
ref_count_terminate_last()(glfwTerminate, glfw_init_count);
516511
}
517512

518513
#define FEATURE_PRESENT(x) (strcmp(STRINGIFY(x), "1") == 0 ? "on" : "off")
@@ -580,8 +575,21 @@ static void gl_show_help(bool full) {
580575
col() << "\t" << TBOLD(<< keyname <<) << "\t\t" << i.second << "\n";
581576
}
582577

578+
if (ref_count_init_once<int>()(glfwInit, glfw_init_count).value_or(GLFW_TRUE) == GLFW_FALSE) {
579+
LOG(LOG_LEVEL_ERROR) << "Cannot initialize GLFW!\n";
580+
return;
581+
}
583582
gl_print_monitors(full);
584-
col() << "\nCompiled " << SBOLD("features: ") << "SPOUT - "
583+
color_printf("\n");
584+
GLFWwindow *window = glfwCreateWindow(32, 32, DEFAULT_WIN_NAME, nullptr, nullptr);
585+
if (window != nullptr) {
586+
glfwMakeContextCurrent(window);
587+
check_display_gl_version(true);
588+
glfwDestroyWindow(window);
589+
}
590+
ref_count_terminate_last()(glfwTerminate, glfw_init_count);
591+
592+
col() << "Compiled " << SBOLD("features: ") << "SPOUT - "
585593
<< FEATURE_PRESENT(SPOUT) << ", Syphon - "
586594
<< FEATURE_PRESENT(SYPHON) << ", VDPAU - "
587595
<< FEATURE_PRESENT(HWACC_VDPAU) << "\n";
@@ -1444,7 +1452,9 @@ static void glfw_mouse_callback(GLFWwindow *win, double /* x */, double /* y */)
14441452
}
14451453
}
14461454

1447-
static bool display_gl_check_gl_version() {
1455+
static bool
1456+
check_display_gl_version(bool print_ver)
1457+
{
14481458
auto version = (const char *) glGetString(GL_VERSION);
14491459
if (!version) {
14501460
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to get OpenGL version!\n");
@@ -1454,8 +1464,12 @@ static bool display_gl_check_gl_version() {
14541464
log_msg(LOG_LEVEL_ERROR, MOD_NAME "ERROR: OpenGL 2.0 is not supported, try updating your drivers...\n");
14551465
return false;
14561466
}
1457-
log_msg(LOG_LEVEL_INFO, MOD_NAME "OpenGL 2.0 is supported...\n");
1458-
MSG(VERBOSE, "Supported OpenGL version is %s.\n", version);
1467+
if (print_ver) { // from help
1468+
color_printf(TBOLD("OpenGL version:") " %s\n", version);
1469+
} else {
1470+
MSG(INFO, "OpenGL 2.0 is supported...\n");
1471+
MSG(VERBOSE, "Supported OpenGL version is %s.\n", version);
1472+
}
14591473
return true;
14601474
}
14611475

@@ -1728,7 +1742,7 @@ static bool display_gl_init_opengl(struct state_gl *s)
17281742
}
17291743
}
17301744
#endif
1731-
if (!display_gl_check_gl_version()) {
1745+
if (!check_display_gl_version(false)) {
17321746
glfwDestroyWindow(s->window);
17331747
s->window = nullptr;
17341748
return false;

0 commit comments

Comments
 (0)