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/>.
21 #include "Environment/Skybox.hpp"
25 extern float viewdistance;
26 extern float blurness;
27 extern int environment;
28 extern bool skyboxtexture;
33 void SkyBox::load (const std::string& ffront, const std::string& fleft, const std::string& fback,
34 const std::string& fright, const std::string& fup, const std::string& fdown)
36 front.load(ffront, true);
37 left.load(fleft, true);
38 back.load(fback, true);
39 right.load(fright, true);
41 down.load(fdown, true);
46 static float size = viewdistance / 4;
49 glGetFloatv(GL_MODELVIEW_MATRIX, M);
54 if (environment == desertenvironment) {
55 glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
56 glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
58 glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
62 glDisable(GL_TEXTURE_2D);
63 glColor3f(skyboxr * .8, skyboxg * .8, skyboxb * .8);
66 glDisable(GL_CULL_FACE);
68 glDisable(GL_LIGHTING);
70 glEnable(GL_TEXTURE_2D);
71 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
73 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
74 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
76 glNormal3f( 0.0f, 0.0f, -1);
78 glVertex3f(-size, -size, size);
80 glVertex3f( size, -size, size);
82 glVertex3f( size, size, size);
84 glVertex3f(-size, size, size);
87 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
88 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
90 glNormal3f( 0.0f, 0.0f, 1);
92 glVertex3f(-size, -size, -size);
94 glVertex3f(-size, size, -size);
96 glVertex3f( size, size, -size);
98 glVertex3f( size, -size, -size);
101 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
102 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
104 glNormal3f( 0.0f, -1.0f, 0);
106 glVertex3f(-size, size, -size);
108 glVertex3f(-size, size, size);
110 glVertex3f( size, size, size);
112 glVertex3f( size, size, -size);
115 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
116 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
118 glNormal3f( 0.0f, 1.0f, 0);
121 glVertex3f(-size, -size, -size);
123 glVertex3f( size, -size, -size);
125 glVertex3f( size, -size, size);
127 glVertex3f(-size, -size, size);
130 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
131 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
133 glNormal3f( -1.0f, 0.0f, 0);
135 glVertex3f( size, -size, -size);
137 glVertex3f( size, size, -size);
139 glVertex3f( size, size, size);
141 glVertex3f( size, -size, size);
144 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
145 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
147 glNormal3f( 1.0f, 0.0f, 0);
149 glVertex3f(-size, -size, -size);
151 glVertex3f(-size, -size, size);
153 glVertex3f(-size, size, size);
155 glVertex3f(-size, size, -size);
157 glEnable(GL_CULL_FACE);