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 constexpr int WindowWidth = 800;
static constexpr int WindowHeight= 600;
static constexpr int WindowHeight = 600;
static constexpr const char WindowName[] = "Tower Defense";
std::unique_ptr<td::render::Renderer> renderer = std::make_unique<td::render::Renderer>();
@@ -64,9 +64,8 @@ bool create() {
glContext = SDL_GL_CreateContext(window);
if (!glContext)
{
std::cerr << "Could not create context! SDL reports error: " << SDL_GetError() << std::endl;
if (!glContext) {
std::cerr << "Could not create context! SDL error: " << SDL_GetError() << std::endl;
return false;
}
@@ -76,9 +75,9 @@ bool create() {
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
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_BLUE_SIZE, &b);
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &a);
SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
@@ -96,7 +95,7 @@ bool create() {
}
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);
@@ -128,21 +127,21 @@ void destroy() {
void pollEvents() {
SDL_Event event;
while(SDL_PollEvent(&event)){
if(event.type == SDL_WINDOWEVENT){
switch(event.window.event){
case SDL_WINDOWEVENT_CLOSE:{
shouldClose = true;
}
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT) {
switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE: {
shouldClose = true;
}
case SDL_WINDOWEVENT_RESIZED:{
int windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
windowResizeEvent(windowWidth, windowHeight);
}
case SDL_WINDOWEVENT_RESIZED: {
int windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
windowResizeEvent(windowWidth, windowHeight);
}
default:
break;
default:
break;
}
}
ImGui_ImplSDL2_ProcessEvent(&event);