Poly list system beginnings - Depth polys are done but currently have zero

effects.  Will need to do wall poly implementation before it matters.
This commit is contained in:
Joseph Carter 2000-06-19 10:14:00 +00:00
parent 6024c0ce7f
commit 2f811fc65b
9 changed files with 291 additions and 10 deletions

View file

@ -1,5 +1,6 @@
#!/bin/sh
echo "NOTE: two \"AC_TRY_RUN\" warnings below are not a problem!"
aclocal
autoheader
automake --add-missing

View file

@ -11,4 +11,4 @@ EXTRA_DIST = adivtab.h anorm_dots.h anorms.h asm_draw.h asm_i386.h block16.h \
sbar.h screen.h server.h sizebuf.h sound.h spritegn.h sys.h \
uint32.h vid.h view.h wad.h winquake.h world.h zone.h \
win32/fnmatch.h win32/bc/config.h win32/vc/config.h win32/vc/dirent.h \
win32/version.h context_x11.h dga_check.h
win32/version.h context_x11.h dga_check.h gl_poly.h

71
include/gl_poly.h Normal file
View file

@ -0,0 +1,71 @@
/*
gl_poly.h
Interface to the OpenGL poly list renderer
Copyright (C) 2000 Joseph Carter <knghtbrd@debian.org>
Author: Joseph Carter <knghtbrd@debian.org>
Date: 15 Jun 2000
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __GL_POLY_H
#define __GL_POLY_H
//
// Depth polys
//
#define MAX_DEPTHPOLYS 8192
#define MAX_DEPTHVERTS (MAX_DEPTHPOLYS*4)
typedef struct
{
vec3_t v;
} depthvert_t;
typedef struct
{
unsigned short firstvert;
unsigned short verts;
} depthpoly_t;
extern depthvert_t *depthvert;
extern depthpoly_t *depthpoly;
extern unsigned short currentdepthpoly;
extern unsigned short currentdepthvert;
void Poly_ClearDepthPolys (void);
void Poly_BeginDepthPoly (void);
void Poly_EndDepthPoly (void);
void Poly_DepthPolyVert (vec3_t v);
void Poly_RenderDepthPolys (void);
//
// Poly list housekeeping
//
void Poly_Init (void);
void Poly_Shutdown (void);
#endif // __GL_POLY_H

View file

@ -307,5 +307,10 @@ void GL_BuildLightmaps (void);
//
void R_NetGraph (void);
//
// gl_warp.c
//
void EmitDepthPolys (msurface_t *fa);
#endif // _GLQUAKE_H

View file

@ -80,7 +80,7 @@ soft_SOURCES= cl_model.c cl_trans.c d_edge.c d_fill.c d_init.c d_modech.c \
screen.c model.c $(SOFT_ASM)
ogl_SOURCES= gl_draw.c gl_mesh.c gl_model.c gl_ngraph.c gl_part.c \
gl_refrag.c gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
gl_screen.c gl_trans.c gl_view.c gl_warp.c
gl_screen.c gl_trans.c gl_view.c gl_warp.c gl_poly.c
mgl_SOURCES= vid_mgl.c in_win.c
ggi_SOURCES= vid_ggi.c

169
source/gl_poly.c Normal file
View file

@ -0,0 +1,169 @@
/*
gl_poly.c
Poly list renderer for OpenGL
Copyright (C) 2000 Joseph Carter <knghtbrd@debian.org>
Copyright (C) 2000 Forest Hale <havoc@gamevisions.com>
Author: Joseph Carter <knghtbrd@debian.org>
Date: 15 June 2000
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include "glquake.h"
#include "gl_poly.h"
#include "console.h"
// ===========
// DEPTH POLYS
// ===========
depthvert_t *depthvert;
depthpoly_t *depthpoly;
unsigned short currentdepthpoly;
unsigned short currentdepthvert;
/*
Poly_ClearDepthPolys
*/
void
Poly_ClearDepthPolys (void)
{
currentdepthpoly = currentdepthvert = 0;
}
/*
Poly_BeginDepthPoly
*/
void
Poly_BeginDepthPoly (void)
{
if (currentdepthpoly >= MAX_DEPTHPOLYS
|| currentdepthvert >= MAX_DEPTHVERTS)
return;
depthpoly[currentdepthpoly].firstvert = currentdepthvert;
depthpoly[currentdepthpoly].verts = 0;
}
/*
Poly_EndDepthPoly
*/
void
Poly_EndDepthPoly (void)
{
if (currentdepthpoly >= MAX_DEPTHPOLYS)
return;
if (depthpoly[currentdepthpoly].verts < 3)
{
// invalid poly - reset vert pointer
currentdepthvert = depthpoly[currentdepthpoly].firstvert;
return;
}
if (currentdepthvert >= MAX_DEPTHVERTS)
return;
currentdepthpoly++;
}
/*
Poly_DepthPolyVert
*/
void
Poly_DepthPolyVert (vec3_t v)
{
if (currentdepthpoly >= MAX_DEPTHPOLYS
|| currentdepthvert >= MAX_DEPTHVERTS)
return;
VectorCopy (depthvert[currentdepthvert].v, v);
currentdepthvert++;
depthpoly[currentdepthpoly].verts++;
}
/*
Poly_RenderDepthPolys
When drawn with a 0 colormask, a poly is transparent
*/
void
Poly_RenderDepthPolys (void)
{
int i, j;
depthpoly_t *p;
depthvert_t *vert;
if (currentdepthpoly < 1)
return;
glColorMask (0, 0, 0, 0);
glDepthMask (1);
for (i = 0, p = depthpoly; i < currentdepthpoly; i++, p++)
{
vert = &depthvert[p->firstvert];
glBegin (GL_TRIANGLE_FAN);
for (j=0 ; j<p->verts ; j++, vert++)
glVertex3fv (vert->v);
glEnd ();
}
glColorMask (1, 1, 1, 1);
}
// =================
// Poly housekeeping
// =================
/*
Poly_Init
*/
void
Poly_Init (void)
{
// depth polys
depthvert = malloc(MAX_DEPTHVERTS * sizeof(depthvert_t));
depthpoly = malloc(MAX_DEPTHPOLYS * sizeof(depthpoly_t));
}
/*
Poly_Shutdown
*/
void
Poly_Shutdown (void)
{
// depth polys
free (depthvert);
free (depthpoly);
}

