-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
66 lines (49 loc) · 1.15 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// main.cpp
// Includes
#include "st.h"
#include "stgl.h"
#include "stglut.h"
#include "Scene.h"
#include <iostream>
#include <stdio.h>
using namespace std;
#define WIN_WIDTH 512
#define WIN_HEIGHT 512
//globals
Scene* scene;
void DisplayCallback()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Clear the window.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
scene->Draw();
glutSwapBuffers();
}
// Reshape the window
void ReshapeCallback(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, w, 0, h, -1., 1.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char** argv)
{
scene = new Scene(argv[1]);
// Initialize GLUT.
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(20, 20);
glutInitWindowSize(
WIN_WIDTH, WIN_HEIGHT);
glutCreateWindow("CS148 Assignment 6");
// Register GLUT callbacks and enter main loop.
glutDisplayFunc(DisplayCallback);
glutReshapeFunc(ReshapeCallback);
glutMainLoop();
return 0;
}