From 6f987639cf77b881a44f118446b24158ba0912d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Thu, 15 Feb 2024 21:49:00 +0000 Subject: [PATCH] fix: formatting and linting --- include/figure.hpp | 15 +++--- include/figure_generator.hpp | 4 +- src/engine.cpp | 94 +++++++++++++++++------------------- src/figure.cpp | 15 +++--- src/figure_generator.cpp | 30 ++++++------ src/generator.cpp | 7 ++- 6 files changed, 77 insertions(+), 88 deletions(-) diff --git a/include/figure.hpp b/include/figure.hpp index 66aeab5..98df288 100644 --- a/include/figure.hpp +++ b/include/figure.hpp @@ -1,16 +1,15 @@ #pragma once -#include #include #include +#include typedef std::vector> Point; -class Figure -{ -public: - Figure(); - void exportFile(std::string filename); +class Figure { + public: + Figure(); + void exportFile(std::string filename); -private: - std::vector points; + private: + std::vector points; }; \ No newline at end of file diff --git a/include/figure_generator.hpp b/include/figure_generator.hpp index 0e1903c..cd37105 100644 --- a/include/figure_generator.hpp +++ b/include/figure_generator.hpp @@ -1,8 +1,10 @@ #pragma once #include + #include "figure.hpp" std::unique_ptr
generatePlane(float length, int divisions); std::unique_ptr
generateBox(float dimension, int divisions); std::unique_ptr
generateSphere(float radius, int slices, int stacks); -std::unique_ptr
generateCone(float radius, float height, int slices, int stacks); +std::unique_ptr
generateCone(float radius, float height, int slices, + int stacks); diff --git a/src/engine.cpp b/src/engine.cpp index 01a89d3..9324e89 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -7,65 +7,59 @@ #define _USE_MATH_DEFINES #include -void changeSize(int w, int h) -{ - // Prevent a divide by zero, when window is too short - // (you can�t make a window with zero width). - if (h == 0) - h = 1; - // compute window's aspect ratio - float ratio = w * 1.0f / h; - // Set the projection matrix as current - glMatrixMode(GL_PROJECTION); - // Load the identity matrix - glLoadIdentity(); - // Set the viewport to be the entire window - glViewport(0, 0, w, h); - // Set the perspective - gluPerspective(45.0f, ratio, 1.0f, 1000.0f); - // return to the model view matrix mode - glMatrixMode(GL_MODELVIEW); +void changeSize(int w, int h) { + // Prevent a divide by zero, when window is too short + // (you can�t make a window with zero width). + if (h == 0) h = 1; + // compute window's aspect ratio + float ratio = w * 1.0f / h; + // Set the projection matrix as current + glMatrixMode(GL_PROJECTION); + // Load the identity matrix + glLoadIdentity(); + // Set the viewport to be the entire window + glViewport(0, 0, w, h); + // Set the perspective + gluPerspective(45.0f, ratio, 1.0f, 1000.0f); + // return to the model view matrix mode + glMatrixMode(GL_MODELVIEW); } -void renderScene(void) -{ - // clear buffers - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +void renderScene(void) { + // clear buffers + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - // set camera - glLoadIdentity(); - gluLookAt(0.0f, 0.0f, 5.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 1.0f, 0.0f); + // set camera + glLoadIdentity(); + gluLookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f); - // put drawing instructions here - glutWireTeapot(1); + // put drawing instructions here + glutWireTeapot(1); - // End of frame - glutSwapBuffers(); + // End of frame + glutSwapBuffers(); } -int main(int argc, char **argv) -{ - // put GLUT�s init here - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); - glutInitWindowPosition(100, 100); - glutInitWindowSize(800, 800); - glutCreateWindow("CG@DI"); +int main(int argc, char **argv) { + // put GLUT�s init here + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); + glutInitWindowPosition(100, 100); + glutInitWindowSize(800, 800); + glutCreateWindow("CG@DI"); - // put callback registry here - glutReshapeFunc(changeSize); - glutIdleFunc(renderScene); - glutDisplayFunc(renderScene); + // put callback registry here + glutReshapeFunc(changeSize); + glutIdleFunc(renderScene); + glutDisplayFunc(renderScene); - // some OpenGL settings - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + // some OpenGL settings + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - // enter GLUT�s main cycle - glutMainLoop(); + // enter GLUT�s main cycle + glutMainLoop(); - return 1; + return 1; } \ No newline at end of file diff --git a/src/figure.cpp b/src/figure.cpp index 62de665..c152513 100644 --- a/src/figure.cpp +++ b/src/figure.cpp @@ -1,14 +1,11 @@ #include "figure.hpp" + #include -Figure::Figure() -{ - points = std::vector(); -} +Figure::Figure() { points = std::vector(); } -void Figure::exportFile(std::string filename) -{ - std::ofstream file(filename); - file << "Test\n"; - file.close(); +void Figure::exportFile(std::string filename) { + std::ofstream file(filename); + file << "Test\n"; + file.close(); } \ No newline at end of file diff --git a/src/figure_generator.cpp b/src/figure_generator.cpp index b227590..6ff9982 100644 --- a/src/figure_generator.cpp +++ b/src/figure_generator.cpp @@ -1,28 +1,26 @@ #include "figure_generator.hpp" + #include // This is a placeholder for the actual implementation of the functions -std::unique_ptr
generatePlane(float length, int divisions) -{ - std::cout << "Generating Plane\n"; - return std::make_unique
(); +std::unique_ptr
generatePlane(float length, int divisions) { + std::cout << "Generating Plane\n"; + return std::make_unique
(); } -std::unique_ptr
generateBox(float dimension, int divisions) -{ - std::cout << "Generating Box\n"; - return std::make_unique
(); +std::unique_ptr
generateBox(float dimension, int divisions) { + std::cout << "Generating Box\n"; + return std::make_unique
(); } -std::unique_ptr
generateSphere(float radius, int slices, int stacks) -{ - std::cout << "Generating Sphere\n"; - return std::make_unique
(); +std::unique_ptr
generateSphere(float radius, int slices, int stacks) { + std::cout << "Generating Sphere\n"; + return std::make_unique
(); } -std::unique_ptr
generateCone(float radius, float height, int slices, int stacks) -{ - std::cout << "Generating Cone\n"; - return std::make_unique
(); +std::unique_ptr
generateCone(float radius, float height, int slices, + int stacks) { + std::cout << "Generating Cone\n"; + return std::make_unique
(); } diff --git a/src/generator.cpp b/src/generator.cpp index df28b27..46c9bce 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -1,7 +1,6 @@ #include -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; } \ No newline at end of file