diff options
| author | cflip <cflip@cflip.net> | 2022-02-20 09:15:40 -0700 | 
|---|---|---|
| committer | cflip <cflip@cflip.net> | 2022-02-20 09:15:40 -0700 | 
| commit | a3f4ac00ee76f5e3b2dae7838a6c13ccae40ceac (patch) | |
| tree | af8575869f901657b2252c56c7a15e278ef2c0f7 /src/main.cpp | |
| parent | 3828bb56022c636a7dd056a4781249222ea0d3ca (diff) | |
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 57 | 
1 files changed, 57 insertions, 0 deletions
| diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6056442 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,57 @@ +#include <SDL.h> +#include <iostream> + +#include "audio.h" +#include "gui.h" +#include "sequence.h" + +int main(int argc, char** argv) +{ +	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { +		std::cerr << "Failed to initalize SDL! " << SDL_GetError() << std::endl; +		return 1; +	} + +	SDL_Window* window = SDL_CreateWindow("fmseq", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 320, SDL_WINDOW_SHOWN); +	SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); +	SDL_Event event; + +	Sequence sequence; +	AudioContext audio(sequence); +	GUI gui(sequence); + +	bool running = true; +	while (running) { +		while (SDL_PollEvent(&event)) { +			switch (event.type) { +			case SDL_QUIT: +				running = false; +				break; +			case SDL_MOUSEBUTTONDOWN: +				gui.OnMouseDown(event.button.x, event.button.y); +				break; +			case SDL_MOUSEMOTION: +				gui.OnMouseMove(event.button.x, event.button.y); +				break; +			case SDL_MOUSEBUTTONUP: +				gui.OnMouseUp(); +				break; +			} +		} +		 +		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); +		SDL_RenderClear(renderer); + +		gui.Repaint(renderer, audio.CurrentStep()); + +		SDL_RenderPresent(renderer); +		SDL_UpdateWindowSurface(window); + +		SDL_Delay(10); +	} + +	SDL_DestroyWindow(window); +	SDL_Quit(); + +	return 0; +}
\ No newline at end of file | 
