-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (61 loc) · 1.41 KB
/
main.cpp
File metadata and controls
73 lines (61 loc) · 1.41 KB
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
67
68
69
70
71
72
73
#include <iostream>
#include <GL/gl.h>
#include <GL/glut.h>
#include "Constants.h"
#include "Utils.h"
#include "Context.h"
#include "InputFile.h"
using namespace std;
Context mContext;
void onLoad()
{
Utils::initialize_randomness(-1);
mContext.loadGraph("/home/jaox/Documentos/gtest.txt");
}
void onEnterFrame()
{
mContext.drawGraph();
}
void init()
{
Utils::initialize_randomness(-1);
glClearColor(0.0,0.0,0.0,0.0);
onLoad();
}
void displayCallback()
{
glClear(GL_COLOR_BUFFER_BIT);
onEnterFrame();
glutSwapBuffers();
}
void reShapeCallback(int w,int h)
{
// Set the viewport according to the window's dimensions
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Orthographic projection
glOrtho(0,WIDTH*SCALE,HEIGHT*SCALE,0.0,0.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void timerCallback(int)
{
glutPostRedisplay();
glutTimerFunc(1000/FPS, timerCallback,0);
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
// RGBA mode and a double buffered window
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(WIDTH,HEIGHT);
glutCreateWindow("Test");
// Registration of the display callback function
glutDisplayFunc(displayCallback);
glutReshapeFunc(reShapeCallback);
glutTimerFunc(0,timerCallback,0);
init();
glutMainLoop();
return 0;
}