half-edge/src/main.c

81 lines
1.9 KiB
C
Raw Normal View History

2014-05-06 21:20:16 +00:00
/*
* Copyright 2011-2014 hasufell
*
* This file is part of a hasufell project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2014-05-10 17:39:20 +00:00
/**
* @file main.c
* Takes argv[1] as parameter and passes
* it to the glut functions for drawing the file
* in a predefined scene.
* @brief program entry point
*/
2014-05-08 20:54:54 +00:00
#include "gl_draw.h"
2014-05-10 17:16:13 +00:00
#include "half_edge.h"
#include "print.h"
2014-05-10 17:16:13 +00:00
#include "vector.h"
2014-05-06 21:09:59 +00:00
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
2014-05-07 19:08:47 +00:00
#include <stdio.h>
#define filename __FILE__
2014-05-07 19:08:47 +00:00
/**
* Program help text.
*/
char const * const helptext = "Usage: drow-engine <file.obj>\n";
int main(int argc, char *argv[])
2014-05-06 21:09:59 +00:00
{
int windowX;
int windowY;
int screenX;
int screenY;
2014-05-09 13:03:29 +00:00
float factor = 0.80; /* percent of screen */
if (argc == 1) {
2014-05-07 19:08:47 +00:00
printf("%s", helptext);
return 1;
}
2014-05-07 19:08:47 +00:00
glutInit(&argc, argv);
screenX = glutGet(GLUT_SCREEN_WIDTH);
windowX = (screenX * factor);
screenY = glutGet(GLUT_SCREEN_HEIGHT);
windowY = (screenY * factor);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(((screenX / 2) - (windowX / 2)),
((screenY / 2) - (windowY / 2)));
glutInitWindowSize(windowX, windowY);
glutCreateWindow(filename);
2014-05-17 01:31:56 +00:00
glutSetWindowTitle("Drow engine");
init(argv[1]);
glutKeyboardFunc(keyboard);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
2014-05-17 15:24:29 +00:00
glutTimerFunc(TIMERMSECS, animate, 0);
glutMainLoop();
2014-05-07 19:08:47 +00:00
return 0;
2014-05-06 21:09:59 +00:00
}