#include <assert.h>
#include <GL/glut.h>
#include <cgmath/cgmath.h>
+#include "mesh.h"
enum {
KEY_F1 = GLUT_KEY_F1 | 0x100,
static long start_time;
static float cam_theta, cam_phi;
-static cgm_vec3 cam_pos;
+static cgm_vec3 cam_pos = {0, -1.6, 0};
static float pxform[16];
static int mouse_x, mouse_y;
{' ', 0}
};
+static struct scenefile scn;
+
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
+ if(load_scenefile(&scn, "data/testlvl.obj") == -1) {
+ return -1;
+ }
+
start_time = glutGet(GLUT_ELAPSED_TIME);
return 0;
}
static void cleanup(void)
{
+ destroy_scenefile(&scn);
}
-#define WALK_SPEED 1.0f
+#define WALK_SPEED 3.0f
static void update(void)
{
static unsigned int prev_upd;
static void display(void)
{
+ struct mesh *mesh;
+
update();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(pxform);
- glFrontFace(GL_CW);
- glutSolidTeapot(1.0);
- glFrontFace(GL_CCW);
+ mesh = scn.meshlist;
+ while(mesh) {
+ float col[4];
+ col[0] = mesh->mtl.color.x;
+ col[1] = mesh->mtl.color.y;
+ col[2] = mesh->mtl.color.z;
+ col[3] = 1.0f;
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col);
+
+ draw_mesh(mesh);
+ mesh = mesh->next;
+ }
glutSwapBuffers();
assert(glGetError() == GL_NO_ERROR);