diff options
| author | Riley Beckett <rbeckettvt@gmail.com> | 2025-10-18 13:58:08 -0400 |
|---|---|---|
| committer | Riley Beckett <rbeckettvt@gmail.com> | 2025-10-18 13:58:08 -0400 |
| commit | 6093d0bc24fb4a89873b6f68ce3f3ad1958bdde0 (patch) | |
| tree | 57c417c89ff1ddd03a005ca66cf889abfd9b33a5 | |
| parent | eb62e6d21d6492d6e7d4894bd0298ad85c0b8a0a (diff) | |
add verbose
| -rw-r--r-- | args.c | 6 | ||||
| -rw-r--r-- | graphics.c | 20 | ||||
| -rw-r--r-- | registry.c | 4 | ||||
| -rw-r--r-- | shader.c | 6 | ||||
| -rw-r--r-- | state.h | 1 | ||||
| -rwxr-xr-x | swenu-path.sh | 6 | ||||
| -rwxr-xr-x | swenu-run.sh | 7 |
7 files changed, 30 insertions, 20 deletions
@@ -10,12 +10,13 @@ void parse_args(client_state* state, int argc, char* argv[]) { {"lines", required_argument, 0, 'l'}, {"center", no_argument, 0, 'c'}, {"allow-free-result", no_argument, 0, 'a'}, + {"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0} }; int opt; int long_index = 0; - while ((opt = getopt_long(argc, argv, "l:ca", long_opts, &long_index)) != -1) { + while ((opt = getopt_long(argc, argv, "l:cav", long_opts, &long_index)) != -1) { switch (opt) { case 'l': state->lines = atoi(optarg); @@ -26,6 +27,9 @@ void parse_args(client_state* state, int argc, char* argv[]) { case 'a': state->allow_free_result = true; break; + case 'v': + state->verbose = true; + break; default: fprintf(stderr, "Usage: NOT WHAT YOU TYPED\n"); break; @@ -59,54 +59,56 @@ bool init_gl(client_state* state) { state->egl_window = wl_egl_window_create(state->surface, state->width, state->height); if (!state->egl_window) { - fprintf(stderr, "ewindow\n"); + fprintf(stderr, "Failed to create EGL Window\n"); return false; } state->egl_display = eglGetDisplay(state->display); if (state->egl_display == EGL_NO_DISPLAY) { - fprintf(stderr, "edisplay\n"); + fprintf(stderr, "Failed to create EGL Display\n"); return false; } { EGLint major, minor; if (eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) { - fprintf(stderr, "eglinit\n"); + fprintf(stderr, "Failed to initalize EGL\n"); return false; } - fprintf(stderr, "EGL version %u.%u\n", major, minor); + if (state->verbose) { + fprintf(stderr, "EGL version %u.%u\n", major, minor); + } } eglBindAPI(EGL_OPENGL_API); EGLint num_configs; if (eglChooseConfig(state->egl_display, attrs, &state->egl_config, 1, &num_configs) != EGL_TRUE) { - fprintf(stderr, "econfig: %d\n", eglGetError()); + fprintf(stderr, "Failed to choose EGL Config: %d\n", eglGetError()); return false; } state->egl_surface = eglCreateWindowSurface(state->egl_display, state->egl_config, (EGLNativeWindowType)state->egl_window, NULL); if (state->egl_surface == EGL_NO_SURFACE) { - fprintf(stderr, "esurface\n"); + fprintf(stderr, "Failed to create EGL Window Surface\n"); return false; } state->egl_context = eglCreateContext(state->egl_display, state->egl_config, EGL_NO_CONTEXT, NULL); if (state->egl_context == EGL_NO_CONTEXT) { - fprintf(stderr, "econtext: %x\n", eglGetError()); + fprintf(stderr, "Failed to create EGL Context: %x\n", eglGetError()); return false; } eglMakeCurrent(state->egl_display, state->egl_surface, state->egl_surface, state->egl_context); if (!gladLoadGL()) { - fprintf(stderr, "gladLoadGL"); + fprintf(stderr, "Failed to load OpenGL functions\n"); return false; } - { + if (state->verbose) { GLint major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); @@ -16,7 +16,9 @@ void setup_registry_and_globals(client_state* state) { void global(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version) { client_state* state = data; - fprintf(stderr, "iface: %s v%d\n", interface, version); + if (state->verbose) { + fprintf(stderr, "iface: %s v%d\n", interface, version); + } if (!strcmp(interface, wl_compositor_interface.name)) { state->compositor = wl_registry_bind(wl_registry, name, &wl_compositor_interface, 1); @@ -14,7 +14,7 @@ GLuint createShader(const char *vertexCode, const char *fragmentCode) { glGetShaderiv(vertex, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertex, 512, NULL, infoLog); - fprintf(stderr, "ERROR: Failed to compile vertex shader: %s\n", infoLog); + fprintf(stderr, "ERROR: Failed to compile vertex shader: %s\n", infoLog); } fragment = glCreateShader(GL_FRAGMENT_SHADER); @@ -24,7 +24,7 @@ GLuint createShader(const char *vertexCode, const char *fragmentCode) { glGetShaderiv(fragment, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(fragment, 512, NULL, infoLog); - fprintf(stderr, "ERROR: Failed to compile fragment shader: %s\n", infoLog); + fprintf(stderr, "ERROR: Failed to compile fragment shader: %s\n", infoLog); } GLuint ShaderProgram = glCreateProgram(); @@ -34,7 +34,7 @@ GLuint createShader(const char *vertexCode, const char *fragmentCode) { glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &success); if (!success) { - fprintf(stderr, "Failed to link shaders\n"); + fprintf(stderr, "Failed to link shaders\n"); } glDeleteShader(vertex); @@ -96,6 +96,7 @@ typedef struct { int lines; bool allow_free_result; bool center; + bool verbose; // state char* input_buffer; diff --git a/swenu-path.sh b/swenu-path.sh new file mode 100755 index 0000000..a720d5c --- /dev/null +++ b/swenu-path.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +IFS=: +for dir in $PATH; do + [ -e ${dir} ] && find ${dir} -executable -printf '%f\n' +done | sort -u diff --git a/swenu-run.sh b/swenu-run.sh index 95d949b..956fe64 100755 --- a/swenu-run.sh +++ b/swenu-run.sh @@ -1,7 +1,2 @@ #!/bin/sh - -IFS=: -exec $( - for dir in $PATH; do - [ -e ${dir} ] && find ${dir} -executable -printf '%f\n' - done | sort -u | ./swenu -cal) +./swenu-path.sh | ./swenu "$@" | ${SHELL:-"/bin/sh"} & |
