Skip to content

Commit

Permalink
fix: formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Feb 15, 2024
1 parent f1d4338 commit 6f98763
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 88 deletions.
15 changes: 7 additions & 8 deletions include/figure.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#pragma once
#include <vector>
#include <string>
#include <tuple>
#include <vector>

typedef std::vector<std::tuple<std::string, std::string>> Point;

class Figure
{
public:
Figure();
void exportFile(std::string filename);
class Figure {
public:
Figure();
void exportFile(std::string filename);

private:
std::vector<Point> points;
private:
std::vector<Point> points;
};
4 changes: 3 additions & 1 deletion include/figure_generator.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once
#include <memory>

#include "figure.hpp"

std::unique_ptr<Figure> generatePlane(float length, int divisions);
std::unique_ptr<Figure> generateBox(float dimension, int divisions);
std::unique_ptr<Figure> generateSphere(float radius, int slices, int stacks);
std::unique_ptr<Figure> generateCone(float radius, float height, int slices, int stacks);
std::unique_ptr<Figure> generateCone(float radius, float height, int slices,
int stacks);
94 changes: 44 additions & 50 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,59 @@
#define _USE_MATH_DEFINES
#include <math.h>

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;
}
15 changes: 6 additions & 9 deletions src/figure.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include "figure.hpp"

#include <fstream>

Figure::Figure()
{
points = std::vector<Point>();
}
Figure::Figure() { points = std::vector<Point>(); }

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();
}
30 changes: 14 additions & 16 deletions src/figure_generator.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#include "figure_generator.hpp"

#include <iostream>

// This is a placeholder for the actual implementation of the functions

std::unique_ptr<Figure> generatePlane(float length, int divisions)
{
std::cout << "Generating Plane\n";
return std::make_unique<Figure>();
std::unique_ptr<Figure> generatePlane(float length, int divisions) {
std::cout << "Generating Plane\n";
return std::make_unique<Figure>();
}

std::unique_ptr<Figure> generateBox(float dimension, int divisions)
{
std::cout << "Generating Box\n";
return std::make_unique<Figure>();
std::unique_ptr<Figure> generateBox(float dimension, int divisions) {
std::cout << "Generating Box\n";
return std::make_unique<Figure>();
}

std::unique_ptr<Figure> generateSphere(float radius, int slices, int stacks)
{
std::cout << "Generating Sphere\n";
return std::make_unique<Figure>();
std::unique_ptr<Figure> generateSphere(float radius, int slices, int stacks) {
std::cout << "Generating Sphere\n";
return std::make_unique<Figure>();
}

std::unique_ptr<Figure> generateCone(float radius, float height, int slices, int stacks)
{
std::cout << "Generating Cone\n";
return std::make_unique<Figure>();
std::unique_ptr<Figure> generateCone(float radius, float height, int slices,
int stacks) {
std::cout << "Generating Cone\n";
return std::make_unique<Figure>();
}
7 changes: 3 additions & 4 deletions src/generator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>

int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

0 comments on commit 6f98763

Please sign in to comment.