some more const correctness (in gl_sky_clip.c) and make the sky poly debug

drawing avialable via the gl_sky_debug cvar.
This commit is contained in:
Bill Currie 2002-01-03 18:18:45 +00:00
parent 461f63c7ff
commit 9312681182
5 changed files with 86 additions and 71 deletions

View file

@ -65,7 +65,7 @@ QFGL_DONT_NEED (void, glColor3i, (GLint red, GLint green, GLint blue));
QFGL_DONT_NEED (void, glColor3iv, (const GLint * v));
QFGL_DONT_NEED (void, glColor3s, (GLshort red, GLshort green, GLshort blue));
QFGL_DONT_NEED (void, glColor3sv, (const GLshort * v));
QFGL_DONT_NEED (void, glColor3ub, (GLubyte red, GLubyte green, GLubyte blue));
QFGL_NEED (void, glColor3ub, (GLubyte red, GLubyte green, GLubyte blue));
QFGL_NEED (void, glColor3ubv, (const GLubyte * v));
QFGL_DONT_NEED (void, glColor3ui, (GLuint red, GLuint green, GLuint blue));
QFGL_DONT_NEED (void, glColor3uiv, (const GLuint * v));

View file

@ -35,8 +35,9 @@
#define SKY_TEX 2000 // Quake 2 environment sky
extern qboolean skyloaded;
extern vec5_t skyvec[6][4];
void R_DrawSky (void);
void R_DrawSkyChain (msurface_t *s);
void R_DrawSkyChain (const msurface_t *s);
#endif // __QF_GL_sky_h

View file

@ -34,6 +34,7 @@ extern struct cvar_s *gl_picmip;
extern struct cvar_s *gl_playermip;
extern struct cvar_s *gl_reporttjunctions;
extern struct cvar_s *gl_sky_clip;
extern struct cvar_s *gl_sky_debug;
extern struct cvar_s *gl_sky_divide;
extern struct cvar_s *gl_skymultipass;
extern struct cvar_s *gl_texsort;

View file

