Skip to content

Commit

Permalink
refactor: read from input
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJPinto committed Mar 4, 2024
1 parent b135c26 commit 7ae169a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 9 additions & 6 deletions engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

float cameraAngle = 90.0f;
float cameraAngleY = 0.0f;
char* file = "";

Configuration c;

void changeSize(int w, int h) {
Expand Down Expand Up @@ -60,7 +60,10 @@ void renderScene(void) {
glEnd();

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
drawFile(file);
for(std::string model : c.models) {
drawFile(model.data());
}


// End of frame
glutSwapBuffers();
Expand Down Expand Up @@ -97,17 +100,17 @@ void processSpecialKeys(int key, int xx, int yy) {

int main(int argc, char** argv) {
std::string filename;
filename.assign("../engine/test.xml");
filename.assign(argv[1]);
c = parseConfig(filename);

// put GLUT�s init here
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(800, 800);
glutInitWindowSize(c.window.width, c.window.height);
glutCreateWindow("CG@DI");

// put callback registry here
file = argv[1];
glutReshapeFunc(changeSize);
glutIdleFunc(renderScene);
glutDisplayFunc(renderScene);
glutReshapeFunc(reshape);
Expand Down
5 changes: 3 additions & 2 deletions engine/test.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<world>
<window width="512" height="512" /> <!-- gluPerspective Ratio -->
<camera>
<position x="3" y="2" z="1" /> <!-- gluLookAt eye -->
<position x="5" y="5" z="5" /> <!-- gluLookAt eye -->
<lookAt x="0" y="0" z="0" /> <!-- gluLookAt center-->
<up x="0" y="1" z="0" /> <!-- gluLookAt up-->
<projection fov="60" near="1" far="1000" /> <!--gluPerspective-->
</camera>
<group>
<models>
<model file="cone.3d" /> <!-- generator cone 1 2 4 3 cone.3d -->
<model file="cone.3d" />
<model file="sphere.3d" /> <!-- generator cone 1 2 4 3 cone.3d -->
</models>
</group>
</world>

0 comments on commit 7ae169a

Please sign in to comment.