-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmain.h
More file actions
146 lines (120 loc) · 3.19 KB
/
main.h
File metadata and controls
146 lines (120 loc) · 3.19 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// CIS565 CUDA Rasterizer: A simple rasterization pipeline for Patrick Cozzi's CIS565: GPU Computing at the University of Pennsylvania
// Written by Yining Karl Li, Copyright (c) 2012 University of Pennsylvania
#ifndef MAIN_H
#define MAIN_H
#ifdef __APPLE__
#include <GL/glfw.h>
#else
#include <GL/glew.h>
#include <GL/glut.h>
#endif
#include <stdlib.h>
#include <cuda_runtime.h>
#include <cuda_gl_interop.h>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <time.h>
#include "glslUtility.h"
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "rasterizeKernels.h"
#include "utilities.h"
#include "ObjCore/objloader.h"
#if CUDA_VERSION >= 5000
#include <helper_cuda.h>
#include <helper_cuda_gl.h>
#define compat_getMaxGflopsDeviceId() gpuGetMaxGflopsDeviceId()
#else
#include <cutil_inline.h>
#include <cutil_gl_inline.h>
#define compat_getMaxGflopsDeviceId() cutGetMaxGflopsDeviceId()
#endif
using namespace std;
#define X_MAX 8
#define Y_MAX 9
#define Z_MAX 10
#define X_MIN 16
#define Y_MIN 17
#define Z_MIN 18
//-------------------------------
//------------GL STUFF-----------
//-------------------------------
int frame;
int fpstracker;
double seconds;
int fps = 0;
GLuint positionLocation = 0;
GLuint texcoordsLocation = 1;
const char *attributeLocations[] = { "Position", "Tex" };
GLuint pbo = (GLuint)NULL;
GLuint displayImage;
uchar4 *dptr;
glm::vec3 camera_eye = glm::vec3(0,0,4);
glm::vec3 camera_towards = glm::vec3(0,0,1);
glm::vec3 camera_up = glm::vec3(0,-1,0);
static double camera_yfov = 0.75;
float camera_zoom;
obj* mesh;
float mesh_size;
glm::vec3 mesh_center;
float* vbo;
int vbosize;
float* cbo;
int cbosize;
int* ibo;
int ibosize;
float* nbo;
int nbosize;
//-------------------------------
//----------CUDA STUFF-----------
//-------------------------------
int width=800; int height=800;
//-------------------------------
//----------GLUT STUFF-----------
//-------------------------------
static int GLUTwindow = 0;
static int GLUTwindow_height = height;
static int GLUTwindow_width = width;
static int GLUTmouse[2] = { 0, 0 };
static int GLUTbutton[3] = { 0, 0, 0 };
static int GLUTmodifiers = 0;
//-------------------------------
//-------------MAIN--------------
//-------------------------------
int main(int argc, char** argv);
//-------------------------------
//---------RUNTIME STUFF---------
//-------------------------------
void runCuda();
#ifdef __APPLE__
void display();
#else
void display();
void keyboard(unsigned char key, int x, int y);
#endif
//-------------------------------
//----------SETUP STUFF----------
//-------------------------------
#ifdef __APPLE__
void init();
#else
void init(int argc, char* argv[]);
#endif
void initPBO(GLuint* pbo);
void initCuda();
void initTextures();
void initVAO();
void initCamera();
void GLUTMouse(int button, int state, int x, int y);
void GLUTMotion(int x, int y);
GLuint initShader(const char *vertexShaderPath, const char *fragmentShaderPath);
//-------------------------------
//---------CLEANUP STUFF---------
//-------------------------------
void cleanupCuda();
void deletePBO(GLuint* pbo);
void deleteTexture(GLuint* tex);
void shut_down(int return_code);
#endif