2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
23 extern float viewdistance;
24 extern float blurness;
25 extern int environment;
26 extern bool skyboxtexture;
31 void SkyBox::load (const char *ffront, const char *fleft, const char *fback,
32 const char *fright, const char *fup, const char *fdown)
34 front.load(ffront, true, false);
35 left.load(fleft, true, false);
36 back.load(fback, true, false);
37 right.load(fright, true, false);
38 up.load(fup, true, false);
39 down.load(fdown, true, false);
44 static float size = viewdistance / 4;
47 glGetFloatv(GL_MODELVIEW_MATRIX, M);
53 glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
55 glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
57 glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
60 glDisable(GL_TEXTURE_2D);
61 glColor3f(skyboxr * .8, skyboxg * .8, skyboxb * .8);
64 glDisable(GL_CULL_FACE);
66 glDisable(GL_LIGHTING);
68 glEnable(GL_TEXTURE_2D);
69 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
71 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
72 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
74 glNormal3f( 0.0f, 0.0f, -1);
76 glVertex3f(-size, -size, size);
78 glVertex3f( size, -size, size);
80 glVertex3f( size, size, size);
82 glVertex3f(-size, size, size);
85 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
86 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
88 glNormal3f( 0.0f, 0.0f, 1);
90 glVertex3f(-size, -size, -size);
92 glVertex3f(-size, size, -size);
94 glVertex3f( size, size, -size);
96 glVertex3f( size, -size, -size);
99 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
100 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
102 glNormal3f( 0.0f, -1.0f, 0);
104 glVertex3f(-size, size, -size);
106 glVertex3f(-size, size, size);
108 glVertex3f( size, size, size);
110 glVertex3f( size, size, -size);
113 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
114 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
116 glNormal3f( 0.0f, 1.0f, 0);
119 glVertex3f(-size, -size, -size);
121 glVertex3f( size, -size, -size);
123 glVertex3f( size, -size, size);
125 glVertex3f(-size, -size, size);
128 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
129 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
131 glNormal3f( -1.0f, 0.0f, 0);
133 glVertex3f( size, -size, -size);
135 glVertex3f( size, size, -size);
137 glVertex3f( size, size, size);
139 glVertex3f( size, -size, size);
142 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
143 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
145 glNormal3f( 1.0f, 0.0f, 0);
147 glVertex3f(-size, -size, -size);
149 glVertex3f(-size, -size, size);
151 glVertex3f(-size, size, size);
153 glVertex3f(-size, size, -size);
155 glEnable(GL_CULL_FACE);