Renderer aufgeräumt

This commit is contained in:
Yamagi Burmeister 2009-03-05 13:08:47 +00:00
parent 9f7cd534ff
commit 0453361bbc
6 changed files with 49 additions and 249 deletions

View file

@ -109,9 +109,9 @@ void GL_ScreenShot_f (void)
Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir()); Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir());
Sys_Mkdir (checkname); Sys_Mkdir (checkname);
// //
// find a file name to save it to // find a file name to save it to
// //
strcpy(picname,"quake00.tga"); strcpy(picname,"quake00.tga");
for (i=0 ; i<=99 ; i++) for (i=0 ; i<=99 ; i++)
@ -244,3 +244,4 @@ void GL_UpdateSwapInterval( void )
} }
} }
} }

View file

@ -17,9 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// GL_RSURF.C: surface-related refresh code
#include <assert.h>
#include <assert.h>
#include "header/local.h" #include "header/local.h"
static vec3_t modelorg; // relative to viewpoint static vec3_t modelorg; // relative to viewpoint
@ -97,81 +96,6 @@ image_t *R_TextureAnimation (mtexinfo_t *tex)
return tex->image; return tex->image;
} }
#if 0
/*
=================
WaterWarpPolyVerts
Mangles the x and y coordinates in a copy of the poly
so that any drawing routine can be water warped
=================
*/
glpoly_t *WaterWarpPolyVerts (glpoly_t *p)
{
int i;
float *v, *nv;
static byte buffer[1024];
glpoly_t *out;
out = (glpoly_t *)buffer;
out->numverts = p->numverts;
v = p->verts[0];
nv = out->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE, nv+=VERTEXSIZE)
{
nv[0] = v[0] + 4*sin(v[1]*0.05+r_newrefdef.time)*sin(v[2]*0.05+r_newrefdef.time);
nv[1] = v[1] + 4*sin(v[0]*0.05+r_newrefdef.time)*sin(v[2]*0.05+r_newrefdef.time);
nv[2] = v[2];
nv[3] = v[3];
nv[4] = v[4];
nv[5] = v[5];
nv[6] = v[6];
}
return out;
}
/*
================
DrawGLWaterPoly
Warp the vertex coordinates
================
*/
void DrawGLWaterPoly (glpoly_t *p)
{
int i;
float *v;
p = WaterWarpPolyVerts (p);
qglBegin (GL_TRIANGLE_FAN);
v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{
qglTexCoord2f (v[3], v[4]);
qglVertex3fv (v);
}
qglEnd ();
}
void DrawGLWaterPolyLightmap (glpoly_t *p)
{
int i;
float *v;
p = WaterWarpPolyVerts (p);
qglBegin (GL_TRIANGLE_FAN);
v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
{
qglTexCoord2f (v[5], v[6]);
qglVertex3fv (v);
}
qglEnd ();
}
#endif
/* /*
================ ================
DrawGLPoly DrawGLPoly
@ -514,14 +438,14 @@ void R_RenderBrushPoly (msurface_t *fa)
GL_TexEnv( GL_REPLACE ); GL_TexEnv( GL_REPLACE );
} }
//====== //======
//PGM //PGM
if(fa->texinfo->flags & SURF_FLOWING) if(fa->texinfo->flags & SURF_FLOWING)
DrawGLFlowingPoly (fa); DrawGLFlowingPoly (fa);
else else
DrawGLPoly (fa->polys); DrawGLPoly (fa->polys);
//PGM //PGM
//====== //======
/* /*
** check for lightmap modification ** check for lightmap modification
@ -647,8 +571,6 @@ void DrawTextureChains (void)
c_visible_textures = 0; c_visible_textures = 0;
// GL_TexEnv( GL_REPLACE );
if ( !qglSelectTextureSGIS && !qglActiveTextureARB ) if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
{ {
for ( i = 0, image=gltextures ; i<numgltextures ; i++,image++) for ( i = 0, image=gltextures ; i<numgltextures ; i++,image++)
@ -700,7 +622,6 @@ void DrawTextureChains (void)
image->texturechain = NULL; image->texturechain = NULL;
} }
// GL_EnableMultitexture( true );
} }
GL_TexEnv( GL_REPLACE ); GL_TexEnv( GL_REPLACE );
@ -784,8 +705,8 @@ dynamic:
GL_MBind( QGL_TEXTURE0, image->texnum ); GL_MBind( QGL_TEXTURE0, image->texnum );
GL_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex ); GL_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex );
//========== //==========
//PGM //PGM
if (surf->texinfo->flags & SURF_FLOWING) if (surf->texinfo->flags & SURF_FLOWING)
{ {
float scroll; float scroll;
@ -822,8 +743,8 @@ dynamic:
qglEnd (); qglEnd ();
} }
} }
//PGM //PGM
//========== //==========
} }
else else
{ {
@ -832,8 +753,8 @@ dynamic:
GL_MBind( QGL_TEXTURE0, image->texnum ); GL_MBind( QGL_TEXTURE0, image->texnum );
GL_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex ); GL_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex );
//========== //==========
//PGM //PGM
if (surf->texinfo->flags & SURF_FLOWING) if (surf->texinfo->flags & SURF_FLOWING)
{ {
float scroll; float scroll;
@ -857,8 +778,8 @@ dynamic:
} }
else else
{ {
//PGM //PGM
//========== //==========
for ( p = surf->polys; p; p = p->chain ) for ( p = surf->polys; p; p = p->chain )
{ {
v = p->verts[0]; v = p->verts[0];
@ -871,11 +792,11 @@ dynamic:
} }
qglEnd (); qglEnd ();
} }
//========== //==========
//PGM //PGM
} }
//PGM //PGM
//========== //==========
} }
} }
@ -921,7 +842,7 @@ void R_DrawInlineBModel (void)
dot = DotProduct (modelorg, pplane->normal) - pplane->dist; dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
{ {
@ -1057,7 +978,7 @@ void R_RecursiveWorldNode (mnode_t *node)
if (R_CullBox (node->minmaxs, node->minmaxs+3)) if (R_CullBox (node->minmaxs, node->minmaxs+3))
return; return;
// if a leaf node, draw stuff // if a leaf node, draw stuff
if (node->contents != -1) if (node->contents != -1)
{ {
pleaf = (mleaf_t *)node; pleaf = (mleaf_t *)node;
@ -1084,9 +1005,8 @@ void R_RecursiveWorldNode (mnode_t *node)
return; return;
} }
// node is just a decision point, so go down the apropriate sides // node is just a decision point, so go down the apropriate sides
// find which side of the node we are on
// find which side of the node we are on
plane = node->plane; plane = node->plane;
switch (plane->type) switch (plane->type)
@ -1116,7 +1036,7 @@ void R_RecursiveWorldNode (mnode_t *node)
sidebit = SURF_PLANEBACK; sidebit = SURF_PLANEBACK;
} }
// recurse down the children, front side first // recurse down the children, front side first
R_RecursiveWorldNode (node->children[side]); R_RecursiveWorldNode (node->children[side]);
// draw stuff // draw stuff
@ -1157,42 +1077,6 @@ void R_RecursiveWorldNode (mnode_t *node)
// recurse down the back side // recurse down the back side
R_RecursiveWorldNode (node->children[!side]); R_RecursiveWorldNode (node->children[!side]);
/*
for ( ; c ; c--, surf++)
{
if (surf->visframe != r_framecount)
continue;
if ( (surf->flags & SURF_PLANEBACK) != sidebit )
continue; // wrong side
if (surf->texinfo->flags & SURF_SKY)
{ // just adds to visible sky bounds
R_AddSkySurface (surf);
}
else if (surf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))
{ // add to the translucent chain
// surf->texturechain = alpha_surfaces;
// alpha_surfaces = surf;
}
else
{
if ( qglMTexCoord2fSGIS && !( surf->flags & SURF_DRAWTURB ) )
{
GL_RenderLightmappedPoly( surf );
}
else
{
// the polygon is visible, so add it to the texture
// sorted chain
// FIXME: this is a hack for animation
image = R_TextureAnimation (surf->texinfo);
surf->texturechain = image->texturechain;
image->texturechain = surf;
}
}
}
*/
} }
@ -1329,23 +1213,6 @@ void R_MarkLeaves (void)
} while (node); } while (node);
} }
} }
#if 0
for (i=0 ; i<r_worldmodel->vis->numclusters ; i++)
{
if (vis[i>>3] & (1<<(i&7)))
{
node = (mnode_t *)&r_worldmodel->leafs[i]; // FIXME: cluster
do
{
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
#endif
} }
@ -1464,7 +1331,7 @@ void GL_BuildPolygonFromSurface(msurface_t *fa)
glpoly_t *poly; glpoly_t *poly;
vec3_t total; vec3_t total;
// reconstruct the polygon // reconstruct the polygon
pedges = currentmodel->edges; pedges = currentmodel->edges;
lnumverts = fa->numedges; lnumverts = fa->numedges;
vertpage = 0; vertpage = 0;
@ -1598,8 +1465,6 @@ void GL_BeginBuildingLightmaps (model_t *m)
if (!gl_state.lightmap_textures) if (!gl_state.lightmap_textures)
{ {
gl_state.lightmap_textures = TEXNUM_LIGHTMAPS; gl_state.lightmap_textures = TEXNUM_LIGHTMAPS;
// gl_state.lightmap_textures = gl_state.texture_extension_number;
// gl_state.texture_extension_number = gl_state.lightmap_textures + MAX_LIGHTMAPS;
} }
gl_lms.current_lightmap_texture = 1; gl_lms.current_lightmap_texture = 1;

View file

@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// gl_warp.c -- sky and water polygons
#include "header/local.h" #include "header/local.h"
@ -231,19 +230,11 @@ void EmitWaterPolys (msurface_t *fa)
os = v[3]; os = v[3];
ot = v[4]; ot = v[4];
#if !id386
s = os + r_turbsin[(int)((ot*0.125+r_newrefdef.time) * TURBSCALE) & 255]; s = os + r_turbsin[(int)((ot*0.125+r_newrefdef.time) * TURBSCALE) & 255];
#else
s = os + r_turbsin[Q_ftol( ((ot*0.125+rdt) * TURBSCALE) ) & 255];
#endif
s += scroll; s += scroll;
s *= (1.0/64); s *= (1.0/64);
#if !id386
t = ot + r_turbsin[(int)((os*0.125+rdt) * TURBSCALE) & 255]; t = ot + r_turbsin[(int)((os*0.125+rdt) * TURBSCALE) & 255];
#else
t = ot + r_turbsin[Q_ftol( ((os*0.125+rdt) * TURBSCALE) ) & 255];
#endif
t *= (1.0/64); t *= (1.0/64);
qglTexCoord2f (s, t); qglTexCoord2f (s, t);
@ -267,7 +258,6 @@ vec3_t skyclip[6] = {
}; };
int c_sky; int c_sky;
// 1 = s, 2 = t, 3 = 2048
int st_to_vec[6][3] = int st_to_vec[6][3] =
{ {
{3,-1,2}, {3,-1,2},
@ -279,11 +269,8 @@ int st_to_vec[6][3] =
{-2,-1,3}, // 0 degrees yaw, look straight up {-2,-1,3}, // 0 degrees yaw, look straight up
{2,-1,-3} // look straight down {2,-1,-3} // look straight down
// {-1,2,3},
// {1,2,-3}
}; };
// s = [0]/[2], t = [1]/[2]
int vec_to_st[6][3] = int vec_to_st[6][3] =
{ {
{-2,3,1}, {-2,3,1},
@ -294,9 +281,6 @@ int vec_to_st[6][3] =
{-2,-1,3}, {-2,-1,3},
{-2,1,-3} {-2,1,-3}
// {-1,2,3},
// {1,2,-3}
}; };
float skymins[2][6], skymaxs[2][6]; float skymins[2][6], skymaxs[2][6];
@ -311,16 +295,7 @@ void DrawSkyPolygon (int nump, vec3_t vecs)
float *vp; float *vp;
c_sky++; c_sky++;
#if 0
glBegin (GL_POLYGON);
for (i=0 ; i<nump ; i++, vecs+=3)
{
VectorAdd(vecs, r_origin, v);
qglVertex3fv (v);
}
glEnd();
return;
#endif
// decide which face it maps to // decide which face it maps to
VectorCopy (vec3_origin, v); VectorCopy (vec3_origin, v);
for (i=0, vp=vecs ; i<nump ; i++, vp+=3) for (i=0, vp=vecs ; i<nump ; i++, vp+=3)
@ -563,12 +538,6 @@ void R_DrawSkyBox (void)
{ {
int i; int i;
#if 0
qglEnable (GL_BLEND);
GL_TexEnv( GL_MODULATE );
qglColor4f (1,1,1,0.5);
qglDisable (GL_DEPTH_TEST);
#endif
if (skyrotate) if (skyrotate)
{ // check for no sky at all { // check for no sky at all
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
@ -579,9 +548,9 @@ qglDisable (GL_DEPTH_TEST);
return; // nothing visible return; // nothing visible
} }
qglPushMatrix (); qglPushMatrix ();
qglTranslatef (r_origin[0], r_origin[1], r_origin[2]); qglTranslatef (r_origin[0], r_origin[1], r_origin[2]);
qglRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); qglRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
{ {
@ -607,12 +576,6 @@ qglRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);
qglEnd (); qglEnd ();
} }
qglPopMatrix (); qglPopMatrix ();
#if 0
glDisable (GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4f (1,1,1,0.5);
glEnable (GL_DEPTH_TEST);
#endif
} }
@ -660,3 +623,4 @@ void R_SetSky (char *name, float rotate, vec3_t axis)
} }
} }
} }

