forked from karpathy/scriptsbots
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (61 loc) · 2.26 KB
/
Copy pathmain.cpp
File metadata and controls
81 lines (61 loc) · 2.26 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
74
75
76
77
78
79
80
81
#include "GLView.h"
#include "World.h"
#include <ctime>
#include "config.h"
#ifdef LOCAL_GLUT32
#include "glut.h"
#else
#include <GL/glut.h>
#endif
#include "glui.h"
#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
GLView* GLVIEW = new GLView(0);
int main(int argc, char **argv) {
srand(time(0));
//load settings. This will be different...
//import readwrite for this?
// int window;
// GLUI *menu;
if (conf::WIDTH%conf::CZ!=0 || conf::HEIGHT%conf::CZ!=0) printf("CAREFUL! The cell size variable conf::CZ should divide evenly into both conf::WIDTH and conf::HEIGHT! It doesn't right now!");
printf("Controls:\n p= pause\n m= toggle drawing (for faster computation)\n += faster, -= slower\n delete= delete selected agent\n tab= reset world\n");
printf("Pan around by dragging with left mouse button or the arrow keys, zoom by dragging middle mouse button or the '<' and '>' keys. Right-click on the world for options\n");
printf( "GLUI version: %3.2f\n", GLUI_Master.get_version() );
World* world = new World();
GLVIEW->setWorld(world);
//GLUT SETUP
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(250,20);
glutInitWindowSize(conf::WWIDTH,conf::WHEIGHT);
GLVIEW->win1= glutCreateWindow("Scriptbots");
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_FLAT);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GLUI_Master.set_glutDisplayFunc(gl_renderScene);
GLUI_Master.set_glutIdleFunc(gl_handleIdle);
GLUI_Master.set_glutReshapeFunc(gl_changeSize);
glutKeyboardFunc(gl_processNormalKeys);
glutSpecialFunc(gl_processSpecialKeys);
glutKeyboardUpFunc(gl_processReleasedKeys);
glutMouseFunc(gl_processMouse);
glutMotionFunc(gl_processMouseActiveMotion);
glutPassiveMotionFunc(gl_processMousePassiveMotion);
//menu window.
GLVIEW->gluiCreateMenu();
//create right click context menu
GLVIEW->glCreateMenu();
if (CreateDirectory("saves", NULL)) printf("\"saves\" directory did not exist. Does now!");
if (CreateDirectory("saved_agents", NULL)) printf("\"saved_agents\" directory did not exist. Does now!");
try{
glutMainLoop();
} catch( std::bad_alloc &){
printf("Out of memory!\n");
} catch( std::bad_exception &){
printf("Severe error!\n");
}
return 0;
}