2021-12-19 22:44:48 +00:00
|
|
|
// draw.c
|
|
|
|
|
|
|
|
void draw_frame(SDL_Window *w, SDL_Renderer *r, Ampler_state *state) {
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_SetRenderDrawColor(r, 0x1D, 0x2B, 0x53, 255);
|
2021-12-21 01:37:24 +00:00
|
|
|
//SDL_SetRenderDrawColor(r, 10, 10, 10, 100);
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_RenderClear(r);
|
|
|
|
|
2021-12-21 01:37:24 +00:00
|
|
|
// TODO: ACTUALLY DRAW ALL SOUNDS, BUT SMOLER
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_SetRenderDrawColor(r, 0xFF, 0x00, 0x4D, 255);
|
|
|
|
const space = (44100 * 8) / 512;
|
2021-12-21 01:37:24 +00:00
|
|
|
const int t = 0;
|
2021-12-20 00:03:14 +00:00
|
|
|
for int x = 0; x < 512; x += 1 do {
|
|
|
|
const int y = 128 + 256 * t;
|
2021-12-21 01:37:24 +00:00
|
|
|
const int val = state -> sounds[0].tracks[t][x * space];
|
|
|
|
SDL_RenderDrawLine(r, x, y + val / 8, x, y + val);
|
|
|
|
//SDL_RenderDrawPoint(r, x, y + val);
|
2021-12-20 00:03:14 +00:00
|
|
|
}
|
|
|
|
|
2021-12-20 02:06:02 +00:00
|
|
|
if state -> played_audio_last_frame do
|
|
|
|
for int i = 0; i < arraylen(state -> sounds); i += 1 do {
|
2021-12-21 01:37:24 +00:00
|
|
|
const int x = state -> sounds[i].pos / space;
|
|
|
|
SDL_RenderDrawLine(r, x, 0, x, 512);
|
2021-12-20 02:06:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_RenderPresent(r);
|
2021-12-19 22:44:48 +00:00
|
|
|
}
|