Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJPinto committed Feb 28, 2024
1 parent a441398 commit 0c2d338
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
4 changes: 3 additions & 1 deletion engine/include/draw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#define DRAW_HPP

#include <math.h>

#include <vector>

#include "draw.hpp"
#include "utils.hpp"

void drawTriangles(const std::vector<Point>& points);

void drawFile(char* filename);

#endif //DRAW_HPP
#endif // DRAW_HPP
36 changes: 18 additions & 18 deletions engine/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>

#include "draw.hpp"
#include "utils.hpp"

void drawTriangles(const std::vector<Point>& points) {
glBegin(GL_TRIANGLES);
for (size_t i = 0; i < points.size(); i += 3) {
// Draw each triangle
glVertex3f(points[i].x, points[i].y, points[i].z);
glVertex3f(points[i + 1].x, points[i + 1].y, points[i + 1].z);
glVertex3f(points[i + 2].x, points[i + 2].y, points[i + 2].z);
}
glEnd();
glBegin(GL_TRIANGLES);
for (size_t i = 0; i < points.size(); i += 3) {
// Draw each triangle
glVertex3f(points[i].x, points[i].y, points[i].z);
glVertex3f(points[i + 1].x, points[i + 1].y, points[i + 1].z);
glVertex3f(points[i + 2].x, points[i + 2].y, points[i + 2].z);
}
glEnd();
}

void drawFile(char* filename) {
std::string dir = "../models/";
dir.append(filename);

std::string dir = "../models/";
dir.append(filename);

std::vector<Point> points = parseFile(dir);
if (points.empty()) {
// File not found or empty, handle this case
return;
}
drawTriangles(points);
std::vector<Point> points = parseFile(dir);
if (points.empty()) {
// File not found or empty, handle this case
return;
}
drawTriangles(points);
}

34 changes: 16 additions & 18 deletions engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#define _USE_MATH_DEFINES
#include <math.h>
#include "draw.hpp"

#include "draw.hpp"

char* file = "";

Expand Down Expand Up @@ -39,30 +39,29 @@ void renderScene(void) {

// put drawing instructions here
glBegin(GL_LINES);
// x-axis (red)
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
// y-axis (green)
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
// z-axis (blue)
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glVertex3f(0.0f, 0.0f, 1.0f);
glEnd();
// x-axis (red)
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
// y-axis (green)
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
// z-axis (blue)
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glVertex3f(0.0f, 0.0f, 1.0f);
glEnd();
glEnd();

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
drawFile(file);


// End of frame
glutSwapBuffers();
}

int main(int argc, char **argv) {
int main(int argc, char** argv) {
// put GLUT�s init here
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
Expand All @@ -76,10 +75,9 @@ int main(int argc, char **argv) {
glutIdleFunc(renderScene);
glutDisplayFunc(renderScene);


// some OpenGL settings
glEnable(GL_DEPTH_TEST);
//glEnable(GL_CULL_FACE);
// glEnable(GL_CULL_FACE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

// enter GLUT�s main cycle
Expand Down
24 changes: 12 additions & 12 deletions engine/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
#include <vector>

std::vector<Point> parseFile(std::string filename) {
std::vector<Point> points;
std::ifstream file(filename);

if (!file.is_open()) {
std::cerr << "Error: Unable to open file " << filename << std::endl;
return points;
}
std::vector<Point> points;
std::ifstream file(filename);

Point point;
while (file >> point.x >> point.y >> point.z) {
points.push_back(point);
}
file.close();
if (!file.is_open()) {
std::cerr << "Error: Unable to open file " << filename << std::endl;
return points;
}

Point point;
while (file >> point.x >> point.y >> point.z) {
points.push_back(point);
}
file.close();
return points;
}
6 changes: 3 additions & 3 deletions generator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void generateFigure(int argc, char* argv[]) {
return;
}

std::string figureType = argv[argc - 1];
char* figureType = argv[argc - 1];
std::string figureName = argv[1];

if (figureName == "sphere" && argc == 6) {
Expand All @@ -22,15 +22,15 @@ void generateFigure(int argc, char* argv[]) {
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);

generateCube(length, divisions, argv[4]);
generateCube(length, divisions, figureType);
} else if (figureName == "plane" && argc == 5) {
// Generate Plane
std::cout << "Generating Plane\n"; // Added newline here
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);

generatePlane(length, divisions,
argv[4]); // Assuming saveToFile is available
figureType); // Assuming saveToFile is available
} else if (figureName == "cone" && argc == 7) {
// Generate Cone
std::cout << "Generating Cone\n";
Expand Down

0 comments on commit 0c2d338

Please sign in to comment.