View file

@ -55,6 +55,7 @@
#include "model.h" // needed by: glquake.h
#include "console.h"
#include "glquake.h"
#include "gl_poly.h"
qboolean VID_Is8bit(void);
extern void R_InitBubble();
@ -248,7 +249,7 @@ void R_Init (void)
gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None");
if (gl_mtexable)
Cvar_SetValue(gl_texsort, 0.0);
Cvar_SetValue (gl_texsort, 0.0);
gl_cull = Cvar_Get("gl_cull", "1", CVAR_NONE, "None");
gl_smoothmodels = Cvar_Get("gl_smoothmodels", "1", CVAR_NONE, "None");
@ -274,6 +275,8 @@ void R_Init (void)
playertextures = texture_extension_number;
texture_extension_number += MAX_CLIENTS;
Poly_Init ();
}
/*

View file

@ -55,6 +55,7 @@
#include "model.h" // needed by: glquake.h
#include "console.h"
#include "glquake.h"
#include "gl_poly.h"
extern double realtime;
int skytexturenum;
@ -422,6 +423,7 @@ void R_DrawSequentialPoly (msurface_t *s)
glEnd ();
return;
} else {
glDisable (GL_BLEND);
p = s->polys;
t = R_TextureAnimation (s->texinfo->texture);
@ -436,6 +438,8 @@ void R_DrawSequentialPoly (msurface_t *s)
glEnd ();
glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
glEnable (GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin (GL_POLYGON);
v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
@ -457,6 +461,15 @@ void R_DrawSequentialPoly (msurface_t *s)
EmitWaterPolys (s);
return;
}
//
// depth polys for sky surfaces
//
if (s->flags & SURF_DRAWSKY)
{
EmitDepthPolys (s);
return;
}
}
@ -1009,9 +1022,9 @@ void R_RecursiveWorldNode (mnode_t *node)
surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf;
}
} else if (surf->flags & SURF_DRAWSKY) {
surf->texturechain = skychain;
skychain = surf;
// } else if (surf->flags & SURF_DRAWSKY) {
// surf->texturechain = skychain;
// skychain = surf;
} else if (surf->flags & SURF_DRAWTURB) {
surf->texturechain = waterchain;
waterchain = surf;
@ -1044,10 +1057,12 @@ void R_DrawWorld (void)
glColor3f (1.0, 1.0, 1.0);
memset (lightmap_polys, 0, sizeof(lightmap_polys));
// Be sure to clear the skybox --KB
Poly_ClearDepthPolys ();
R_DrawSky ();
R_RecursiveWorldNode (cl.worldmodel->nodes);
Poly_RenderDepthPolys ();
DrawTextureChains ();

View file

@ -42,6 +42,7 @@
#include "console.h"
#include "model.h"
#include "glquake.h"
#include "gl_poly.h"
#include "sys.h"
extern double realtime;
@ -586,9 +587,6 @@ void R_LoadSkys (char * skyname)
void
R_SkyBoxPolyVec(vec5_t v)
{
// avoid interpolation seams
// s = s * (254.0/256.0) + (1.0/256.0);
// t = t * (254.0/256.0) + (1.0/256.0);
glTexCoord2fv (v);
glVertex3f (r_refdef.vieworg[0] + v[2],
r_refdef.vieworg[1] + v[3],
@ -831,3 +829,22 @@ void R_InitSky (texture_t *mt)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
/*
EmitDepthPolys
*/
void
EmitDepthPolys (msurface_t *fa)
{
glpoly_t *p;
float *v;
int i;
for (p=fa->polys ; p ; p=p->next)
{
Poly_BeginDepthPoly ();
for (i=0,v=p->verts[0] ; i<p->numverts ; i++, v+=VERTEXSIZE)
Poly_DepthPolyVert (v);
Poly_EndDepthPoly ();
}
}