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
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program 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.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 extern float viewdistance;
26 extern float blurness;
27 extern int environment;
28 extern bool skyboxtexture;
34 SkyBox::load (const char *ffront, const char *fleft, const char *fback,
35 const char *fright, const char *fup, const char *fdown)
37 front.load(ffront, true, false);
38 left.load(fleft, true, false);
39 back.load(fback, true, false);
40 right.load(fright, true, false);
41 up.load(fup, true, false);
42 down.load(fdown, true, false);
47 static float size = viewdistance / 4;
50 glGetFloatv(GL_MODELVIEW_MATRIX, M);
56 glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
58 glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
60 glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
63 glDisable(GL_TEXTURE_2D);
64 glColor3f(skyboxr * .8, skyboxg * .8, skyboxb * .8);
67 glDisable(GL_CULL_FACE);
69 glDisable(GL_LIGHTING);
71 glEnable(GL_TEXTURE_2D);
72 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
74 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
75 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
77 glNormal3f( 0.0f, 0.0f, -1);
79 glVertex3f(-size, -size, size);
81 glVertex3f( size, -size, size);
83 glVertex3f( size, size, size);
85 glVertex3f(-size, size, size);
88 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
89 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
91 glNormal3f( 0.0f, 0.0f, 1);
93 glVertex3f(-size, -size, -size);
95 glVertex3f(-size, size, -size);
97 glVertex3f( size, size, -size);
99 glVertex3f( size, -size, -size);
102 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
103 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
105 glNormal3f( 0.0f, -1.0f, 0);
107 glVertex3f(-size, size, -size);
109 glVertex3f(-size, size, size);
111 glVertex3f( size, size, size);
113 glVertex3f( size, size, -size);
116 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
117 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
119 glNormal3f( 0.0f, 1.0f, 0);
122 glVertex3f(-size, -size, -size);
124 glVertex3f( size, -size, -size);
126 glVertex3f( size, -size, size);
128 glVertex3f(-size, -size, size);
131 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
132 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
134 glNormal3f( -1.0f, 0.0f, 0);
136 glVertex3f( size, -size, -size);
138 glVertex3f( size, size, -size);
140 glVertex3f( size, size, size);
142 glVertex3f( size, -size, size);
145 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
146 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
148 glNormal3f( 1.0f, 0.0f, 0);
150 glVertex3f(-size, -size, -size);
152 glVertex3f(-size, -size, size);
154 glVertex3f(-size, size, size);
156 glVertex3f(-size, size, -size);
158 glEnable(GL_CULL_FACE);