summaryrefslogtreecommitdiffstats
path: root/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'render.c')
-rw-r--r--render.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/render.c b/render.c
new file mode 100644
index 0000000..7296055
--- /dev/null
+++ b/render.c
@@ -0,0 +1,46 @@
+#include <GL/gl.h>
+#include <math.h>
+#include <zoom/render.h>
+#include <zoom/player.h>
+#include <zoom/level.h>
+#include <zoom/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();
+}