internal size
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
TARGET ?= forge
|
||||
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
|
||||
|
||||
.PHONY: build
|
||||
|
||||
@@ -115,6 +115,8 @@ make -f Makefile.dev release-arch
|
||||
- [x] demo mode
|
||||
- [x] random seed injected into shaders
|
||||
- [ ] internal texture size for speed
|
||||
- [ ] pass state as uniform
|
||||
- [ ] debug shader (and in monitor)
|
||||
- [ ] Clean code and fix things
|
||||
- [ ] Midi
|
||||
- [ ] Read Midi events
|
||||
|
||||
+11
-17
@@ -1,3 +1,4 @@
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -30,6 +31,7 @@ static void print_help(int status_code) {
|
||||
" -s, --screen output screen number (default: primary)\n"
|
||||
" -f, --frag fragment shaders directory (default: TODO)\n"
|
||||
" -fc, --frag-config fragment shaders config file (default: TODO)\n"
|
||||
" -is, --internal-size internal texture height (default: 720)\n"
|
||||
" -t, --tempo base tempo (default: 60)\n"
|
||||
" --demo demonstration mode\n");
|
||||
exit(status_code);
|
||||
@@ -52,26 +54,15 @@ static char *split_arg_value(char *arg) {
|
||||
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)) {
|
||||
invalid_value(arg, value);
|
||||
}
|
||||
unsigned long long tmp_value = (unsigned long long)atoll(value);
|
||||
if (tmp_value >= 256) {
|
||||
if (tmp_value >= UINT_MAX) {
|
||||
invalid_value(arg, value);
|
||||
}
|
||||
return (unsigned char)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;
|
||||
return (unsigned int)tmp_value;
|
||||
}
|
||||
|
||||
Parameters args_parse(int argc, char **argv) {
|
||||
@@ -80,10 +71,11 @@ Parameters args_parse(int argc, char **argv) {
|
||||
char *arg;
|
||||
char *value;
|
||||
|
||||
params.hot_reload = false;
|
||||
params.screen = 0;
|
||||
params.frag_path = 0;
|
||||
params.frag_config_path = 0;
|
||||
params.hot_reload = false;
|
||||
params.internal_size = 720;
|
||||
params.base_tempo = 60.0f;
|
||||
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")) {
|
||||
params.hot_reload = true;
|
||||
} 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")) {
|
||||
params.frag_path = value;
|
||||
} else if (is_arg(arg, "-fc") || is_arg(arg, "--frag-config")) {
|
||||
params.frag_config_path = value;
|
||||
} 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")) {
|
||||
params.demo = true;
|
||||
} else {
|
||||
|
||||
@@ -175,6 +175,8 @@ void forge_run(Parameters params) {
|
||||
|
||||
window_get_context(window, &context);
|
||||
|
||||
context.internal_size = params.internal_size;
|
||||
|
||||
program = shaders_init(fragment_shaders, shader_config, context);
|
||||
|
||||
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]);
|
||||
|
||||
// define texture image as empty
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context.width, context.height, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||
glTexImage2D(
|
||||
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
|
||||
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
|
||||
for (i = 0; i < program.tex_count; i++) {
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context.width, context.height, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||
glTexImage2D(
|
||||
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;
|
||||
float base_tempo;
|
||||
bool demo;
|
||||
unsigned int internal_size;
|
||||
} Parameters;
|
||||
|
||||
typedef struct Vertex {
|
||||
@@ -73,6 +74,7 @@ typedef GLFWwindow Window;
|
||||
typedef struct Context {
|
||||
int width;
|
||||
int height;
|
||||
unsigned int internal_size;
|
||||
double time;
|
||||
unsigned int fps;
|
||||
float tempo;
|
||||
|
||||
Reference in New Issue
Block a user