clipedge_t edgehead, edgetail;
clipedge_t maxedge = {2000000000.0f};
-cvar_t r_clipwidth = {"r_clipwidth", "800"};
-cvar_t r_clipheight = {"r_clipheight", "600"};
-cvar_t r_clipedges = {"r_clipedges", "32768", true};
-cvar_t r_clipsurfaces = {"r_clipsurfaces", "8192", true};
+cvar_t r_clipwidth = {0, "r_clipwidth", "800"};
+cvar_t r_clipheight = {0, "r_clipheight", "600"};
+cvar_t r_clipedges = {CVAR_SAVE, "r_clipedges", "32768"};
+cvar_t r_clipsurfaces = {CVAR_SAVE, "r_clipsurfaces", "8192"};
int clipwidth = 0, clipheight = 0;
int maxclipsurfs = 0, maxclipedges = 0;
//float r_clip_nearclipdist, r_clip_nearclipdist2;
tinyplane_t r_clip_viewplane[5];
+mempool_t *r_clip_mempool;
+
void R_Clip_MakeViewMatrix(void)
{
float pixelaspect, screenaspect, horizontalfieldofview, verticalfieldofview;
{
int i;
int newwidth, newheight, newmaxedges, newmaxsurfs;
- newwidth = bound(80, (int) r_clipwidth.value, vid.width * 2);
- newheight = bound(60, (int) r_clipheight.value, vid.height * 2);
- newmaxedges = bound(128, (int) r_clipedges.value, 262144);
- newmaxsurfs = bound(32, (int) r_clipsurfaces.value, 65536);
+ newwidth = bound(80, r_clipwidth.integer, vid.realwidth * 2);
+ newheight = bound(60, r_clipheight.integer, vid.realheight * 2);
+ newmaxedges = bound(128, r_clipedges.integer, 262144);
+ newmaxsurfs = bound(32, r_clipsurfaces.integer, 65536);
if (newwidth != clipwidth || newheight != clipheight || maxclipedges != newmaxedges || maxclipsurfs != newmaxsurfs)
{
#if CLIPTEST
if (clipbuffer)
- qfree(clipbuffer);
+ Mem_Free(clipbuffer);
#endif
if (clipedges)
- qfree(clipedges);
+ Mem_Free(clipedges);
if (clipsurfs)
- qfree(clipsurfs);
+ Mem_Free(clipsurfs);
if (newedges)
- qfree(newedges);
+ Mem_Free(newedges);
if (removeedges)
- qfree(removeedges);
+ Mem_Free(removeedges);
clipwidth = newwidth;
clipheight = newheight;
maxclipedges = newmaxedges;
maxclipsurfs = newmaxsurfs;
#if CLIPTEST
- clipbuffer = qmalloc(clipwidth * clipheight * sizeof(clippixel_t));
+ clipbuffer = Mem_Alloc(r_clip_mempool, clipwidth * clipheight * sizeof(clippixel_t));
#endif
- clipedges = qmalloc(maxclipedges * sizeof(clipedge_t));
- clipsurfs = qmalloc(maxclipsurfs * sizeof(clipsurf_t));
- newedges = qmalloc(clipheight * sizeof(clipedge_t));
- removeedges = qmalloc(clipheight * sizeof(clipedge_t *));
+ clipedges = Mem_Alloc(r_clip_mempool, maxclipedges * sizeof(clipedge_t));
+ clipsurfs = Mem_Alloc(r_clip_mempool, maxclipsurfs * sizeof(clipsurf_t));
+ newedges = Mem_Alloc(r_clip_mempool, clipheight * sizeof(clipedge_t));
+ removeedges = Mem_Alloc(r_clip_mempool, clipheight * sizeof(clipedge_t *));
clipedgesend = clipedges + maxclipedges;
clipsurfsend = clipsurfs + maxclipsurfs;
}
void r_clip_start(void)
{
+ r_clip_mempool = Mem_AllocPool("R_Clip");
}
void r_clip_shutdown(void)
{
+ Mem_FreePool(&r_clip_mempool);
#if CLIPTEST
- if (clipbuffer)
- qfree(clipbuffer);
clipbuffer = NULL;
#endif
- if (clipsurfs)
- qfree(clipsurfs);
clipsurfs = NULL;
- if (clipedges)
- qfree(clipedges);
clipedges = NULL;
- if (newedges)
- qfree(newedges);
newedges = NULL;
- if (removeedges)
- qfree(removeedges);
removeedges = NULL;
clipwidth = -1;
clipheight = -1;
float *prevpoint, prevdist, dist, dot;
// begin with the last point, then enter the loop with the first point as current
- prevpoint = (float *) ((byte *)in + stride * (inpoints - 1));
+ prevpoint = (float *) ((qbyte *)in + stride * (inpoints - 1));
prevdist = DotProduct(prevpoint, plane->normal) - plane->dist;
prevside = prevdist >= 0 ? SIDE_FRONT : SIDE_BACK;
i = 0;
prevpoint = in;
prevdist = dist;
prevside = side;
- (byte *)in += stride;
+ (qbyte *)in += stride;
begin:
dist = DotProduct(in, plane->normal) - plane->dist;
{
polyplane = &localplane;
// calculate the plane for the polygon
- if (!R_Clip_TriangleToPlane((float *) points, (float *) ((byte *)points + stride), (float *) ((byte *)points + 2 * stride), polyplane))
+ if (!R_Clip_TriangleToPlane((float *) points, (float *) ((qbyte *)points + stride), (float *) ((qbyte *)points + 2 * stride), polyplane))
{
for (i = 0;i < numverts;i++)
for (j = i + 1;j < numverts;j++)
for (k = j + 1;k < numverts;k++)
- if (R_Clip_TriangleToPlane((float *) ((byte *)points + i * stride), (float *) ((byte *)points + j * stride), (float *) ((byte *)points + k * stride), polyplane))
+ if (R_Clip_TriangleToPlane((float *) ((qbyte *)points + i * stride), (float *) ((qbyte *)points + j * stride), (float *) ((qbyte *)points + k * stride), polyplane))
goto valid1;
return; // gave up
valid1:;
else
{
// calculate the plane for the polygon
- if (!R_Clip_TriangleToPlane((float *) points, (float *) ((byte *)points + stride), (float *) ((byte *)points + 2 * stride), &localplane))
+ if (!R_Clip_TriangleToPlane((float *) points, (float *) ((qbyte *)points + stride), (float *) ((qbyte *)points + 2 * stride), &localplane))
{
for (i = 0;i < numverts;i++)
for (j = i + 1;j < numverts;j++)
for (k = j + 1;k < numverts;k++)
- if (R_Clip_TriangleToPlane((float *) ((byte *)points + i * stride), (float *) ((byte *)points + j * stride), (float *) ((byte *)points + k * stride), &localplane))
+ if (R_Clip_TriangleToPlane((float *) ((qbyte *)points + i * stride), (float *) ((qbyte *)points + j * stride), (float *) ((qbyte *)points + k * stride), &localplane))
goto valid4;
return; // gave up
valid4:;
#if CLIPTEST
int i;
static int firstupload = true;
- byte clipbuffertex[256*256], *b;
- if (!r_render.value)
+ qbyte clipbuffertex[256*256], *b;
+ if (!r_render.integer)
return;
if (clipwidth > 256 || clipheight > 256)
return;
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, clipwidth, clipheight, GL_LUMINANCE, GL_UNSIGNED_BYTE, clipbuffertex);
glBegin (GL_QUADS);
- glTexCoord2f (0 , 0 );glVertex2f (0 , 0 );
- glTexCoord2f (clipwidth / 256.0f, 0 );glVertex2f (vid.width, 0 );
- glTexCoord2f (clipwidth / 256.0f, clipheight / 256.0f);glVertex2f (vid.width, vid.height);
- glTexCoord2f (0 , clipheight / 256.0f);glVertex2f (0 , vid.height);
+ glTexCoord2f (0 , 0 );glVertex2f (0 , 0 );
+ glTexCoord2f (clipwidth / 256.0f, 0 );glVertex2f (vid.conwidth, 0 );
+ glTexCoord2f (clipwidth / 256.0f, clipheight / 256.0f);glVertex2f (vid.conwidth, vid.conheight);
+ glTexCoord2f (0 , clipheight / 256.0f);glVertex2f (0 , vid.conheight);
glEnd ();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);