Compare commits

..

No commits in common. "84595eff00a145c9ca07678a45c84d2c8d4cdd75" and "47bbca6806ff90d6bf56d857da37645800b8285c" have entirely different histories.

2 changed files with 4 additions and 51 deletions

View file

@ -1,4 +1,4 @@
CFLAGS = -std=c11 -pedantic -Wall -Wextra -O2 -Ofast -D_DEFAULT_SOURCE -D_FORTIFY_SOURCE=2 CFLAGS = -ansi -pedantic -Wall -Wextra -O2 -Ofast -D_DEFAULT_SOURCE
LDFLAGS = -lX11 -lGL -lGLEW -lm -lrt LDFLAGS = -lX11 -lGL -lGLEW -lm -lrt
shadermeh: shadermeh.o window.o shader.o shadermeh: shadermeh.o window.o shader.o

View file

@ -1,5 +1,4 @@
/* SPDX-License-Identifier: ISC */ /* SPDX-License-Identifier: ISC */
/* /*
* shadermeh.c * shadermeh.c
* *
@ -7,9 +6,6 @@
*/ */
#include "shadermeh.h" #include "shadermeh.h"
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#define HAVE_ARCH_STRUCT_FLOCK
#include <linux/fcntl.h>
static GLfloat vertex_buffer[] = { static GLfloat vertex_buffer[] = {
-1.0f, -1.0f, 0.0f, /* lower left corner */ -1.0f, -1.0f, 0.0f, /* lower left corner */
@ -94,7 +90,7 @@ static const struct option long_opts[] = {
{ NULL, 0, NULL, 0 }, { NULL, 0, NULL, 0 },
}; };
static const char *short_opts = "r:w:h:s:S"; static const char *short_opts = "w:h:s:S:r";
static const char *usage_str = static const char *usage_str =
"shadermeh OPTIONS...\n" "shadermeh OPTIONS...\n"
@ -103,7 +99,6 @@ static const char *usage_str =
"\n" "\n"
" --width, -w <pixels>\n" " --width, -w <pixels>\n"
" --height, -h <pixels>\n" " --height, -h <pixels>\n"
" --sampling-rate, -r <sampling rate[Hz]>\n"
"\n" "\n"
" --to-stdout, -S\n" " --to-stdout, -S\n"
"\n" "\n"
@ -115,7 +110,6 @@ static const char *usage_str =
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GLuint u_iResolution, u_iTime, u_iTimeDelta, u_iFrame; GLuint u_iResolution, u_iTime, u_iTimeDelta, u_iFrame;
GLfloat u_iSampleRate;
struct timespec start, frame_start, frame_end; struct timespec start, frame_start, frame_end;
unsigned int width, height, iFrame = 0; unsigned int width, height, iFrame = 0;
void *fb32 = NULL, *fb24 = NULL; void *fb32 = NULL, *fb24 = NULL;
@ -126,9 +120,7 @@ int main(int argc, char **argv)
bool to_stdout = false; bool to_stdout = false;
window *wnd; window *wnd;
int i; int i;
unsigned int sampling_rate = 0; /* Leaving this at 0 disables audio unsigned int sampling_rate = 0;
* input
*/
float in_samples[SND_BUFFER_SIZE]; /* Raw input floats from -1...1 */ float in_samples[SND_BUFFER_SIZE]; /* Raw input floats from -1...1 */
float norm_samples[SND_BUFFER_SIZE]; /* Normalized samples from 0...1 */ float norm_samples[SND_BUFFER_SIZE]; /* Normalized samples from 0...1 */
@ -182,43 +174,6 @@ int main(int argc, char **argv)
free(fb32); free(fb32);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(!isatty(STDOUT_FILENO)){
long old_pipe_size = fcntl(STDOUT_FILENO, F_GETPIPE_SZ);
if(old_pipe_size < 0){
perror("Failed to get stdout pipe size");
}else{
int psz = getpagesize();
size_t frame_size = (width * height * 3);
size_t frame_cnt = psz / frame_size;
if((psz % frame_size) != 0){
frame_cnt++;
}
size_t new_pipe_size = frame_size * frame_cnt;
int fin_psz = fcntl(STDOUT_FILENO, F_SETPIPE_SZ,
new_pipe_size);
if(fin_psz < 0){
fprintf(stderr, "Failed to set STDOUT "
"pipe size to %zu: %s\n",
new_pipe_size, strerror(errno));
}else{
fprintf(stderr, "stdout pipe size "
"change from %li to %zu "
"resulted in %i\n",
old_pipe_size,
new_pipe_size,
fin_psz);
}
/* A failure to change pipe size is not
* catastrophic, beacause the application will
* still perform as needed, just with a bigger
* or smaller buffer. */
}
}
}
if (sampling_rate != 0 && !isatty(STDIN_FILENO)){
fputs("Sampling rate specified and STDIN not a tty! "
"You habe been warnded!\n", stderr);
} }
/********** create window and make context current **********/ /********** create window and make context current **********/
@ -247,7 +202,7 @@ int main(int argc, char **argv)
glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor); glGetIntegerv(GL_MINOR_VERSION, &minor);
fprintf(stderr,"OpenGL version %d.%d\n", major, minor); printf("OpenGL version %d.%d\n", major, minor);
/******************** initialization ********************/ /******************** initialization ********************/
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@ -284,10 +239,8 @@ int main(int argc, char **argv)
u_iTime = glGetUniformLocation(prog, "iTime"); u_iTime = glGetUniformLocation(prog, "iTime");
u_iTimeDelta = glGetUniformLocation(prog, "iTimeDelta"); u_iTimeDelta = glGetUniformLocation(prog, "iTimeDelta");
u_iFrame = glGetUniformLocation(prog, "iFrame;"); u_iFrame = glGetUniformLocation(prog, "iFrame;");
u_iSampleRate = glGetUniformLocation(prog, "iSampleRate");
glUniform3f(u_iResolution, width, height, 0.0f); glUniform3f(u_iResolution, width, height, 0.0f);
glUniform1f(u_iSampleRate, sampling_rate);
clock_gettime(CLOCK_MONOTONIC_RAW, &start); clock_gettime(CLOCK_MONOTONIC_RAW, &start);