-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.h
103 lines (86 loc) · 2.8 KB
/
main.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// This file belongs to the OpenGL xyzw Dataviewer located at:
// https://github.com/moeeeep/opengl_dataviewer
// Copyright (C) 2011 Pascal Spörri <pascal.spoerri@gmail.com>
//
// 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, either version 3 of the License, or
// (at your option) any later version.
//
// 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/>.
#ifndef MAIN_H
#define MAIN_H
#include "opengl.h"
// QT
#include <QDebug>
#include <QString>
#include <QTime>
#include <cmath>
// Data import and export
#include "data.h"
////////////////////////////////////////////////////////
// Constants for the display
int window_height = 600;
int window_width = 800;
////////////////////////////////////////////////////////
// Definitions for OpenGL
GLuint positionsVBO;
/* This is a handle to the shader program */
GLuint shaderProgram;
GLuint vertexShader, fragmentShader;
GLchar *vertexSource, *fragmentSource;
QString vertexShaderLocation("shaders/vertex.glsl");
QString fragmentShaderLocation("shaders/fragment.glsl");
const unsigned int shaderAtribute = 0;
/////////////////////////////////////////////////////////
// Other variables
float anim = 0.0;
int pauseFlag = 0;
int frames =0;
int current_frame = 0;
QTime timer;
// mouse controls
int mouse_old_x, mouse_old_y;
int mouse_buttons = 0;
float rotate_x = -37.4, rotate_y = -231.399;
float posX = -100;
float posY = -100;
float posZ = 0.0;
float movingFactor = 10;
int waitframes = 10; // The number of frames it should wait between each execution
////////////////////////////////////////////////////////
// Declarations
float3 camera_position;
float3 camera_direction;
float3 camera_up;
// OpenGL related
//CUTBoolean initGL();
void initGL();
void createVBO( GLuint* vbo);
void deleteVBO( GLuint* vbo);
char* readShader(QString filename);
void initShaders();
// Callbacks
void display();
void keyboard( unsigned char key, int x, int y);
void mouse(int button, int state, int x, int y);
void motion(int x, int y);
// Runtime
void showFPS(float fps);
void runTimestep();
void renderSpheres(Timestep t);
void run(int argc, char** argv, QString filename);
///////////////////////////////////////////////////////
// Vector functions
void normalize3(float3* vec) {
float norm = sqrt(vec->x*vec->x + vec->y*vec->y + vec->z*vec->z);
vec->x = vec->x/norm;
vec->y = vec->y/norm;
vec->z = vec->z/norm;
}
#endif // MAIN_H