feat(window): can specify opengl version from args
Clang Build CI / run-no-video (push) Failing after 48s
Clang Lint CI / lint-no-video (push) Failing after 48s
Clang Build CI / run-video (push) Failing after 50s
Clang Build CI / build-release (push) Failing after 1m12s
Clang Lint CI / lint-video (push) Failing after 51s
Clang Build CI / run-no-video (push) Failing after 48s
Clang Lint CI / lint-no-video (push) Failing after 48s
Clang Build CI / run-video (push) Failing after 50s
Clang Build CI / build-release (push) Failing after 1m12s
Clang Lint CI / lint-video (push) Failing after 51s
This commit is contained in:
+24
-3
@@ -7,12 +7,13 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
#define STR_IMPL_(x) #x // stringify argument
|
||||||
|
#define STR(x) STR_IMPL_(x) // indirection to expand argument macros
|
||||||
|
|
||||||
static void print_help(int status_code) {
|
static void print_help(int status_code) {
|
||||||
puts(
|
puts(
|
||||||
PACKAGE
|
PACKAGE
|
||||||
@@ -48,6 +49,8 @@ static void print_help(int status_code) {
|
|||||||
"[--wayland] "
|
"[--wayland] "
|
||||||
"[--cocoa] "
|
"[--cocoa] "
|
||||||
"[--win32] "
|
"[--win32] "
|
||||||
|
"[-oma=MAJOR] "
|
||||||
|
"[-omi=MINOR] "
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Fusion Of Real-time Generative Effects.\n\n"
|
"Fusion Of Real-time Generative Effects.\n\n"
|
||||||
"options:\n"
|
"options:\n"
|
||||||
@@ -91,7 +94,13 @@ static void print_help(int status_code) {
|
|||||||
" --x11 force X11 GLFW backend\n"
|
" --x11 force X11 GLFW backend\n"
|
||||||
" --wayland force Wayland GLFW backend\n"
|
" --wayland force Wayland GLFW backend\n"
|
||||||
" --cocoa force Cocoa GLFW backend\n"
|
" --cocoa force Cocoa GLFW backend\n"
|
||||||
" --win32 force Win32 GLFW backend\n");
|
" --win32 force Win32 GLFW backend\n"
|
||||||
|
" -oma, --opengl-major-version OpenGL major version "
|
||||||
|
"(default: " STR(
|
||||||
|
OPENGL_MAJOR_VERSION) ")\n"
|
||||||
|
" -omi, --opengl-minor-version OpenGL "
|
||||||
|
"minor version (default: " STR(
|
||||||
|
OPENGL_MINOR_VERSION) ")\n");
|
||||||
exit(status_code);
|
exit(status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +172,8 @@ void args_parse(Parameters *params, int argc, char **argv) {
|
|||||||
params->trace_midi = false;
|
params->trace_midi = false;
|
||||||
params->trace_fps = false;
|
params->trace_fps = false;
|
||||||
params->glfw_backend = GLFW_BACKEND_ANY;
|
params->glfw_backend = GLFW_BACKEND_ANY;
|
||||||
|
params->opengl_major = OPENGL_MAJOR_VERSION;
|
||||||
|
params->opengl_minor = OPENGL_MINOR_VERSION;
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
arg = argv[i];
|
arg = argv[i];
|
||||||
@@ -239,6 +250,16 @@ void args_parse(Parameters *params, int argc, char **argv) {
|
|||||||
params->glfw_backend = GLFW_BACKEND_COCOA;
|
params->glfw_backend = GLFW_BACKEND_COCOA;
|
||||||
} else if (is_arg(arg, "--win32")) {
|
} else if (is_arg(arg, "--win32")) {
|
||||||
params->glfw_backend = GLFW_BACKEND_WIN32;
|
params->glfw_backend = GLFW_BACKEND_WIN32;
|
||||||
|
} else if (is_arg(arg, "-oma") || is_arg(arg, "--opengl-major-version")) {
|
||||||
|
params->opengl_major = parse_uint(arg, value);
|
||||||
|
if (params->opengl_major == 0) {
|
||||||
|
invalid_value(arg, value);
|
||||||
|
}
|
||||||
|
} else if (is_arg(arg, "-omi") || is_arg(arg, "--opengl-minor-version")) {
|
||||||
|
params->opengl_minor = parse_uint(arg, value);
|
||||||
|
if (params->opengl_major == 0) {
|
||||||
|
invalid_value(arg, value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef VIDEO_IN
|
#ifdef VIDEO_IN
|
||||||
if (is_arg(arg, "-vi") || is_arg(arg, "--video-in")) {
|
if (is_arg(arg, "-vi") || is_arg(arg, "--video-in")) {
|
||||||
|
|||||||
@@ -87,4 +87,23 @@
|
|||||||
#define MAX_TAP_VALUES 10
|
#define MAX_TAP_VALUES 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* OPENGL */
|
||||||
|
|
||||||
|
#ifndef OPENGL_MAJOR_VERSION
|
||||||
|
#define OPENGL_MAJOR_VERSION 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef OPENGL_MINOR_VERSION
|
||||||
|
#define OPENGL_MINOR_VERSION 6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GLFW CONSTANTS */
|
||||||
|
#ifndef GLFW_BACKENDS
|
||||||
|
#define GLFW_BACKEND_ANY 0
|
||||||
|
#define GLFW_BACKEND_X11 1
|
||||||
|
#define GLFW_BACKEND_WAYLAND 2
|
||||||
|
#define GLFW_BACKEND_COCOA 3
|
||||||
|
#define GLFW_BACKEND_WIN32 4
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_H */
|
#endif /* CONFIG_H */
|
||||||
|
|||||||
@@ -3,12 +3,6 @@
|
|||||||
#ifndef CONSTANTS_H
|
#ifndef CONSTANTS_H
|
||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
static const unsigned int GLFW_BACKEND_ANY = 0;
|
|
||||||
static const unsigned int GLFW_BACKEND_X11 = 1;
|
|
||||||
static const unsigned int GLFW_BACKEND_WAYLAND = 2;
|
|
||||||
static const unsigned int GLFW_BACKEND_COCOA = 3;
|
|
||||||
static const unsigned int GLFW_BACKEND_WIN32 = 4;
|
|
||||||
|
|
||||||
static const char *vertex_shader_text =
|
static const char *vertex_shader_text =
|
||||||
"#version 460\n"
|
"#version 460\n"
|
||||||
"const mat4 mvp = "
|
"const mat4 mvp = "
|
||||||
|
|||||||
+4
-2
@@ -293,7 +293,8 @@ static bool init(const Parameters *params) {
|
|||||||
|
|
||||||
if (params->output) {
|
if (params->output) {
|
||||||
window_output = window_init(PACKAGE " " VERSION, params->output_screen,
|
window_output = window_init(PACKAGE " " VERSION, params->output_screen,
|
||||||
params->windowed, NULL, key_callback);
|
params->windowed, params->opengl_major,
|
||||||
|
params->opengl_minor, NULL, key_callback);
|
||||||
|
|
||||||
window_use(window_output, &context);
|
window_use(window_output, &context);
|
||||||
|
|
||||||
@@ -305,7 +306,8 @@ static bool init(const Parameters *params) {
|
|||||||
if (params->monitor) {
|
if (params->monitor) {
|
||||||
window_monitor =
|
window_monitor =
|
||||||
window_init(PACKAGE " " VERSION " (monitor)", params->monitor_screen,
|
window_init(PACKAGE " " VERSION " (monitor)", params->monitor_screen,
|
||||||
params->windowed, window_output, key_callback);
|
params->windowed, params->opengl_major,
|
||||||
|
params->opengl_minor, window_output, key_callback);
|
||||||
|
|
||||||
window_use(window_monitor, &context);
|
window_use(window_monitor, &context);
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ typedef struct Parameters {
|
|||||||
bool trace_midi;
|
bool trace_midi;
|
||||||
bool trace_fps;
|
bool trace_fps;
|
||||||
unsigned int glfw_backend;
|
unsigned int glfw_backend;
|
||||||
|
unsigned int opengl_major;
|
||||||
|
unsigned int opengl_minor;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|
||||||
// file.c
|
// file.c
|
||||||
|
|||||||
+9
-7
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
static void init_glfw(void (*error_callback)(int, const char *),
|
static void init_glfw(void (*error_callback)(int, const char *),
|
||||||
@@ -69,7 +67,9 @@ static GLFWmonitor *get_monitor(unsigned char monitor_index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GLFWwindow *
|
static GLFWwindow *
|
||||||
create_window(GLFWmonitor *monitor, const char *title, Window *shared_context,
|
create_window(GLFWmonitor *monitor, const char *title,
|
||||||
|
const unsigned int opengl_major, const unsigned int opengl_minor,
|
||||||
|
Window *shared_context,
|
||||||
void (*key_callback)(Window *, int, int, int, int)) {
|
void (*key_callback)(Window *, int, int, int, int)) {
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
|
|
||||||
@@ -82,8 +82,8 @@ create_window(GLFWmonitor *monitor, const char *title, Window *shared_context,
|
|||||||
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
||||||
|
|
||||||
// Context related hints
|
// Context related hints
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, opengl_major);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, opengl_minor);
|
||||||
#ifdef GL_DEBUG
|
#ifdef GL_DEBUG
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
||||||
#endif
|
#endif
|
||||||
@@ -122,14 +122,16 @@ void window_terminate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Window *window_init(const char *title, unsigned char monitor_index,
|
Window *window_init(const char *title, unsigned char monitor_index,
|
||||||
bool windowed, Window *shared_context,
|
bool windowed, const unsigned int opengl_major,
|
||||||
|
const unsigned int opengl_minor, Window *shared_context,
|
||||||
void (*key_callback)(Window *, int, int, int, int)) {
|
void (*key_callback)(Window *, int, int, int, int)) {
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
GLFWmonitor *monitor;
|
GLFWmonitor *monitor;
|
||||||
|
|
||||||
monitor = windowed ? NULL : get_monitor(monitor_index);
|
monitor = windowed ? NULL : get_monitor(monitor_index);
|
||||||
|
|
||||||
window = create_window(monitor, title, shared_context, key_callback);
|
window = create_window(monitor, title, opengl_major, opengl_minor,
|
||||||
|
shared_context, key_callback);
|
||||||
|
|
||||||
use_window(window);
|
use_window(window);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -8,7 +8,8 @@ void window_startup(void (*error_callback)(int, const char *), const unsigned in
|
|||||||
void window_terminate();
|
void window_terminate();
|
||||||
|
|
||||||
Window *window_init(const char *title, unsigned char monitor_index,
|
Window *window_init(const char *title, unsigned char monitor_index,
|
||||||
bool windowed, Window *shared_context,
|
bool windowed, const unsigned int opengl_major,
|
||||||
|
const unsigned int opengl_minor, Window *shared_context,
|
||||||
void (*key_callback)(Window *, int, int, int, int));
|
void (*key_callback)(Window *, int, int, int, int));
|
||||||
|
|
||||||
void window_update_title(Window *window, const char *title);
|
void window_update_title(Window *window, const char *title);
|
||||||
|
|||||||
Reference in New Issue
Block a user