30 #include "../gldrv/gl_globals.h"
42 static string starspritetextures =
vs_config->
getVariable(
"graphics",
"far_stars_sprite_texture",
"" );
43 static float starspritesize =
45 if (starspritetextures.length() == 0) {
50 "true" ) ) ? filename :
"" );
56 "true" ) ) ? filename :
"", starspritetextures,
59 up = left = down = front = right = back = NULL;
61 SphereBackground = NULL;
65 string suffix =
".image";
66 temp = string( file )+
"_up.image";
69 temp = string( file )+
"_up.bmp";
76 temp = string( file )+
"_sphere.image";
79 temp = string( file )+
"_sphere.bmp";
82 SphereBackground =
new SphereMesh( 20, 8, 8, temp.c_str(),
"", NULL, true );
93 temp = string( file )+
"_left"+suffix;
98 temp = string( file )+
"_front"+suffix;
103 temp = string( file )+
"_right"+suffix;
108 temp = string( file )+
"_back"+suffix;
113 temp = string( file )+
"_down"+suffix;
140 if (SphereBackground)
141 delete SphereBackground;
156 if (SphereBackground)
165 for (
int i = 0;
i < 7; ++
i)
188 if (SphereBackground) {
189 SphereBackground->
DrawNow( FLT_MAX,
true );
208 static struct skybox_rendering_record
211 float vertices[4][3];
214 skybox_rendering_sequence[6] = {
221 {-1, +1, +1}, {-1, +1, -1}, {+1, +1, -1}, {+1, +1, +1}
224 {-1, +2, +1, 0}, {-1, +2, -1, 0}, {+1, +2, -1, 0}, {+1, +2, +1, 0}
230 {-1,+1, -1}, {-1, +1, +1}, {-1, -1, +1}, {-1, -1, -1}
233 {-2, +1, -1, 0}, {-2, +1, +1, 0}, {-2, -1, +1, 0}, {-2, -1, -1, 0}
239 {-1, +1, +1}, {+1, +1, +1}, {+1, -1, +1}, {-1, -1, +1}
242 {-1, +1, +2, 0}, {+1, +1, +2, 0}, {+1, -1, +2, 0}, {-1, -1, +2, 0}
248 {+1, +1, +1}, {+1, +1, -1}, {+1, -1, -1}, {+1, -1, +1}
251 {+2, +1, +1, 0}, {+2, +1, -1, 0}, {+2, -1, -1, 0}, {+2, -1, +1, 0}
257 {+1, +1, -1}, {-1, +1, -1}, {-1, -1, -1}, {+1, -1, -1}
260 {+1, +1, -2, 0}, {-1, +1, -2, 0}, {-1, -1, -2, 0}, {+1, -1, -2, 0}
266 {-1, -1, +1}, {+1, -1, +1}, {+1, -1, -1}, {-1, -1, -1}
269 {-1, -2, +1, 0}, {+1, -2, +1, 0}, {+1, -2, -1, 0}, {-1, -2, -1, 0}
279 {-1, +1, +1}, {-1, +1, -1}, {+1, +1, -1}, {+1, +1, +1}
282 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
288 {-1, +1, -1}, {-1, +1, +1}, {-1, -1, +1}, {-1, -1, -1}
291 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
297 {-1, +1, +1}, {+1, +1, +1}, {+1, -1, +1}, {-1, -1, +1}
300 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
306 {+1, +1, +1}, {+1, +1, -1}, {+1, -1, -1}, {+1, -1, +1}
309 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
315 {+1, +1, -1}, {-1, +1, -1}, {-1, -1, -1}, {+1, -1, -1}
318 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
324 {-1, -1, +1}, {+1, -1, +1}, {+1, -1, -1}, {-1, -1, -1}
327 {1, 0, 1, 0}, {0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 1}
332 skybox_rendering_sequence[0].tex = up;
333 skybox_rendering_sequence[1].tex = left;
334 skybox_rendering_sequence[2].tex = front;
335 skybox_rendering_sequence[3].tex = right;
336 skybox_rendering_sequence[4].tex = back;
337 skybox_rendering_sequence[5].tex = down;
338 for (
size_t skr = 0; skr <
sizeof (skybox_rendering_sequence)/
sizeof (skybox_rendering_sequence[0]); skr++) {
339 Texture *tex = skybox_rendering_sequence[skr].tex;
345 const int numlayers = 1;
346 const bool multitex =
true;
347 const int numpasses = 1;
348 static const float edge_fixup =
350 const float ms = 0.f, Ms = 1.f-edge_fixup/tex->
boundSizeX;
351 const float mt = 0.f, Mt = 1.f-edge_fixup/tex->
boundSizeY;
352 const float _stca[] = {-1.f, -Ms, ms, Ms, +1.f}, _ttca[] = {-1.f, -Mt, mt, Mt, +1.f};
353 const float *stca = _stca+2, *ttca = _ttca+2;
361 bool multitex = (numlayers > 1);
371 float stca[] = {ms, Ms}, ttca[] = {mt, Mt};
380 for (
int pass = 0; pass < numpasses; pass++)
389 float s1,
t1, s2, t2;
392 #define VERTEX( i ) \
393 s1 = stca[size_t(skybox_rendering_sequence[skr].tcoord[i][0])]; \
394 t1 = ttca[size_t(skybox_rendering_sequence[skr].tcoord[i][1])]; \
395 s2 = stca[size_t(skybox_rendering_sequence[skr].tcoord[i][2])]; \
396 glTexCoord3f( s1, t1, s2 ); \
397 GFXVertex3f( skybox_rendering_sequence[skr].vertices[i][0]*size, \
398 skybox_rendering_sequence[skr].vertices[i][1]*size, \
399 skybox_rendering_sequence[skr].vertices[i][2]*size );
401 #define VERTEX( i ) \
402 s1 = stca[size_t(skybox_rendering_sequence[skr].tcoord[i][0])]; \
403 t1 = ttca[size_t(skybox_rendering_sequence[skr].tcoord[i][1])]; \
404 s2 = stca[size_t(skybox_rendering_sequence[skr].tcoord[i][2])]; \
405 t2 = ttca[size_t(skybox_rendering_sequence[skr].tcoord[i][3])]; \
406 if (!multitex) GFXTexCoord2f( s1, t1 ); \
407 else GFXTexCoord4f( s1, t1, s2, t2 ); \
408 GFXVertex3f( skybox_rendering_sequence[skr].vertices[i][0]*size, \
409 skybox_rendering_sequence[skr].vertices[i][1]*size, \
410 skybox_rendering_sequence[skr].vertices[i][2]*size );
427 for (lyr = 0; lyr < numlayers; lyr++) {
451 static float background_velocity_scale =