summaryrefslogtreecommitdiff
path: root/example/main.cpp
blob: d71322b313cec9ad3b78f2a4dcb278f557b675dc (plain)
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
#include<stdio.h>
#include<time.h>
#include "glgfx.h"
#include "gfx.h"
#include "main.h"
#include "gui.h"
int loop;
int rot = 0;
float dir = 0.0f;
int main (int argc, char * argv[]) {
	//inits program
	initgfx(400,600, "rotating cube");
	initglgfx();
	setlight(0,10,10);
	setcam(0.0,0.0,1.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
	//main loop, this is defined in main.h and global
	loop = 1;
	while(loop) {
		cleargfx();
		clearglgfx();	
		//polls events, which are in a buffer
		//returns 1 if there is event in buffer
		//returns 0 if buffer is empty
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			switch (event.type) {
				//loop is a global defined in main.h
				case SDL_QUIT:
					printf("loop = 0;\n");
					loop = 0;
				break;
				
			}
		}
		dir += 0.05;
		if (dir > 360.0f) {
			rot++;
			rot = rot % 3;
			dir = 0.0f;
		}
		switch (rot) {
			case 0:
				drawmodel(0.0f, 0.0f, -2.0f, dir, 0.0f, 0.0f);
				drawmodel(0.5f, 3.0f, -10.0f, dir, 0.0f, 0.0f);
			break;
			case 1:
				drawmodel(0.0f, 0.0f, -2.0f, 0.0f, dir, 0.0f);
				drawmodel(0.5f, 3.0f, -10.0f, 0.0f, dir, 0.0f);
			break;
			case 2:
				drawmodel(0.0f, 0.0f, -2.0f, 0.0f, 0.0f, dir);
				drawmodel(0.5f, 3.0f, -10.0f, 0.0f, 0.0f, dir);
			break;
		}
		updategfx();
	}
	quitgfx();
	return 0;
}