refactor: format code
This commit is contained in:
@@ -26,19 +26,19 @@ std::unique_ptr<td::render::Renderer> renderer = std::make_unique<td::render::Re
|
||||
static int lastWidth = 0, lastHeight = 0;
|
||||
static float aspectRatio;
|
||||
|
||||
void error_callback(int error, const char* description){
|
||||
void error_callback(int error, const char* description) {
|
||||
std::cerr << "GLFW Error : " << description << std::endl;
|
||||
}
|
||||
|
||||
void windowResizeEvent(GLFWwindow* window, int width, int height){
|
||||
aspectRatio = (float) width / height;
|
||||
void windowResizeEvent(GLFWwindow* window, int width, int height) {
|
||||
aspectRatio = (float)width / height;
|
||||
renderer->resize(width, height);
|
||||
lastWidth = width;
|
||||
lastHeight = height;
|
||||
}
|
||||
|
||||
void create() {
|
||||
glfwSetErrorCallback(&error_callback);
|
||||
glfwSetErrorCallback(&error_callback);
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
@@ -46,15 +46,15 @@ void create() {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_NAME, nullptr, nullptr);
|
||||
glfwMakeContextCurrent(window);
|
||||
if(!renderer->init()){
|
||||
exit(1);
|
||||
}
|
||||
TowerGui::init(window, renderer.get());
|
||||
if (!renderer->init()) {
|
||||
exit(1);
|
||||
}
|
||||
TowerGui::init(window, renderer.get());
|
||||
windowResizeEvent(window, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
}
|
||||
|
||||
void render() {
|
||||
renderer->prepare();
|
||||
renderer->prepare();
|
||||
TowerGui::render();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void update() {
|
||||
glfwSwapBuffers(window);
|
||||
int windowWidth, windowHeight;
|
||||
glfwGetWindowSize(window, &windowWidth, &windowHeight);
|
||||
if(windowWidth != lastWidth || windowHeight != lastHeight){
|
||||
if (windowWidth != lastWidth || windowHeight != lastHeight) {
|
||||
windowResizeEvent(window, windowWidth, windowHeight);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void destroy() {
|
||||
renderer.reset(0);
|
||||
TowerGui::destroy();
|
||||
glfwDestroyWindow(window);
|
||||
window = NULL;
|
||||
window = NULL;
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
@@ -80,21 +80,21 @@ void pollEvents() {
|
||||
}
|
||||
|
||||
bool isCloseRequested() {
|
||||
return glfwWindowShouldClose(window);
|
||||
return glfwWindowShouldClose(window);
|
||||
}
|
||||
|
||||
bool isMouseDown(int button) {
|
||||
return glfwGetMouseButton(window, button);
|
||||
return glfwGetMouseButton(window, button);
|
||||
}
|
||||
|
||||
float getAspectRatio(){
|
||||
float getAspectRatio() {
|
||||
return aspectRatio;
|
||||
}
|
||||
|
||||
int getWindowWidth(){
|
||||
int getWindowWidth() {
|
||||
return lastWidth;
|
||||
}
|
||||
int getWindowHeight(){
|
||||
int getWindowHeight() {
|
||||
return lastHeight;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user