#include "quakedef.h"
-extern model_t *loadmodel;
-
int skytexturenum;
-int solidskytexture;
-int alphaskytexture;
+rtexture_t *solidskytexture;
+rtexture_t *alphaskytexture;
float speedscale; // for top sky and bottom sky
msurface_t *warpface;
-extern cvar_t gl_subdivide_size;
-
void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
{
int i, j;
return;
}
- poly = Hunk_Alloc (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float));
+ poly = Hunk_AllocName (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float), "surfaces");
poly->next = warpface->polys;
warpface->polys = poly;
poly->numverts = numverts;
-extern qboolean lighthalf;
-
-#define SKY_TEX 4000
+rtexture_t *skyboxside[6];
char skyname[256];
// LordHavoc: moved LoadTGA and LoadPCX to gl_draw.c
-extern int image_width, image_height;
-
-byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight);
/*
==================
R_LoadSkyBox
void R_LoadSkyBox (void)
{
int i;
- char name[64];
+ char name[1024];
byte* image_rgba;
+ if (strlen(skyname) >= 1000)
+ {
+ Con_Printf ("sky name too long (%i, max is 1000)\n", strlen(skyname));
+ return;
+ }
for (i=0 ; i<6 ; i++)
{
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + i);
sprintf (name, "env/%s%s", skyname, suf[i]);
- if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0)))
+ if (!(image_rgba = loadimagepixels(name, false, 0, 0)))
{
sprintf (name, "gfx/env/%s%s", skyname, suf[i]);
- if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0)))
+ if (!(image_rgba = loadimagepixels(name, false, 0, 0)))
{
Con_Printf ("Couldn't load %s\n", name);
continue;
}
}
- glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_rgba);
- free (image_rgba);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ skyboxside[i] = R_LoadTexture(va("skyboxside%d", i), image_width, image_height, image_rgba, TEXF_RGBA | TEXF_PRECACHE);
+ qfree(image_rgba);
}
}
}
}
-extern cvar_t r_skyboxsize;
-
#define R_SkyBoxPolyVec(s,t,x,y,z) \
glTexCoord2f((s) * (254.0f/256.0f) + (1.0f/256.0f), (t) * (254.0f/256.0f) + (1.0f/256.0f));\
- glVertex3f((x) * 1024.0 + r_refdef.vieworg[0], (y) * 1024.0 + r_refdef.vieworg[1], (z) * 1024.0 + r_refdef.vieworg[2]);
+ glVertex3f((x) * 1024.0 + r_origin[0], (y) * 1024.0 + r_origin[1], (z) * 1024.0 + r_origin[2]);
-void R_SkyBox()
+void R_SkyBox(void)
{
glDisable (GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 3); // front
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[3])); // front
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, 1, -1, 1);
R_SkyBoxPolyVec(1, 1, 1, -1, -1);
R_SkyBoxPolyVec(0, 1, 1, 1, -1);
R_SkyBoxPolyVec(0, 0, 1, 1, 1);
glEnd();
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 1); // back
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[1])); // back
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, -1, 1, 1);
R_SkyBoxPolyVec(1, 1, -1, 1, -1);
R_SkyBoxPolyVec(0, 1, -1, -1, -1);
R_SkyBoxPolyVec(0, 0, -1, -1, 1);
glEnd();
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 0); // right
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[0])); // right
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, 1, 1, 1);
R_SkyBoxPolyVec(1, 1, 1, 1, -1);
R_SkyBoxPolyVec(0, 1, -1, 1, -1);
R_SkyBoxPolyVec(0, 0, -1, 1, 1);
glEnd();
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 2); // left
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[2])); // left
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, -1, -1, 1);
R_SkyBoxPolyVec(1, 1, -1, -1, -1);
R_SkyBoxPolyVec(0, 1, 1, -1, -1);
R_SkyBoxPolyVec(0, 0, 1, -1, 1);
glEnd();
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 4); // up
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[4])); // up
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, 1, -1, 1);
R_SkyBoxPolyVec(1, 1, 1, 1, 1);
R_SkyBoxPolyVec(0, 1, -1, 1, 1);
R_SkyBoxPolyVec(0, 0, -1, -1, 1);
glEnd();
- glBindTexture(GL_TEXTURE_2D, SKY_TEX + 5); // down
+ glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[5])); // down
glBegin(GL_QUADS);
R_SkyBoxPolyVec(1, 0, 1, 1, -1);
R_SkyBoxPolyVec(1, 1, 1, -1, -1);
glEnd();
}
+/*
float skydomeouter[33*33*3];
float skydomeinner[33*33*3];
unsigned short skydomeindices[32*66];
}
}
-extern cvar_t gl_vertexarrays;
void skydome(float *source, float s, float texscale)
{
vec_t vert[33*33][3], tex[33*33][2], *v, *t;
{
*t++ = source[0] * texscale + s;
*t++ = source[1] * texscale + s;
- *v++ = *source++ + r_refdef.vieworg[0];
- *v++ = *source++ + r_refdef.vieworg[1];
- *v++ = *source++ + r_refdef.vieworg[2];
- }
- if (gl_vertexarrays.value)
- {
- qglTexCoordPointer(2, GL_FLOAT, 0, tex);
- qglVertexPointer(3, GL_FLOAT, 0, vert);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
-// qglInterleavedArrays(GL_T2F_V3F, 0, vert);
- for (i = 0;i < (32*66);i+=66)
- qglDrawElements(GL_TRIANGLE_STRIP, 66, GL_UNSIGNED_SHORT, &skydomeindices[i]);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- else
- {
- index = skydomeindices;
- for (i = 0;i < (32*66);i+=66)
- {
- glBegin(GL_TRIANGLE_STRIP);
- for (j = 0;j < 66;j++)
- {
- // Matrox G200 (and possibly G400) drivers don't support TexCoord2fv...
- glTexCoord2f(tex[*index][0], tex[*index][1]);
- glVertex3fv(&vert[*index++][0]);
- }
- glEnd();
- }
+ *v++ = *source++ + r_origin[0];
+ *v++ = *source++ + r_origin[1];
+ *v++ = *source++ + r_origin[2];
}
+ glTexCoordPointer(2, GL_FLOAT, 0, tex);
+ glVertexPointer(3, GL_FLOAT, 0, vert);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+// glInterleavedArrays(GL_T2F_V3F, 0, vert);
+ for (i = 0;i < (32*66);i+=66)
+ glDrawElements(GL_TRIANGLE_STRIP, 66, GL_UNSIGNED_SHORT, &skydomeindices[i]);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
-void R_SkyDome()
+void R_SkyDome(void)
{
glDisable (GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
skydomecalc(skydomeouter, 1024, 1024, 256);
skydomecalc(skydomeinner, 512, 512, 128);
}
- speedscale = realtime*8.0/256.0;
+ speedscale = cl.time*8.0/256.0;
speedscale -= (int)speedscale;
skydome(skydomeouter, speedscale, 1.0 / 256.0);
glEnable (GL_BLEND);
glBindTexture(GL_TEXTURE_2D, alphaskytexture); // lower clouds
- speedscale = realtime*8.0/128.0;
+ speedscale = cl.time*8.0/128.0;
speedscale -= (int)speedscale;
skydome(skydomeinner, speedscale, 1.0 / 128.0);
glDisable (GL_BLEND);
}
+*/
-void R_Sky()
+void R_Sky(void)
{
+ if (!r_render.value)
+ return;
+ if (!skyname[0])
+ return;
glDisable(GL_DEPTH_TEST);
glDepthMask(0);
- if (skyname[0])
+// if (skyname[0])
R_SkyBox();
- else // classic quake sky
- R_SkyDome();
+// else // classic quake sky
+// R_SkyDome();
glDepthMask(1);
glEnable (GL_DEPTH_TEST);
glColor3f (1,1,1);
A sky texture is 256*128, with the right side being a masked overlay
==============
*/
-// LordHavoc: changed this for GLQuake
-void R_InitSky (byte *src, int bytesperpixel) //texture_t *mt)
+void R_InitSky (byte *src, int bytesperpixel)
{
int i, j, p;
-// byte *src;
unsigned trans[128*128];
unsigned transpix;
int r, g, b;
unsigned *rgba;
- extern int skytexturenum;
-
-// src = (byte *)mt + mt->offsets[0];
if (bytesperpixel == 4)
{
((byte *)&transpix)[3] = 0;
}
- if (!solidskytexture)
- solidskytexture = texture_extension_number++;
- if (!isDedicated)
- {
- glBindTexture(GL_TEXTURE_2D, solidskytexture );
- glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
-
+ solidskytexture = R_LoadTexture ("sky_solidtexture", 128, 128, (byte *) trans, TEXF_RGBA | TEXF_PRECACHE);
if (bytesperpixel == 4)
{
}
}
- if (!alphaskytexture)
- alphaskytexture = texture_extension_number++;
- if (!isDedicated)
- {
- glBindTexture(GL_TEXTURE_2D, alphaskytexture);
- glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
+ alphaskytexture = R_LoadTexture ("sky_alphatexture", 128, 128, (byte *) trans, TEXF_ALPHA | TEXF_RGBA | TEXF_PRECACHE);
}