@ -171,7 +171,8 @@ determine_face (vec3_t v)
v.n
*/
static int
find_intersect (int face1, vec3_t x1, int face2, vec3_t x2, vec3_t y)
find_intersect (int face1, const vec3_t x1, int face2, const vec3_t x2,
vec3_t y)
{
int axis;
vec3_t n; // normal to the plane formed by the
@ -225,7 +226,7 @@ find_cube_vertex (int face1, int face2, int face3, vec3_t v)
(wish I could find a cleaner way of calculating s and t).
*/
static void
set_vertex (struct box_def *box, int face, int ind, vec3_t v)
set_vertex (struct box_def *box, int face, int ind, const vec3_t v)
{
VectorCopy (v, box->face[face].poly.verts[ind]);
VectorAdd (v, r_refdef.vieworg, box->face[face].poly.verts[ind]);
@ -263,7 +264,7 @@ set_vertex (struct box_def *box, int face, int ind, vec3_t v)
append a vertex to the poly vertex list.
*/
static void
add_vertex (struct box_def *box, int face, vec3_t v)
add_vertex (struct box_def *box, int face, const vec3_t v)
{
set_vertex (box, face, box->face[face].poly.numverts++, v);
}
@ -329,8 +330,8 @@ insert_cube_vertices (struct box_def *box, struct visit_def visit, int count,
enter/leave purposes).
*/
static void
cross_cube_edge (struct box_def *box, int face1, vec3_t v1, int face2,
vec3_t v2)
cross_cube_edge (struct box_def *box, int face1, const vec3_t v1, int face2,
const vec3_t v2)
{
int axis;
int face = -1;
@ -569,7 +570,7 @@ process_corners (struct box_def *box)
draws all faces of the cube with 3 or more vertices.
*/
static void
render_box (struct box_def *box)
render_box (const struct box_def *box)
{
int i, j;
@ -587,7 +588,7 @@ render_box (struct box_def *box)
}
void
R_DrawSkyBoxPoly (glpoly_t *poly)
R_DrawSkyBoxPoly (const glpoly_t *poly)
{
int i;
struct box_def box;
@ -645,7 +646,7 @@ R_DrawSkyBoxPoly (glpoly_t *poly)
}
void
EmitSkyPolys (float speedscale, msurface_t *fa)
EmitSkyPolys (float speedscale, const msurface_t *fa)
{
float length, s, t;
float *v;
@ -676,7 +677,7 @@ EmitSkyPolys (float speedscale, msurface_t *fa)
}
static inline void
draw_poly (glpoly_t *poly)
draw_poly (const glpoly_t *poly)
{
int i;
@ -688,9 +689,9 @@ draw_poly (glpoly_t *poly)
}
static void
draw_black_sky_polys (msurface_t *sky_chain)
draw_black_sky_polys (const msurface_t *sky_chain)
{
msurface_t *sc = sky_chain;
const msurface_t *sc = sky_chain;
qfglDisable (GL_BLEND);
qfglDisable (GL_TEXTURE_2D);
@ -710,9 +711,9 @@ draw_black_sky_polys (msurface_t *sky_chain)
}
static void
draw_skybox_sky_polys (msurface_t *sky_chain)
draw_skybox_sky_polys (const msurface_t *sky_chain)
{
msurface_t *sc = sky_chain;
const msurface_t *sc = sky_chain;
qfglDepthMask (GL_FALSE);
qfglDisable (GL_DEPTH_TEST);
@ -730,16 +731,16 @@ draw_skybox_sky_polys (msurface_t *sky_chain)
}
static void
draw_skydome_sky_polys (msurface_t *sky_chain)
draw_skydome_sky_polys (const msurface_t *sky_chain)
{
// this function is not yet implemented so just draw black
draw_black_sky_polys (sky_chain);
}
static void
draw_id_sky_polys (msurface_t *sky_chain)
draw_id_sky_polys (const msurface_t *sky_chain)
{
msurface_t *sc = sky_chain;
const msurface_t *sc = sky_chain;
float speedscale;
speedscale = r_realtime / 16;
@ -766,9 +767,9 @@ draw_id_sky_polys (msurface_t *sky_chain)
}
static void
draw_z_sky_polys (msurface_t *sky_chain)
draw_z_sky_polys (const msurface_t *sky_chain)
{
msurface_t *sc = sky_chain;
const msurface_t *sc = sky_chain;
qfglColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
qfglDisable (GL_BLEND);
@ -790,7 +791,7 @@ draw_z_sky_polys (msurface_t *sky_chain)
}
void
R_DrawSkyChain (msurface_t *sky_chain)
R_DrawSkyChain (const msurface_t *sky_chain)
{
if (gl_sky_clip->int_val > 2) {
draw_black_sky_polys (sky_chain);
@ -808,64 +809,73 @@ R_DrawSkyChain (msurface_t *sky_chain)
return; // XXX not properly implemented
}
draw_z_sky_polys (sky_chain);
#if 0
qfglDisable (GL_TEXTURE_2D);
sc = sky_chain;
qfglColor3ubv (255, 255, 255);
while (sc) {
glpoly_t *p = sc->polys;
while (p) {
int i;
if (gl_sky_debug->int_val) {
const msurface_t *sc;
qfglBegin (GL_LINE_LOOP);
for (i = 0; i < p->numverts; i++) {
qfglVertex3fv (p->verts[i]);
qfglDisable (GL_TEXTURE_2D);
if (gl_sky_debug->int_val & 1) {
sc = sky_chain;
qfglColor3ub (255, 255, 255);
while (sc) {
glpoly_t *p = sc->polys;
while (p) {
int i;
qfglBegin (GL_LINE_LOOP);
for (i = 0; i < p->numverts; i++) {
qfglVertex3fv (p->verts[i]);
}
qfglEnd ();
p = p->next;
}
sc = sc->texturechain;
}
qfglEnd ();
p = p->next;
}
sc = sc->texturechain;
}
sc = sky_chain;
qfglColor3ubv (0, 255, 0);
qfglBegin (GL_POINTS);
while (sc) {
glpoly_t *p = sc->polys;
if (gl_sky_debug->int_val & 2) {
sc = sky_chain;
qfglColor3ub (0, 255, 0);
qfglBegin (GL_POINTS);
while (sc) {
glpoly_t *p = sc->polys;
while (p) {
int i;
vec3_t x, c = { 0, 0, 0 };
while (p) {
int i;
vec3_t x, c = { 0, 0, 0 };
for (i = 0; i < p->numverts; i++) {
VectorSubtract (p->verts[i], r_refdef.vieworg, x);
VectorAdd (x, c, c);
}
VectorScale (c, 1.0 / p->numverts, c);
VectorAdd (c, r_refdef.vieworg, c);
qfglVertex3fv (c);
p = p->next;
}
sc = sc->texturechain;
}
qfglEnd ();
if (skyloaded) {
int i, j;
qfglColor3ubv (255, 0, 0);
for (i = 0; i < 6; i++) {
vec3_t v;
qfglBegin (GL_LINE_LOOP);
for (j = 0; j < 4; j++) {
VectorScale (&skyvec[i][j][2], 1.0 / 128.0, v);
VectorAdd (v, r_refdef.vieworg, v);
qfglVertex3fv (v);
for (i = 0; i < p->numverts; i++) {
VectorSubtract (p->verts[i], r_refdef.vieworg, x);
VectorAdd (x, c, c);
}
VectorScale (c, 1.0 / p->numverts, c);
VectorAdd (c, r_refdef.vieworg, c);
qfglVertex3fv (c);
p = p->next;
}
sc = sc->texturechain;
}
qfglEnd ();
}
if (gl_sky_debug->int_val & 4) {
if (skyloaded) {
int i, j;
qfglColor3ub (255, 0, 0);
for (i = 0; i < 6; i++) {
vec3_t v;
qfglBegin (GL_LINE_LOOP);
for (j = 0; j < 4; j++) {
VectorScale (&skyvec[i][j][2], 1.0 / 128.0, v);
VectorAdd (v, r_refdef.vieworg, v);
qfglVertex3fv (v);
}
qfglEnd ();
}
}
}
qfglColor3ubv (color_white);
qfglEnable (GL_TEXTURE_2D);
}
qfglColor3ubv (color_white);
qfglEnable (GL_TEXTURE_2D);
#endif
}

View file

@ -75,6 +75,7 @@ cvar_t *gl_picmip;
cvar_t *gl_playermip;
cvar_t *gl_reporttjunctions;
cvar_t *gl_sky_clip;
cvar_t *gl_sky_debug;
cvar_t *gl_skymultipass;
cvar_t *gl_texsort;
cvar_t *gl_triplebuffer;
@ -225,6 +226,8 @@ R_Init_Cvars (void)
NULL, "None");
gl_sky_clip = Cvar_Get ("gl_sky_clip", "2", CVAR_ARCHIVE, NULL,
"controls amount of sky overdraw");
gl_sky_debug = Cvar_Get ("gl_sky_debug", "0", CVAR_NONE, NULL,
"debugging `info' for sky clipping");
gl_sky_divide = Cvar_Get ("gl_sky_divide", "1", CVAR_ARCHIVE, NULL,
"subdivide sky polys");
gl_skymultipass = Cvar_Get ("gl_skymultipass", "1", CVAR_ARCHIVE, NULL,