Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some comments and stripped some more stuff out

  • Loading branch information...
commit 0c1e3f176fcc5ee40ed42c2129f5f3ce7e5b7aa8 1 parent 2f6b6a4
@bettsmatt authored
Showing with 31 additions and 181 deletions.
  1. BIN  BetaFX
  2. +31 −181 main.cpp
View
BIN  BetaFX
Binary file not shown
View
212 main.cpp
@@ -42,113 +42,29 @@ void G308_SetLight();
void mouse(int button, int state, int x, int y);
void mouseMotion (int x, int y);
void menu (int);
-G308_Point getArcBallVector (int, int);
-// Objects
-#define BOX 0
-#define BUNNY 1
-#define SPHERE 2
-#define TABLE 3
-#define TEAPOT 4
-#define TORUS 5
+void tick();
-// Materials
-#define BRICK GLuint 0
-#define CUBEMAP 1
-#define NORMAL 2
-#define WOOD 3
-
-#define PI 3.14159265358979323846
-
-/*
- * Current camera position
- */
-v3* camPos;
-v3* camLookAt;
-v3* camRot;
-
-/*
- * Keep track of camera positions
- */
-typedef struct camera {
- v3* camPos;
- v3* camLookAt;
- v3* camRot;
-} camera;
-
-
-int px;
-int py;
-bool rightMouseDown;
-bool animationMode;
-int menuID;
-
-bool arcBall;
-bool pan;
-bool zoom;
-
-char** menuItems;
G308_Geometry** geometry = NULL;
int numGeo;
-char** geometryFiles;
-v3** geometryPositions;
-
-GLuint* textureIDs;
-int numTextures;
-
void loadTexture(char*, GLuint);
-void animate ();
-int rotations;
-
-v3 spotPosition;
-v3 spotDirection;
-float spotAngle;
-
-quaternion* rot;
-
-void loadCubemap();
-
int main(int argc, char** argv) {
- if (argc < 1 ) {
- //Usage instructions for core and challenge
- printf("Usage\n");
- printf("./Ass3 priman.asf poses config\n");
+
+ if (argc < 0 ) {
+ // Print message for usage here
exit(EXIT_FAILURE);
}
-
- rot = new quaternion(1,0,0,0);
-
- /*
- * Turn all controls off
- */
- rightMouseDown = false;
- animationMode = false;
- pan = false;
- zoom = false;
- arcBall = false;
-
- camPos = (v3*) malloc(sizeof(v3));
- camLookAt = (v3*) malloc(sizeof(v3));
- camRot = (v3*) malloc(sizeof(v3));
-
- /*
- * Set initial camera positions
- */
- camPos->x = 0, camPos->y = 0, camPos->z = 20;
- camLookAt->x = 0, camLookAt->y = 0, camLookAt->z = 0;
- camRot->x = 0, camRot->y = 1, camRot->z = 0;
-
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(g_nWinWidth, g_nWinHeight);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
- g_mainWnd = glutCreateWindow("COMP308 Assignment4");
+ g_mainWnd = glutCreateWindow("BetaFX");
glutKeyboardFunc(G308_keyboardListener);
@@ -157,7 +73,7 @@ int main(int argc, char** argv) {
G308_init();
- glutIdleFunc(animate);
+ glutIdleFunc(tick);
glutMouseFunc(mouse);
glutMotionFunc(mouseMotion);
glutMainLoop();
@@ -165,19 +81,9 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}
-void animate(){
-
- if(rotations > 0){
- rotations--;
- for(int i = 0 ; i < numGeo ; i ++){
- geometry[i]->worldRot += 5;
- }
- }
-
- G308_display();
-
-}
-
+/*
+ * Load a texture and bind to an ID
+ */
void loadTexture (char* filename, GLuint id){
texInfo* t = (texInfo*) malloc(sizeof(texInfo));
@@ -196,15 +102,15 @@ void loadTexture (char* filename, GLuint id){
GL_UNSIGNED_BYTE, t->textureData);
}
-
-
/*
- * Menu options
+ * Do stuff, in the background
*/
- void menu (int i){
+void tick (){
+
}
+
// Init Light and Camera
void G308_init() {
G308_SetLight();
@@ -254,88 +160,30 @@ void G308_display() {
glutSwapBuffers();
}
-
+/*
+ * Mouse Movement
+ */
void mouseMotion (int x, int y){
}
-
-
+/*
+ * Mouse Clicks
+ */
void mouse (int button, int state, int x, int y){
}
+/*
+ * Keys
+ */
void G308_keyboardListener(unsigned char key, int x, int y) {
- if(key == 't' && rotations == 0)
- rotations = 72;
-
- // Forward
- if(key == '8'){
- spotPosition.z += 1;
- }
-
- // Back
- if(key == '2'){
- spotPosition.z -= 1;
- }
-
- // Left
- if(key == '4'){
- spotPosition.x -= 1;
- }
-
- // Right
- if(key == '6'){
- spotPosition.x += 1;
- }
-
- // Up
- if(key == '+'){
- spotPosition.y -= 1;
- }
-
- // Down
- if(key == '-'){
- spotPosition.y += 1;
- }
-
- // AngleUp
- if(key == '7'){
- spotDirection.x += 0.1;
- }
-
- // AngleDown
- if(key == '9'){
- spotDirection.x -= 0.1;
- }
-
- // AngleLeft
- if(key == '1'){
- spotDirection.z += 0.1;
- }
-
- // AngleRight
- if(key == '3'){
- spotDirection.z -= 0.1;
- }
-
- // Decrease Angle
- if(key == '/'){
- spotAngle -= 1;
- }
-
- // Increase Angle
- if(key == '*'){
- spotAngle += 1;
- }
-
- G308_SetLight();
- G308_display();
-
}
-// Reshape function
+/*
+ * Reshape function
+ */
void G308_Reshape(int w, int h) {
if (h == 0)
h = 1;
@@ -346,7 +194,9 @@ void G308_Reshape(int w, int h) {
glViewport(0, 0, g_nWinWidth, g_nWinHeight);
}
-// Set Camera Position
+/*
+ * Set Camera Position
+ */
void G308_SetCamera() {
glMatrixMode(GL_PROJECTION);
@@ -356,9 +206,9 @@ void G308_SetCamera() {
glLoadIdentity();
gluLookAt(
- camPos->x,camPos->y,camPos->z,
- camLookAt->x,camLookAt->y,camLookAt->z,
- camRot->x,camRot->y,camRot->z
+ 0, 0, 20,
+ 0, 0, 0,
+ 0, 1, 0
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.