feat: iBeats
This commit is contained in:
@@ -214,6 +214,7 @@ static void loop(bool hr, bool trace_fps) {
|
||||
compute_fps(trace_fps);
|
||||
|
||||
context->time = window_get_time();
|
||||
context->tempo_total = (float)tempo_total(context->tempo);
|
||||
|
||||
if (window_output != NULL) {
|
||||
window_use(window_output, context);
|
||||
|
||||
+7
-1
@@ -3,12 +3,14 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "arr.h"
|
||||
#include "config.h"
|
||||
#include "config_file.h"
|
||||
#include "constants.h"
|
||||
#include "shaders.h"
|
||||
#include "types.h"
|
||||
#include "tempo.h"
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include <glad/gl.h>
|
||||
@@ -252,6 +254,9 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
|
||||
program->itempo_locations[i] = glGetUniformLocation(
|
||||
program->programs[i],
|
||||
config_file_get_str(config, "UNIFORM_TEMPO", "iTempo"));
|
||||
program->ibeats_locations[i] = glGetUniformLocation(
|
||||
program->programs[i],
|
||||
config_file_get_str(config, "UNIFORM_BEATS", "iBeats"));
|
||||
program->ifps_locations[i] = glGetUniformLocation(
|
||||
program->programs[i], config_file_get_str(config, "UNIFORM_FPS", "iFPS"));
|
||||
program->ires_locations[i] = glGetUniformLocation(
|
||||
@@ -507,6 +512,7 @@ static void use_program(ShaderProgram program, int i, bool output,
|
||||
// set fragment uniforms
|
||||
write_uniform_1f(program.itime_locations[i], context->time);
|
||||
write_uniform_1f(program.itempo_locations[i], context->tempo.tempo);
|
||||
write_uniform_1f(program.ibeats_locations[i], context->tempo_total);
|
||||
write_uniform_1i(program.ifps_locations[i], context->fps);
|
||||
write_uniform_1i(program.idemo_locations[i], context->demo ? 1 : 0);
|
||||
write_uniform_1i(program.ipage_locations[i], context->page);
|
||||
|
||||
+6
-4
@@ -3,7 +3,6 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "tempo.h"
|
||||
|
||||
static long now() {
|
||||
@@ -112,11 +111,14 @@ void tempo_tap(Tempo *tempo) {
|
||||
add_tap_to_chain(tempo, t);
|
||||
}
|
||||
|
||||
double tempo_progress(Tempo tempo, double modulo) {
|
||||
double tempo_total(Tempo tempo) {
|
||||
long t;
|
||||
|
||||
t = now();
|
||||
|
||||
return fmod((double)(t - tempo.last_reset) / (double)tempo.beat_length,
|
||||
modulo);
|
||||
return (double)(t - tempo.last_reset) / (double)tempo.beat_length;
|
||||
}
|
||||
|
||||
double tempo_progress(Tempo tempo, double modulo) {
|
||||
return fmod(tempo_total(tempo), modulo);
|
||||
}
|
||||
@@ -9,6 +9,8 @@ void tempo_tap(Tempo *tempo);
|
||||
|
||||
void tempo_set(Tempo *tempo, float value);
|
||||
|
||||
double tempo_total(Tempo tempo);
|
||||
|
||||
double tempo_progress(Tempo tempo, double modulo);
|
||||
|
||||
#endif /* TEMPO_H */
|
||||
@@ -88,6 +88,7 @@ typedef struct ShaderProgram {
|
||||
|
||||
GLuint itime_locations[ARRAY_SIZE];
|
||||
GLuint itempo_locations[ARRAY_SIZE];
|
||||
GLuint ibeats_locations[ARRAY_SIZE];
|
||||
GLuint ifps_locations[ARRAY_SIZE];
|
||||
GLuint ires_locations[ARRAY_SIZE];
|
||||
GLuint itexres_locations[ARRAY_SIZE];
|
||||
@@ -157,6 +158,7 @@ typedef struct SharedContext {
|
||||
double time;
|
||||
unsigned int fps;
|
||||
Tempo tempo;
|
||||
double tempo_total;
|
||||
UintArray state;
|
||||
unsigned int page;
|
||||
unsigned int selected;
|
||||
|
||||
Reference in New Issue
Block a user