diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
commit | 9b7be419c9dcc6ebd1e504713c7b2676ca3d2fdf (patch) | |
tree | 97a2fc5ce1ec1345bd6f44889682ea9a2ffafd76 /src/crepe/SDLApp.cpp | |
parent | 080ad535e6fc6666b919b1a21b6986aaf9b678eb (diff) |
`clang-format`
Diffstat (limited to 'src/crepe/SDLApp.cpp')
-rw-r--r-- | src/crepe/SDLApp.cpp | 111 |
1 files changed, 51 insertions, 60 deletions
diff --git a/src/crepe/SDLApp.cpp b/src/crepe/SDLApp.cpp index ca7e819..198c0d0 100644 --- a/src/crepe/SDLApp.cpp +++ b/src/crepe/SDLApp.cpp @@ -1,78 +1,69 @@ #include "SDLApp.h" -#include <iostream> -#include <vector> #include "Particle.h" #include "api/ParticleEmitter.h" +#include <iostream> +#include <vector> -SDLApp::SDLApp(int windowWidth, int windowHeight) - : windowWidth(windowWidth), windowHeight(windowHeight), window(nullptr), renderer(nullptr) {} +SDLApp::SDLApp(int window_width, int window_height) + : window_width(window_width), window_height(window_height), window(nullptr), + renderer(nullptr) {} -SDLApp::~SDLApp() { - cleanUp(); -} +SDLApp::~SDLApp() { clean_up(); } bool SDLApp::initialize() { - if (SDL_Init(SDL_INIT_VIDEO) != 0) { - std::cerr << "SDL Initialization Error: " << SDL_GetError() << std::endl; - return false; - } - - window = SDL_CreateWindow("Particle System", - SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, - windowWidth, - windowHeight, - SDL_WINDOW_SHOWN); - if (!window) { - std::cerr << "Window Creation Error: " << SDL_GetError() << std::endl; - return false; - } - - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); - if (!renderer) { - std::cerr << "Renderer Creation Error: " << SDL_GetError() << std::endl; - return false; - } - - return true; + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + std::cerr << "SDL Initialization Error: " << SDL_GetError() + << std::endl; + return false; + } + + window = SDL_CreateWindow("Particle System", SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, window_width, window_height, + SDL_WINDOW_SHOWN); + if (!window) { + std::cerr << "Window Creation Error: " << SDL_GetError() << std::endl; + return false; + } + + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + if (!renderer) { + std::cerr << "Renderer Creation Error: " << SDL_GetError() << std::endl; + return false; + } + + return true; } -void SDLApp::handleEvents(bool& running) { - SDL_Event event; - while (SDL_PollEvent(&event)) { - if (event.type == SDL_QUIT) { - running = false; - } - } +void SDLApp::handle_events(bool & running) { + SDL_Event event; + while (SDL_PollEvent(&event)) { + if (event.type == SDL_QUIT) { + running = false; + } + } } -void SDLApp::clearScreen() { - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); - SDL_RenderClear(renderer); +void SDLApp::clear_screen() { + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); } -void SDLApp::presentScreen() { - SDL_RenderPresent(renderer); -} +void SDLApp::present_screen() { SDL_RenderPresent(renderer); } -void SDLApp::drawSquare(int x, int y, int size) { - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - SDL_Rect rect = { x, y, size, size }; - SDL_RenderFillRect(renderer, &rect); +void SDLApp::draw_square(int x, int y, int size) { + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_Rect rect = {x, y, size, size}; + SDL_RenderFillRect(renderer, &rect); } -SDL_Texture* squareTexture = nullptr; // Load this with an image or create it - - - - +SDL_Texture * square_texture = nullptr; // Load this with an image or create it -void SDLApp::cleanUp() { - if (renderer) { - SDL_DestroyRenderer(renderer); - } - if (window) { - SDL_DestroyWindow(window); - } - SDL_Quit(); +void SDLApp::clean_up() { + if (renderer) { + SDL_DestroyRenderer(renderer); + } + if (window) { + SDL_DestroyWindow(window); + } + SDL_Quit(); } |