Add width/height options
This commit is contained in:
parent
ee22df9211
commit
3a2d45fb93
2 changed files with 26 additions and 6 deletions
16
glslview.c
16
glslview.c
|
@ -172,17 +172,27 @@ static void handle_input(const char *input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(void) {
|
static void usage(void) {
|
||||||
fprintf(stderr, "Usage: glslview [-t <time>] [-s <speed>] [-0 <param0>] [-1 <param1>] [-2 <param2>] <shader>\n");
|
fprintf(stderr, "Usage: glslview [-w <width>] [-h <height>] [-t <time>] [-s <speed>] [-0 <param0>] [-1 <param1>] [-2 <param2>] <shader>\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
int width = 800, height = 800;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt(argc, argv, "t:s:0:1:2:");
|
int c = getopt(argc, argv, "w:h:t:s:0:1:2:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'w':
|
||||||
|
width = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
height = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
current_time = init_time = atof(optarg);
|
current_time = init_time = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -220,7 +230,7 @@ int main(int argc, char *argv[]) {
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
||||||
|
|
||||||
SDL_Window *window = SDL_CreateWindow("glslview", 0, 0, 800, 800, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
SDL_Window *window = SDL_CreateWindow("glslview", 0, 0, width, height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
||||||
SDL_GLContext ctx = SDL_GL_CreateContext(window);
|
SDL_GLContext ctx = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
|
|
16
glslwrite.c
16
glslwrite.c
|
@ -91,17 +91,27 @@ static void savePNG(int width, int height, const char *output_dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(void) {
|
static void usage(void) {
|
||||||
fprintf(stderr, "Usage: glslwrite [-s <step>] [-f <frames>] [-0 <param0>] [-1 <param1>] [-2 <param2>] <shader>\n");
|
fprintf(stderr, "Usage: glslwrite [-w <width>] [-h <height>] [-s <step>] [-f <frames>] [-0 <param0>] [-1 <param1>] [-2 <param2>] <shader>\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
int width = 800, height = 800;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt(argc, argv, "s:f:0:1:2:");
|
int c = getopt(argc, argv, "w:h:s:f:0:1:2:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'w':
|
||||||
|
width = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
height = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
step = atof(optarg);
|
step = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -138,7 +148,7 @@ int main(int argc, char *argv[]) {
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
||||||
|
|
||||||
SDL_Window *window = SDL_CreateWindow("glslwrite", 0, 0, 800, 800, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
SDL_Window *window = SDL_CreateWindow("glslwrite", 0, 0, width, height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
||||||
SDL_GLContext ctx = SDL_GL_CreateContext(window);
|
SDL_GLContext ctx = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
|
|
Reference in a new issue