summaryrefslogtreecommitdiffstats
path: root/render.c
blob: 5816090aaeddb7d75f903b990aaa96f223d8c1c2 (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
#include <GL/gl.h>
#include <math.h>
#include <zoom/render.h>
#include <zoom/player.h>
#include <zoom/level.h>
#include <neofx/math.h>

extern PLAYER player;
extern LEVEL level;
extern GLuint sphere;

void Render() {
	GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat light_emission[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat std_emission[] = {0.0, 0.0, 0.0, 1.0};
	MATRIX rotate = {
		player.rotycos, 0.0, -player.rotysin, 0.0,
		0.0, 1.0, 0.0, 0.0,
		player.rotysin, 0.0, player.rotycos, 0.0,
		0.0, 0.0, 0.0, 1.0
	};
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	
	glRotatef(player.rotx, 1.0, 0.0, 0.0);
	glMultMatrixf(rotate.f);
	
	
	glTranslatef(-player.pos.x, -player.pos.y, -player.pos.z);
	
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
	glPushMatrix();
	glDisable(GL_TEXTURE_2D);
	glMaterialfv(GL_FRONT, GL_EMISSION, light_emission);
	glTranslatef(light_position[0], light_position[1], light_position[2]);
	glScalef(0.1, 0.1, 0.1);
	glCallList(sphere);
	glMaterialfv(GL_FRONT, GL_EMISSION, std_emission);
	glEnable(GL_TEXTURE_2D);
	glPopMatrix();
	
	DrawRoom(&level, player.room);
	
	glFlush();
}