View file

@ -28,14 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ctype.h> #include <ctype.h>
#include <GL/gl.h> #include <GL/gl.h>
#ifndef SOLARIS
//#include <GL/glxext.h>
#else
#include <GL/glu.h>
#ifndef GL_COLOR_INDEX8_EXT #ifndef GL_COLOR_INDEX8_EXT
#define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX #define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
#endif #endif
#endif
#include <math.h> #include <math.h>
#ifndef _WIN32 #ifndef _WIN32
@ -68,7 +64,6 @@ typedef struct
extern viddef_t vid; extern viddef_t vid;
/* /*
skins will be outline flood filled and mip mapped skins will be outline flood filled and mip mapped
@ -142,12 +137,9 @@ typedef struct
float r, g, b; float r, g, b;
} glvert_t; } glvert_t;
#define MAX_LBM_HEIGHT 480 #define MAX_LBM_HEIGHT 480
#define BACKFACE_EPSILON 0.01 #define BACKFACE_EPSILON 0.01
//==================================================== //====================================================
extern image_t gltextures[MAX_GLTEXTURES]; extern image_t gltextures[MAX_GLTEXTURES];
@ -306,16 +298,6 @@ void R_ClearSkyBox (void);
void R_DrawSkyBox (void); void R_DrawSkyBox (void);
void R_MarkLights (dlight_t *light, int bit, mnode_t *node); void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
#if 0
short LittleShort (short l);
short BigShort (short l);
int LittleLong (int l);
float LittleFloat (float f);
char *va(char *format, ...);
// does a varargs printf into a temp buffer
#endif
void COM_StripExtension (char *in, char *out); void COM_StripExtension (char *in, char *out);
void Draw_GetPicSize (int *w, int *h, char *name); void Draw_GetPicSize (int *w, int *h, char *name);
@ -449,7 +431,6 @@ IMPORTED FUNCTIONS
extern refimport_t ri; extern refimport_t ri;
/* /*
==================================================================== ====================================================================

View file

@ -36,8 +36,6 @@ BRUSH MODELS
// //
// in memory representation // in memory representation
//
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct typedef struct
{ {
vec3_t position; vec3_t position;
@ -53,19 +51,16 @@ typedef struct
int firstface, numfaces; int firstface, numfaces;
} mmodel_t; } mmodel_t;
#define SIDE_FRONT 0 #define SIDE_FRONT 0
#define SIDE_BACK 1 #define SIDE_BACK 1
#define SIDE_ON 2 #define SIDE_ON 2
#define SURF_PLANEBACK 2 #define SURF_PLANEBACK 2
#define SURF_DRAWSKY 4 #define SURF_DRAWSKY 4
#define SURF_DRAWTURB 0x10 #define SURF_DRAWTURB 0x10
#define SURF_DRAWBACKGROUND 0x40 #define SURF_DRAWBACKGROUND 0x40
#define SURF_UNDERWATER 0x80 #define SURF_UNDERWATER 0x80
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct typedef struct
{ {
unsigned short v[2]; unsigned short v[2];
@ -114,7 +109,7 @@ typedef struct msurface_s
mtexinfo_t *texinfo; mtexinfo_t *texinfo;
// lighting info // lighting info
int dlightframe; int dlightframe;
int dlightbits; int dlightbits;
@ -126,7 +121,7 @@ typedef struct msurface_s
typedef struct mnode_s typedef struct mnode_s
{ {
// common with leaf // common with leaf
int contents; // -1, to differentiate from leafs int contents; // -1, to differentiate from leafs
int visframe; // node needs to be traversed if current int visframe; // node needs to be traversed if current
@ -134,7 +129,7 @@ typedef struct mnode_s
struct mnode_s *parent; struct mnode_s *parent;
// node specific // node specific
cplane_t *plane; cplane_t *plane;
struct mnode_s *children[2]; struct mnode_s *children[2];
@ -146,7 +141,7 @@ typedef struct mnode_s
typedef struct mleaf_s typedef struct mleaf_s
{ {
// common with node // common with node
int contents; // wil be a negative contents number int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current int visframe; // node needs to be traversed if current
@ -154,7 +149,7 @@ typedef struct mleaf_s
struct mnode_s *parent; struct mnode_s *parent;
// leaf specific // leaf specific
int cluster; int cluster;
int area; int area;
@ -182,21 +177,21 @@ typedef struct model_s
int flags; int flags;
// //
// volume occupied by the model graphics // volume occupied by the model graphics
// //
vec3_t mins, maxs; vec3_t mins, maxs;
float radius; float radius;
// //
// solid volume for clipping // solid volume for clipping
// //
qboolean clipbox; qboolean clipbox;
vec3_t clipmins, clipmaxs; vec3_t clipmins, clipmaxs;
// //
// brush model // brush model
// //
int firstmodelsurface, nummodelsurfaces; int firstmodelsurface, nummodelsurfaces;
int lightmap; // only for submodels int lightmap; // only for submodels

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* /*
** QGL.H ** QGL.H
*/ */
@ -29,9 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif #endif
#include <GL/gl.h> #include <GL/gl.h>
#ifndef SOLARIS
//#include <GL/glext.h>
#endif
qboolean QGL_Init( const char *dllname ); qboolean QGL_Init( const char *dllname );
void QGL_Shutdown( void ); void QGL_Shutdown( void );
@ -428,18 +426,14 @@ extern BOOL ( WINAPI * qwglSetDeviceGammaRampEXT ) ( const unsigned char *pRed,
#endif #endif
#ifdef __linux__ #if defined __linux__ || defined __FreeBSD__
// local function in dll // local function in dll
extern void *qwglGetProcAddress(char *symbol); extern void *qwglGetProcAddress(char *symbol);
extern void (*qgl3DfxSetPaletteEXT)(GLuint *);
// 3dfxSetPaletteEXT shunt // 3dfxSetPaletteEXT shunt
void Fake_glColorTableEXT( GLenum target, GLenum internalformat, void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
GLsizei width, GLenum format, GLenum type, GLsizei width, GLenum format, GLenum type,
const GLvoid *table ); const GLvoid *table );
#endif // linux #endif // linux
/* deprecated */ /* deprecated */