internal size
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
TARGET ?= forge
|
TARGET ?= forge
|
||||||
INSTALL_DIR ?= $(HOME)/.local/bin
|
INSTALL_DIR ?= $(HOME)/.local/bin
|
||||||
TEST_ARGS ?= --hot-reload --frag=./shaders --frag-config=./config/shaders.cfg --demo
|
TEST_ARGS ?= --hot-reload --frag=./shaders --frag-config=./config/shaders.cfg --demo -is=480
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ make -f Makefile.dev release-arch
|
|||||||
- [x] demo mode
|
- [x] demo mode
|
||||||
- [x] random seed injected into shaders
|
- [x] random seed injected into shaders
|
||||||
- [ ] internal texture size for speed
|
- [ ] internal texture size for speed
|
||||||
|
- [ ] pass state as uniform
|
||||||
|
- [ ] debug shader (and in monitor)
|
||||||
- [ ] Clean code and fix things
|
- [ ] Clean code and fix things
|
||||||
- [ ] Midi
|
- [ ] Midi
|
||||||
- [ ] Read Midi events
|
- [ ] Read Midi events
|
||||||
|
|||||||
+19
-25
@@ -1,3 +1,4 @@
|
|||||||
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -24,14 +25,15 @@ static void print_help(int status_code) {
|
|||||||
"\n\n"
|
"\n\n"
|
||||||
"Fusion Of Real-time Generative Effects.\n\n"
|
"Fusion Of Real-time Generative Effects.\n\n"
|
||||||
"options:\n"
|
"options:\n"
|
||||||
" -h, --help show this help message and exit\n"
|
" -h, --help show this help message and exit\n"
|
||||||
" -v, --version print version\n"
|
" -v, --version print version\n"
|
||||||
" -hr, --hot-reload hot reload of shaders scripts\n"
|
" -hr, --hot-reload hot reload of shaders scripts\n"
|
||||||
" -s, --screen output screen number (default: primary)\n"
|
" -s, --screen output screen number (default: primary)\n"
|
||||||
" -f, --frag fragment shaders directory (default: TODO)\n"
|
" -f, --frag fragment shaders directory (default: TODO)\n"
|
||||||
" -fc, --frag-config fragment shaders config file (default: TODO)\n"
|
" -fc, --frag-config fragment shaders config file (default: TODO)\n"
|
||||||
" -t, --tempo base tempo (default: 60)\n"
|
" -is, --internal-size internal texture height (default: 720)\n"
|
||||||
" --demo demonstration mode\n");
|
" -t, --tempo base tempo (default: 60)\n"
|
||||||
|
" --demo demonstration mode\n");
|
||||||
exit(status_code);
|
exit(status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,26 +54,15 @@ static char *split_arg_value(char *arg) {
|
|||||||
return strtok(NULL, "=");
|
return strtok(NULL, "=");
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char parse_uchar(char *arg, char *value) {
|
static unsigned int parse_uint(char *arg, char *value) {
|
||||||
if (!string_is_number(value)) {
|
if (!string_is_number(value)) {
|
||||||
invalid_value(arg, value);
|
invalid_value(arg, value);
|
||||||
}
|
}
|
||||||
unsigned long long tmp_value = (unsigned long long)atoll(value);
|
unsigned long long tmp_value = (unsigned long long)atoll(value);
|
||||||
if (tmp_value >= 256) {
|
if (tmp_value >= UINT_MAX) {
|
||||||
invalid_value(arg, value);
|
invalid_value(arg, value);
|
||||||
}
|
}
|
||||||
return (unsigned char)tmp_value;
|
return (unsigned int)tmp_value;
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned short parse_ushort(char *arg, char *value) {
|
|
||||||
if (!string_is_number(value)) {
|
|
||||||
invalid_value(arg, value);
|
|
||||||
}
|
|
||||||
unsigned long long tmp_value = (unsigned long long)atoll(value);
|
|
||||||
if (tmp_value >= 65536) {
|
|
||||||
invalid_value(arg, value);
|
|
||||||
}
|
|
||||||
return (unsigned short)tmp_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Parameters args_parse(int argc, char **argv) {
|
Parameters args_parse(int argc, char **argv) {
|
||||||
@@ -80,10 +71,11 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
char *arg;
|
char *arg;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
|
params.hot_reload = false;
|
||||||
params.screen = 0;
|
params.screen = 0;
|
||||||
params.frag_path = 0;
|
params.frag_path = 0;
|
||||||
params.frag_config_path = 0;
|
params.frag_config_path = 0;
|
||||||
params.hot_reload = false;
|
params.internal_size = 720;
|
||||||
params.base_tempo = 60.0f;
|
params.base_tempo = 60.0f;
|
||||||
params.demo = false;
|
params.demo = false;
|
||||||
|
|
||||||
@@ -98,13 +90,15 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
} else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) {
|
} else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) {
|
||||||
params.hot_reload = true;
|
params.hot_reload = true;
|
||||||
} else if (is_arg(arg, "-s") || is_arg(arg, "--screen")) {
|
} else if (is_arg(arg, "-s") || is_arg(arg, "--screen")) {
|
||||||
params.screen = parse_uchar(arg, value);
|
params.screen = parse_uint(arg, value);
|
||||||
} else if (is_arg(arg, "-f") || is_arg(arg, "--frag")) {
|
} else if (is_arg(arg, "-f") || is_arg(arg, "--frag")) {
|
||||||
params.frag_path = value;
|
params.frag_path = value;
|
||||||
} else if (is_arg(arg, "-fc") || is_arg(arg, "--frag-config")) {
|
} else if (is_arg(arg, "-fc") || is_arg(arg, "--frag-config")) {
|
||||||
params.frag_config_path = value;
|
params.frag_config_path = value;
|
||||||
} else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) {
|
} else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) {
|
||||||
params.base_tempo = (float)parse_ushort(arg, value);
|
params.base_tempo = (float)parse_uint(arg, value);
|
||||||
|
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
|
||||||
|
params.internal_size = (float)parse_uint(arg, value);
|
||||||
} else if (is_arg(arg, "--demo")) {
|
} else if (is_arg(arg, "--demo")) {
|
||||||
params.demo = true;
|
params.demo = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ void forge_run(Parameters params) {
|
|||||||
|
|
||||||
window_get_context(window, &context);
|
window_get_context(window, &context);
|
||||||
|
|
||||||
|
context.internal_size = params.internal_size;
|
||||||
|
|
||||||
program = shaders_init(fragment_shaders, shader_config, context);
|
program = shaders_init(fragment_shaders, shader_config, context);
|
||||||
|
|
||||||
init_context(program, &context, params);
|
init_context(program, &context, params);
|
||||||
|
|||||||
+9
-5
@@ -49,8 +49,10 @@ static void init_textures(ShaderProgram *program, Context context) {
|
|||||||
glBindTexture(GL_TEXTURE_2D, program->textures[i]);
|
glBindTexture(GL_TEXTURE_2D, program->textures[i]);
|
||||||
|
|
||||||
// define texture image as empty
|
// define texture image as empty
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context.width, context.height, 0,
|
glTexImage2D(
|
||||||
GL_RGB, GL_UNSIGNED_BYTE, 0);
|
GL_TEXTURE_2D, 0, GL_RGB,
|
||||||
|
(int)(context.internal_size * (float)context.width / context.height),
|
||||||
|
context.internal_size, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||||
|
|
||||||
// setup mipmap context
|
// setup mipmap context
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
@@ -288,8 +290,10 @@ static void update_viewport(ShaderProgram program, Context context) {
|
|||||||
// clean and resize all textures
|
// clean and resize all textures
|
||||||
for (i = 0; i < program.tex_count; i++) {
|
for (i = 0; i < program.tex_count; i++) {
|
||||||
glActiveTexture(GL_TEXTURE0 + i);
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context.width, context.height, 0,
|
glTexImage2D(
|
||||||
GL_RGB, GL_UNSIGNED_BYTE, 0);
|
GL_TEXTURE_2D, 0, GL_RGB,
|
||||||
|
(int)(context.internal_size * (float)context.width / context.height),
|
||||||
|
context.internal_size, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,5 +366,5 @@ void shaders_apply(ShaderProgram program, Context context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use_program(program, program.frag_output_index, true, context);
|
use_program(program, program.frag_monitor_index, true, context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ typedef struct Parameters {
|
|||||||
bool hot_reload;
|
bool hot_reload;
|
||||||
float base_tempo;
|
float base_tempo;
|
||||||
bool demo;
|
bool demo;
|
||||||
|
unsigned int internal_size;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|
||||||
typedef struct Vertex {
|
typedef struct Vertex {
|
||||||
@@ -73,6 +74,7 @@ typedef GLFWwindow Window;
|
|||||||
typedef struct Context {
|
typedef struct Context {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
unsigned int internal_size;
|
||||||
double time;
|
double time;
|
||||||
unsigned int fps;
|
unsigned int fps;
|
||||||
float tempo;
|
float tempo;
|
||||||
|
|||||||
Reference in New Issue
Block a user