refactor: format

This commit is contained in:
2021-11-14 12:04:11 +01:00
parent 004b9b714d
commit 44922d1819

View File

@@ -24,7 +24,7 @@ static SDL_Window* window;
static SDL_GLContext glContext; static SDL_GLContext glContext;
static constexpr int WindowWidth = 800; static constexpr int WindowWidth = 800;
static constexpr int WindowHeight= 600; static constexpr int WindowHeight = 600;
static constexpr const char WindowName[] = "Tower Defense"; static constexpr const char WindowName[] = "Tower Defense";
std::unique_ptr<td::render::Renderer> renderer = std::make_unique<td::render::Renderer>(); std::unique_ptr<td::render::Renderer> renderer = std::make_unique<td::render::Renderer>();
@@ -64,9 +64,8 @@ bool create() {
glContext = SDL_GL_CreateContext(window); glContext = SDL_GL_CreateContext(window);
if (!glContext) if (!glContext) {
{ std::cerr << "Could not create context! SDL error: " << SDL_GetError() << std::endl;
std::cerr << "Could not create context! SDL reports error: " << SDL_GetError() << std::endl;
return false; return false;
} }
@@ -76,9 +75,9 @@ bool create() {
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &a); SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &a);
SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth); SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
@@ -96,7 +95,7 @@ bool create() {
} }
std::cout << "GL Context: " << major << "." << minor << " " << mask_desc std::cout << "GL Context: " << major << "." << minor << " " << mask_desc
<< ", Color : R" << r << "G" << g << "B" << b << "A" << a << ", Depth bits: " << depth << std::endl; << ", Color : R" << r << "G" << g << "B" << b << "A" << a << ", Depth bits: " << depth << std::endl;
SDL_GL_MakeCurrent(window, glContext); SDL_GL_MakeCurrent(window, glContext);
@@ -128,21 +127,21 @@ void destroy() {
void pollEvents() { void pollEvents() {
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)){ while (SDL_PollEvent(&event)) {
if(event.type == SDL_WINDOWEVENT){ if (event.type == SDL_WINDOWEVENT) {
switch(event.window.event){ switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE:{ case SDL_WINDOWEVENT_CLOSE: {
shouldClose = true; shouldClose = true;
} }
case SDL_WINDOWEVENT_RESIZED:{ case SDL_WINDOWEVENT_RESIZED: {
int windowWidth, windowHeight; int windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight); SDL_GetWindowSize(window, &windowWidth, &windowHeight);
windowResizeEvent(windowWidth, windowHeight); windowResizeEvent(windowWidth, windowHeight);
} }
default: default:
break; break;
} }
} }
ImGui_ImplSDL2_ProcessEvent(&event); ImGui_ImplSDL2_ProcessEvent(&event);