summaryrefslogtreecommitdiffstats
path: root/init.c
blob: b799e7709a0bb0217ee48f2aab8846c3bdd9421b (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <zoom/init.h>
#include <zoom/texture.h>
#include <zoom/level.h>
#include <zoom/light.h>

LEVEL level;
GLuint sphere;
GLuint meditex_blue;
GLuint lightmap;


extern TEXLIST *texlist;

int InitGame() {
	LIGHT light = {LIGHT_POINT, {15.0, 15.0, 15.0}, {0.0, 0.0, 0.0}};
	COLOR ambient = {0.1, 0.1, 0.1};
	
	
	glViewport(0, 0, 640, 480);
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(50.0, 640.0/480.0, 0.1, 1000.0);
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	glShadeModel(GL_SMOOTH);
	glClearDepth(1.0);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CCW);
	
	glDisable(GL_LIGHTING);
	
	SetAmbient(ambient);
	AddLight(light);
	
	glEnable(GL_BLEND);
	
	glEnable(GL_TEXTURE_2D);
	
	meditex_blue = LoadTexture("medib.tex");
	
	lightmap = LoadTexture("lightmap.tex");
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	
	GLUquadricObj *quadric = gluNewQuadric();
	gluQuadricDrawStyle(quadric, GLU_FILL);
	gluQuadricTexture(quadric, GL_TRUE);
	
	LoadLevel("level2.lvl", &level);
	
	sphere = glGenLists(1);
	glNewList(sphere, GL_COMPILE);
	glRotatef(90, 1.0, 0.0, 0.0);
	gluSphere(quadric, 1.0, 24, 24);
	glEndList();
	
	gluDeleteQuadric(quadric);
	
	return 1;
}

void UninitGame() {
	FreeLevel(&level);
	free(texlist);
}