Skip to content

Commit

Permalink
refactor: detail
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJPinto committed Feb 28, 2024
1 parent 0c2d338 commit 9dce105
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
4 changes: 3 additions & 1 deletion engine/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "draw.hpp"
#include "utils.hpp"

#define MODELS "../models/"

void drawTriangles(const std::vector<Point>& points) {
glBegin(GL_TRIANGLES);
for (size_t i = 0; i < points.size(); i += 3) {
Expand All @@ -24,7 +26,7 @@ void drawTriangles(const std::vector<Point>& points) {
}

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

std::vector<Point> points = parseFile(dir);
Expand Down
34 changes: 18 additions & 16 deletions engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#define _USE_MATH_DEFINES
#include <math.h>

#include "draw.hpp"


char* file = "";

void changeSize(int w, int h) {
Expand Down Expand Up @@ -39,29 +39,30 @@ 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 @@ -75,9 +76,10 @@ 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

0 comments on commit 9dce105

Please sign in to comment.