typedef struct suffixinfo_s
{
- char *suffix;
+ const char *suffix;
qboolean flipx, flipy, flipdiagonal;
}
suffixinfo_t;
-static suffixinfo_t suffix[3][6] =
+static const suffixinfo_t suffix[3][6] =
{
{
{"px", false, false, false},
skyrendersphere = false;
skyrenderbox = false;
skyrendermasked = false;
- if (r_sky.integer && !r_refdef.fogenabled)
+ if (r_sky.integer && !(r_refdef.fogenabled && r_refdef.fog_alpha < 1))
{
if (skyboxside[0] || skyboxside[1] || skyboxside[2] || skyboxside[3] || skyboxside[4] || skyboxside[5])
skyrenderbox = true;
int i, j, success;
int indices[4] = {0,1,2,3};
char name[MAX_INPUTLINE];
- unsigned char *image_rgba;
+ unsigned char *image_buffer;
unsigned char *temp;
R_UnloadSkyBox();
success = 0;
for (i=0; i<6; i++)
{
- if (dpsnprintf(name, sizeof(name), "%s_%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+ if (dpsnprintf(name, sizeof(name), "%s_%s", skyname, suffix[j][i].suffix) < 0 || !(image_buffer = loadimagepixelsbgra(name, false, false)))
{
- if (dpsnprintf(name, sizeof(name), "%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+ if (dpsnprintf(name, sizeof(name), "%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_buffer = loadimagepixelsbgra(name, false, false)))
{
- if (dpsnprintf(name, sizeof(name), "env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+ if (dpsnprintf(name, sizeof(name), "env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_buffer = loadimagepixelsbgra(name, false, false)))
{
- if (dpsnprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+ if (dpsnprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_buffer = loadimagepixelsbgra(name, false, false)))
continue;
}
}
}
temp = (unsigned char *)Mem_Alloc(tempmempool, image_width*image_height*4);
- Image_CopyMux (temp, image_rgba, image_width, image_height, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, indices);
- skyboxside[i] = R_LoadTexture2D(skytexturepool, va("skyboxside%d", i), image_width, image_height, temp, TEXTYPE_RGBA, TEXF_CLAMP | TEXF_PRECACHE, NULL);
- Mem_Free(image_rgba);
+ Image_CopyMux (temp, image_buffer, image_width, image_height, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, indices);
+ skyboxside[i] = R_LoadTexture2D(skytexturepool, va("skyboxside%d", i), image_width, image_height, temp, TEXTYPE_BGRA, TEXF_CLAMP | TEXF_PRECACHE | (gl_texturecompression_sky.integer ? TEXF_COMPRESS : 0), NULL);
+ Mem_Free(image_buffer);
Mem_Free(temp);
success++;
}
}
}
-float skyboxvertex3f[6*4*3] =
+static const float skyboxvertex3f[6*4*3] =
{
// skyside[0]
16, -16, 16,
16, 16, -16
};
-float skyboxtexcoord2f[6*4*2] =
+static const float skyboxtexcoord2f[6*4*2] =
{
// skyside[0]
0, 1,
0, 0
};
-int skyboxelements[6*2*3] =
+static const int skyboxelements[6*2*3] =
{
// skyside[3]
0, 1, 2,
// FIXME: fixed function path can't properly handle r_view.colorscale > 1
GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_CullFace(GL_NONE);
GL_DepthMask(false);
+ GL_DepthRange(0, 1);
+ GL_PolygonOffset(0, 0);
GL_DepthTest(false); // don't modify or read zbuffer
R_Mesh_VertexPointer(skyboxvertex3f, 0, 0);
R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_TexBind(0, R_GetTexture(skyboxside[i]));
R_Mesh_Draw(0, 6*4, 2, skyboxelements + i * 6, 0, 0);
}
+
+ if(r_refdef.fogenabled)
+ {
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GL_Color(r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], r_refdef.fog_alpha);
+ for (i = 0;i < 6;i++)
+ {
+ R_Mesh_TexBind(0, 0);
+ R_Mesh_Draw(0, 6*4, 2, skyboxelements + i * 6, 0, 0);
+ }
+ }
+
GL_LockArrays(0, 0);
}
// FIXME: fixed function path can't properly handle r_view.colorscale > 1
GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_CullFace(GL_NONE);
GL_DepthMask(true);
+ GL_DepthRange(0, 1);
+ GL_PolygonOffset(0, 0);
GL_DepthTest(false); // don't modify or read zbuffer
R_Mesh_VertexPointer(skysphere_vertex3f, 0, 0);
R_Mesh_ColorPointer(NULL, 0, 0);
GL_LockArrays(0, skysphere_numverts);
R_Mesh_Draw(0, skysphere_numverts, skysphere_numtriangles, skysphere_element3i, 0, 0);
GL_LockArrays(0, 0);
+ R_Mesh_TexBind(1, 0);
}
else
{
R_Mesh_Draw(0, skysphere_numverts, skysphere_numtriangles, skysphere_element3i, 0, 0);
GL_LockArrays(0, 0);
}
+
+ if(r_refdef.fogenabled)
+ {
+ R_Mesh_TexBind(0, 0);
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GL_Color(r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], r_refdef.fog_alpha);
+ GL_LockArrays(0, skysphere_numverts);
+ R_Mesh_Draw(0, skysphere_numverts, skysphere_numtriangles, skysphere_element3i, 0, 0);
+ GL_LockArrays(0, 0);
+ }
}
void R_Sky(void)
//GL_Clear(GL_DEPTH_BUFFER_BIT);
}
*/
+ GL_DepthRange(0, 1);
GL_DepthTest(true);
GL_DepthMask(true);
}