2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
24 extern float viewdistance;
25 extern float blurness;
26 extern int environment;
27 extern bool skyboxtexture;
32 void SkyBox::load (const char *ffront, const char *fleft, const char *fback,
33 const char *fright, const char *fup, const char *fdown)
35 front.load(ffront, true, false);
36 left.load(fleft, true, false);
37 back.load(fback, true, false);
38 right.load(fright, true, false);
39 up.load(fup, true, false);
40 down.load(fdown, true, false);
45 static float size = viewdistance / 4;
48 glGetFloatv(GL_MODELVIEW_MATRIX, M);
54 glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
56 glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
58 glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
61 glDisable(GL_TEXTURE_2D);
62 glColor3f(skyboxr * .8, skyboxg * .8, skyboxb * .8);
65 glDisable(GL_CULL_FACE);
67 glDisable(GL_LIGHTING);
69 glEnable(GL_TEXTURE_2D);
70 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
72 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
73 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
75 glNormal3f( 0.0f, 0.0f, -1);
77 glVertex3f(-size, -size, size);
79 glVertex3f( size, -size, size);
81 glVertex3f( size, size, size);
83 glVertex3f(-size, size, size);
86 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
87 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
89 glNormal3f( 0.0f, 0.0f, 1);
91 glVertex3f(-size, -size, -size);
93 glVertex3f(-size, size, -size);
95 glVertex3f( size, size, -size);
97 glVertex3f( size, -size, -size);
100 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
101 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
103 glNormal3f( 0.0f, -1.0f, 0);
105 glVertex3f(-size, size, -size);
107 glVertex3f(-size, size, size);
109 glVertex3f( size, size, size);
111 glVertex3f( size, size, -size);
114 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
115 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
117 glNormal3f( 0.0f, 1.0f, 0);
120 glVertex3f(-size, -size, -size);
122 glVertex3f( size, -size, -size);
124 glVertex3f( size, -size, size);
126 glVertex3f(-size, -size, size);
129 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
130 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
132 glNormal3f( -1.0f, 0.0f, 0);
134 glVertex3f( size, -size, -size);
136 glVertex3f( size, size, -size);
138 glVertex3f( size, size, size);
140 glVertex3f( size, -size, size);
143 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
144 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
146 glNormal3f( 1.0f, 0.0f, 0);
148 glVertex3f(-size, -size, -size);
150 glVertex3f(-size, -size, size);
152 glVertex3f(-size, size, size);
154 glVertex3f(-size, size, -size);
156 glEnable(GL_CULL_FACE);