Merge pull request #382 from 0lvin/for_review

Add auto detect resolution
This commit is contained in:
Yamagi 2019-04-08 14:00:52 +02:00 committed by GitHub
commit 06c4735fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 258 additions and 213 deletions

View file

@ -1559,6 +1559,9 @@ static const char *idcredits[] = {
"Marty Stratton",
"Henk Hartong",
"",
"+PATCHES AUTHORS",
"eliasm",
"",
"+YAMAGI QUAKE II BY",
"Yamagi Burmeister",
"Daniel Gibson",

View file

@ -140,6 +140,9 @@ ResetDefaults(void *unused)
VID_MenuInit();
}
#define CUSTOM_MODE_NAME "[Custom ]"
#define AUTO_MODE_NAME "[Auto ]"
static void
ApplyChanges(void *unused)
{
@ -168,16 +171,23 @@ ApplyChanges(void *unused)
}
}
/* custom mode */
if (s_mode_list.curvalue != GetCustomValue(&s_mode_list))
/* auto mode */
if (!strcmp(s_mode_list.itemnames[s_mode_list.curvalue],
AUTO_MODE_NAME))
{
/* Restarts automatically */
Cvar_SetValue("r_mode", s_mode_list.curvalue);
Cvar_SetValue("r_mode", -2);
}
else if (!strcmp(s_mode_list.itemnames[s_mode_list.curvalue],
CUSTOM_MODE_NAME))
{
/* Restarts automatically */
Cvar_SetValue("r_mode", -1);
}
else
{
/* Restarts automatically */
Cvar_SetValue("r_mode", -1);
Cvar_SetValue("r_mode", s_mode_list.curvalue);
}
/* UI scaling */
@ -242,7 +252,7 @@ VID_MenuInit(void)
"[OpenGL 1.4]",
"[OpenGL 3.2]",
"[Software ]",
"[Custom ]",
CUSTOM_MODE_NAME,
0
};
@ -279,7 +289,8 @@ VID_MenuInit(void)
"[3840 2160 ]",
"[4096 2160 ]",
"[5120 2880 ]",
"[custom ]",
AUTO_MODE_NAME,
CUSTOM_MODE_NAME,
0
};
@ -392,8 +403,14 @@ VID_MenuInit(void)
{
s_mode_list.curvalue = r_mode->value;
}
else if (r_mode->value == -2)
{
// 'auto' is before 'custom'
s_mode_list.curvalue = GetCustomValue(&s_mode_list) - 1;
}
else
{
// 'custom'
s_mode_list.curvalue = GetCustomValue(&s_mode_list);
}

View file

@ -339,7 +339,7 @@ R_LightPoint(vec3_t p, vec3_t color)
vec3_t dist;
float add;
if (!r_worldmodel->lightdata)
if (!r_worldmodel->lightdata || !currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;

View file

@ -425,7 +425,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
vec3_t up, right;
float scale;
byte color[4];
GLfloat vtx[3*num_particles*3];
GLfloat tex[2*num_particles*3];
GLfloat clr[4*num_particles*3];
@ -433,7 +433,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
unsigned int index_tex = 0;
unsigned int index_clr = 0;
unsigned int j;
R_Bind(r_particletexture->texnum);
glDepthMask(GL_FALSE); /* no z buffering */
glEnable(GL_BLEND);
@ -505,7 +505,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1);
glDepthMask(1); /* back to normal Z buffering */
@ -523,12 +523,12 @@ R_DrawParticles(void)
int i;
unsigned char color[4];
const particle_t *p;
GLfloat vtx[3*r_newrefdef.num_particles];
GLfloat clr[4*r_newrefdef.num_particles];
unsigned int index_vtx = 0;
unsigned int index_clr = 0;
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
@ -1285,12 +1285,22 @@ SetMode_impl(int *pwidth, int *pheight, int mode, int fullscreen)
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
and pheight and don't even try to look up the mode info */
if ((mode != -1) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
if ((mode >= 0) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
{
R_Printf(PRINT_ALL, " invalid mode\n");
return rserr_invalid_mode;
}
/* We trying to get resolution from desktop */
if (mode == -2)
{
if(!ri.GLimp_GetDesktopMode(pwidth, pheight))
{
R_Printf( PRINT_ALL, " can't detect mode\n" );
return rserr_invalid_mode;
}
}
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
@ -1751,11 +1761,11 @@ R_DrawBeam(entity_t *e)
vec3_t direction, normalized_direction;
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
vec3_t oldorigin, origin;
GLfloat vtx[3*NUM_BEAM_SEGS*4];
unsigned int index_vtx = 0;
unsigned int pointb;
oldorigin[0] = e->oldorigin[0];
oldorigin[1] = e->oldorigin[1];
oldorigin[2] = e->oldorigin[2];

View file

@ -331,14 +331,25 @@ SetMode_impl(int *pwidth, int *pheight, int mode, int fullscreen)
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
and pheight and don't even try to look up the mode info */
if ((mode != -1) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
if ((mode >= 0) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
{
R_Printf(PRINT_ALL, " invalid mode\n");
return rserr_invalid_mode;
}
/* We trying to get resolution from desktop */
if (mode == -2)
{
if(!ri.GLimp_GetDesktopMode(pwidth, pheight))
{
R_Printf( PRINT_ALL, " can't detect mode\n" );
return rserr_invalid_mode;
}
}
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
{
return rserr_invalid_mode;

View file

@ -65,7 +65,7 @@ typedef struct image_s
int width, height;
qboolean transparent; // true if any 255 pixels in image
int registration_sequence; // 0 = free
byte *pixels[NUM_MIPS]; // mip levels
byte *pixels[NUM_MIPS]; // mip levels
} image_t;
@ -364,7 +364,7 @@ extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin;
void D_DrawSpansPow2(espan_t *pspans);
void D_DrawZSpans(espan_t *pspans);
void TurbulentPow2(espan_t *pspan);
void NonTurbulentPow2(espan_t *pspan); //PGM
void NonTurbulentPow2(espan_t *pspan);
surfcache_t *D_CacheSurface(const entity_t *currententity, msurface_t *surface, int miplevel);
@ -387,7 +387,7 @@ extern int r_drawnpolycount;
extern int *sintable;
extern int *intsintable;
extern int *blanktable; // PGM
extern int *blanktable;
extern vec3_t vup, base_vup;
extern vec3_t vpn, base_vpn;
@ -516,10 +516,10 @@ extern int r_aliasblendcolor;
extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
extern int r_outofsurfaces;
extern int r_outofedges;
extern int r_outofverts;
extern int r_outoftriangles;
extern qboolean r_outofsurfaces;
extern qboolean r_outofedges;
extern qboolean r_outofverts;
extern qboolean r_outoftriangles;
extern mvertex_t *r_pcurrentvertbase;

View file

@ -68,7 +68,7 @@ typedef struct mplane_s
#define SURF_DRAWBACKGROUND 0x40
#define SURF_DRAWSKYBOX 0x80 // sky box
#define SURF_FLOW 0x100 //PGM
#define SURF_FLOW 0x100
typedef struct
{
@ -118,7 +118,7 @@ typedef struct msurface_s
#define CONTENTS_NODE -1
typedef struct mnode_s
{
// common with leaf
// common with leaf
int contents; // CONTENTS_NODE, to differentiate from leafs
int visframe; // node needs to be traversed if current

View file

@ -232,7 +232,7 @@ R_AliasPreparePoints (const entity_t *currententity, finalvert_t *verts, const f
if ((verts + s_pmdl->num_xyz) >= verts_max)
{
r_outofverts += s_pmdl->num_xyz - (verts_max - verts);
r_outofverts = true;
return;
}
@ -404,7 +404,7 @@ R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalve
plightnormal = r_avertexnormals[newv->lightnormalindex];
// PMM - added double damage shell
// added double damage shell
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
{
lerped_vert[0] += plightnormal[0] * POWERSUIT_SCALE;
@ -762,16 +762,16 @@ R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
/*
** select the proper span routine based on translucency
*/
// PMM - added double damage shell
// PMM - reordered to handle blending
// added double damage shell
// reordered to handle blending
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
{
int color;
// PMM - added double
// added double
color = currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM);
// PMM - reordered, new shells after old shells (so they get overriden)
// reordered, new shells after old shells (so they get overriden)
if ( color == RF_SHELL_RED )
r_aliasblendcolor = SHELL_RED_COLOR;
else if ( color == RF_SHELL_GREEN )
@ -784,40 +784,13 @@ R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
r_aliasblendcolor = SHELL_RB_COLOR;
else if ( color == (RF_SHELL_BLUE | RF_SHELL_GREEN) )
r_aliasblendcolor = SHELL_BG_COLOR;
// PMM - added this .. it's yellowish
// added this .. it's yellowish
else if ( color == (RF_SHELL_DOUBLE) )
r_aliasblendcolor = SHELL_DOUBLE_COLOR;
else if ( color == (RF_SHELL_HALF_DAM) )
r_aliasblendcolor = SHELL_HALF_DAM_COLOR;
// pmm
else
r_aliasblendcolor = SHELL_WHITE_COLOR;
/*
if ( color & RF_SHELL_RED )
{
if ( ( color & RF_SHELL_BLUE) && ( color & RF_SHELL_GREEN) )
r_aliasblendcolor = SHELL_WHITE_COLOR;
else if ( color & (RF_SHELL_BLUE | RF_SHELL_DOUBLE))
r_aliasblendcolor = SHELL_RB_COLOR;
else
r_aliasblendcolor = SHELL_RED_COLOR;
}
else if ( color & RF_SHELL_BLUE)
{
if ( color & RF_SHELL_DOUBLE )
r_aliasblendcolor = SHELL_CYAN_COLOR;
else
r_aliasblendcolor = SHELL_BLUE_COLOR;
}
else if ( color & (RF_SHELL_DOUBLE) )
r_aliasblendcolor = SHELL_DOUBLE_COLOR;
else if ( color & (RF_SHELL_HALF_DAM) )
r_aliasblendcolor = SHELL_HALF_DAM_COLOR;
else if ( color & RF_SHELL_GREEN )
r_aliasblendcolor = SHELL_GREEN_COLOR;
else
r_aliasblendcolor = SHELL_WHITE_COLOR;
*/
if ( currententity->alpha > 0.33 )
d_pdrawspans = R_PolysetDrawSpansConstant8_66;

View file

@ -38,14 +38,10 @@ typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t;
#define MAX_BMODEL_VERTS 500 // 6K
#define MAX_BMODEL_EDGES 1000 // 12K
static mvertex_t *pbverts;
static bedge_t *pbedges;
static int numbverts, numbedges;
static mvertex_t bverts[MAX_BMODEL_VERTS];
static bedge_t bedges[MAX_BMODEL_EDGES];
static mvertex_t *pfrontenter, *pfrontexit;
//===========================================================================
/*
@ -157,12 +153,11 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
float frac;
mplane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
mnode_t *pn;
int area;
qboolean makeclippededge;
mvertex_t *pfrontenter = bverts, *pfrontexit = bverts;
psideedges[0] = psideedges[1] = NULL;
@ -206,13 +201,15 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
if (side != lastside)
{
float frac;
// clipped
if (numbverts >= MAX_BMODEL_VERTS)
return;
// generate the clipped vertex
frac = lastdist / (lastdist - dist);
ptvert = &pbverts[numbverts++];
ptvert = &bverts[numbverts++];
ptvert->position[0] = plastvert->position[0] +
frac * (pvert->position[0] -
plastvert->position[0]);
@ -232,13 +229,13 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
return;
}
ptedge = &pbedges[numbedges];
ptedge = &bedges[numbedges];
ptedge->pnext = psideedges[lastside];
psideedges[lastside] = ptedge;
ptedge->v[0] = plastvert;
ptedge->v[1] = ptvert;
ptedge = &pbedges[numbedges + 1];
ptedge = &bedges[numbedges + 1];
ptedge->pnext = psideedges[side];
psideedges[side] = ptedge;
ptedge->v[0] = ptvert;
@ -267,7 +264,7 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
// if anything was clipped, reconstitute and add the edges along the clip
// plane to both sides (but in opposite directions)
if (makeclippededge)
if (makeclippededge && pfrontexit != pfrontenter)
{
if (numbedges >= (MAX_BMODEL_EDGES - 2))
{
@ -275,13 +272,13 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
return;
}
ptedge = &pbedges[numbedges];
ptedge = &bedges[numbedges];
ptedge->pnext = psideedges[0];
psideedges[0] = ptedge;
ptedge->v[0] = pfrontexit;
ptedge->v[1] = pfrontenter;
ptedge = &pbedges[numbedges + 1];
ptedge = &bedges[numbedges + 1];
ptedge->pnext = psideedges[1];
psideedges[1] = ptedge;
ptedge->v[0] = pfrontenter;
@ -308,6 +305,8 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
{
if (r_newrefdef.areabits)
{
int area;
area = ((mleaf_t *)pn)->area;
if (! (r_newrefdef.areabits[area>>3] & (1<<(area&7)) ) )
continue; // not visible
@ -337,12 +336,10 @@ Bmodel crosses multiple leafs
void
R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, mnode_t *topnode)
{
int i, j, lindex;
vec_t dot;
int i;
msurface_t *psurf;
int numsurfaces;
bedge_t *pbedge;
medge_t *pedge, *pedges;
int numsurfaces;
medge_t *pedges;
// FIXME: use bounding-box-based frustum clipping info?
psurf = &currentmodel->surfaces[currentmodel->firstmodelsurface];
@ -352,6 +349,10 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
for (i=0 ; i<numsurfaces ; i++, psurf++)
{
mplane_t *pplane;
bedge_t *pbedge;
medge_t *pedge;
vec_t dot;
int j;
// find which side of the node we are on
pplane = psurf->plane;
@ -369,14 +370,14 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
// clockwise winding
// FIXME: if edges and vertices get caches, these assignments must move
// outside the loop, and overflow checking must be done here
pbverts = bverts;
pbedges = bedges;
numbverts = numbedges = 0;
pbedge = &bedges[numbedges];
numbedges += psurf->numedges;
for (j=0 ; j<psurf->numedges ; j++)
{
int lindex;
lindex = currentmodel->surfedges[psurf->firstedge+j];
if (lindex > 0)

View file

@ -35,19 +35,15 @@ RE_Draw_FindPic
image_t *
RE_Draw_FindPic (char *name)
{
image_t *image;
if (name[0] != '/' && name[0] != '\\')
{
char fullname[MAX_QPATH];
Com_sprintf (fullname, sizeof(fullname), "pics/%s.pcx", name);
image = R_FindImage (fullname, it_pic);
return R_FindImage (fullname, it_pic);
}
else
image = R_FindImage (name+1, it_pic);
return image;
return R_FindImage (name+1, it_pic);
}
@ -81,7 +77,7 @@ smoothly scrolled off.
void
RE_Draw_CharScaled(int x, int y, int num, float scale)
{
pixel_t *dest;
pixel_t *dest, *dest_max;
byte *source;
int drawline;
int row, col, u, xpos, ypos, iscale;
@ -96,7 +92,7 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
if (y <= -8)
return; // totally off screen
if ( ( y + 8 ) > vid.height ) // PGM - status text was missing in sw...
if ( ( y + 8 ) > vid.height ) // status text was missing in sw...
return;
row = num>>4;
@ -113,6 +109,7 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
drawline = 8;
dest = vid_buffer + y * vid.width + x;
dest_max = vid_buffer + vid.height * vid.width;
while (drawline--)
{
@ -127,6 +124,12 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
}
}
dest += vid.width;
// clipped last lines
if (dest >= dest_max)
{
return;
}
}
source += 128;
}

View file

@ -828,7 +828,7 @@ D_CalcGradients (msurface_t *pface)
((pface->texturemins[1] << SHIFT16XYZ) >> miplevel)
+ pface->texinfo->vecs[1][3]*t;
// PGM - changing flow speed for non-warping textures.
// changing flow speed for non-warping textures.
if (pface->texinfo->flags & SURF_FLOWING)
{
if(pface->texinfo->flags & SURF_WARP)
@ -836,7 +836,6 @@ D_CalcGradients (msurface_t *pface)
else
sadjust += SHIFT16XYZ_MULT * (-128 * ( (r_newrefdef.time * 0.77) - (int)(r_newrefdef.time * 0.77) ));
}
// PGM
//
// -1 (-epsilon) so we never wander off the edge of the texture
@ -902,13 +901,11 @@ D_TurbulentSurf(surf_t *s)
D_CalcGradients (pface);
//============
//PGM
// textures that aren't warping are just flowing. Use NonTurbulentPow2 instead
if(!(pface->texinfo->flags & SURF_WARP))
NonTurbulentPow2 (s->spans);
else
TurbulentPow2 (s->spans);
//PGM
//============
D_DrawZSpans (s->spans);

View file

@ -174,6 +174,9 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
image_t *image;
size_t i, size, full_size;
if (!pic)
return NULL;
image = R_FindFreeImage();
if (strlen(name) >= sizeof(image->name))
ri.Sys_Error(ERR_DROP, "%s: '%s' is too long", __func__, name);

View file

@ -48,20 +48,16 @@ R_MarkLights (dlight_t *light, int bit, mnode_t *node, int r_dlightframecount)
splitplane = node->plane;
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
//=====
//PGM
i=light->intensity;
if(i<0)
i=-i;
//PGM
//=====
i = light->intensity;
if( i< 0)
i = -i;
if (dist > i) // PGM (dist > light->intensity)
if (dist > i) // (dist > light->intensity)
{
R_MarkLights (light, bit, node->children[0], r_dlightframecount);
return;
}
if (dist < -i) // PGM (dist < -light->intensity)
if (dist < -i) // (dist < -light->intensity)
{
R_MarkLights (light, bit, node->children[1], r_dlightframecount);
return;
@ -289,7 +285,7 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
int smax, tmax;
mtexinfo_t *tex;
dlight_t *dl;
int negativeLight; //PGM
int negativeLight;
surf = drawsurf->surf;
smax = (surf->extents[0]>>4)+1;
@ -306,14 +302,12 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
rad = dl->intensity;
//=====
//PGM
negativeLight = 0;
if(rad < 0)
{
negativeLight = 1;
rad = -rad;
}
//PGM
//=====
dist = DotProduct (dl->origin, surf->plane->normal) -
@ -352,7 +346,6 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
dist = td + (sd>>1);
//====
//PGM
if(!negativeLight)
{
if (dist < minlight)
@ -365,7 +358,6 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
if(*plightdest < minlight)
*plightdest = minlight;
}
//PGM
//====
plightdest ++;
}

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// sw_main.c
#include <stdint.h>
#include <limits.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_video.h>
@ -68,10 +69,10 @@ int r_numallocatededges;
int r_numallocatedverts;
int r_numallocatedtriangles;
float r_aliasuvscale = 1.0;
int r_outofsurfaces;
int r_outofedges;
int r_outofverts;
int r_outoftriangles;
qboolean r_outofsurfaces;
qboolean r_outofedges;
qboolean r_outofverts;
qboolean r_outoftriangles;
qboolean r_dowarp;
@ -148,9 +149,7 @@ cvar_t *r_lightlevel; //FIXME HACK
static cvar_t *vid_fullscreen;
static cvar_t *vid_gamma;
//PGM
static cvar_t *r_lockpvs;
//PGM
// sw_vars.c
@ -261,9 +260,7 @@ R_RegisterVariables (void)
vid_gamma->modified = true; // force us to rebuild the gamma table later
sw_overbrightbits->modified = true; // force us to rebuild palette later
//PGM
r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", 0);
//PGM
}
static void
@ -379,6 +376,7 @@ R_ReallocateMapBuffers (void)
if (r_outofsurfaces)
{
r_cnumsurfs *= 2;
r_outofsurfaces = false;
}
if (r_cnumsurfs < NUMSTACKSURFACES)
@ -413,6 +411,7 @@ R_ReallocateMapBuffers (void)
if (r_outofedges)
{
r_numallocatededges *= 2;
r_outofedges = false;
}
if (r_numallocatededges < NUMSTACKEDGES)
@ -443,6 +442,7 @@ R_ReallocateMapBuffers (void)
if (r_outofverts)
{
r_numallocatedverts *= 2;
r_outofverts = false;
}
if (r_numallocatedverts < MAXALIASVERTS)
@ -470,6 +470,7 @@ R_ReallocateMapBuffers (void)
if (r_outoftriangles)
{
r_numallocatedtriangles *= 2;
r_outoftriangles = false;
}
if (r_numallocatedtriangles < vid.height)
@ -782,8 +783,8 @@ RotatedBBox (const vec3_t mins, const vec3_t maxs, vec3_t angles, vec3_t tmins,
for (i=0 ; i<3 ; i++)
{
tmins[i] = 99999;
tmaxs[i] = -99999;
tmins[i] = INT_MAX; // Set maximum values for world range
tmaxs[i] = INT_MIN; // Set minimal values for world range
}
AngleVectors (angles, forward, right, up);
@ -1477,47 +1478,49 @@ GetRefAPI
Q2_DLL_EXPORTED refexport_t
GetRefAPI(refimport_t imp)
{
refexport_t re;
// struct for save refexport callbacks, copy of re struct from main file
// used different variable name for prevent confusion and cppcheck warnings
refexport_t refexport;
memset(&re, 0, sizeof(refexport_t));
memset(&refexport, 0, sizeof(refexport_t));
ri = imp;
re.api_version = API_VERSION;
refexport.api_version = API_VERSION;
re.BeginRegistration = RE_BeginRegistration;
re.RegisterModel = RE_RegisterModel;
re.RegisterSkin = RE_RegisterSkin;
re.DrawFindPic = RE_Draw_FindPic;
re.SetSky = RE_SetSky;
re.EndRegistration = RE_EndRegistration;
refexport.BeginRegistration = RE_BeginRegistration;
refexport.RegisterModel = RE_RegisterModel;
refexport.RegisterSkin = RE_RegisterSkin;
refexport.DrawFindPic = RE_Draw_FindPic;
refexport.SetSky = RE_SetSky;
refexport.EndRegistration = RE_EndRegistration;
re.RenderFrame = RE_RenderFrame;
refexport.RenderFrame = RE_RenderFrame;
re.DrawGetPicSize = RE_Draw_GetPicSize;
refexport.DrawGetPicSize = RE_Draw_GetPicSize;
re.DrawPicScaled = RE_Draw_PicScaled;
re.DrawStretchPic = RE_Draw_StretchPic;
re.DrawCharScaled = RE_Draw_CharScaled;
re.DrawTileClear = RE_Draw_TileClear;
re.DrawFill = RE_Draw_Fill;
re.DrawFadeScreen = RE_Draw_FadeScreen;
refexport.DrawPicScaled = RE_Draw_PicScaled;
refexport.DrawStretchPic = RE_Draw_StretchPic;
refexport.DrawCharScaled = RE_Draw_CharScaled;
refexport.DrawTileClear = RE_Draw_TileClear;
refexport.DrawFill = RE_Draw_Fill;
refexport.DrawFadeScreen = RE_Draw_FadeScreen;
re.DrawStretchRaw = RE_Draw_StretchRaw;
refexport.DrawStretchRaw = RE_Draw_StretchRaw;
re.Init = RE_Init;
re.IsVSyncActive = RE_IsVsyncActive;
re.Shutdown = RE_Shutdown;
re.InitContext = RE_InitContext;
re.ShutdownContext = RE_ShutdownContext;
re.PrepareForWindow = RE_PrepareForWindow;
refexport.Init = RE_Init;
refexport.IsVSyncActive = RE_IsVsyncActive;
refexport.Shutdown = RE_Shutdown;
refexport.InitContext = RE_InitContext;
refexport.ShutdownContext = RE_ShutdownContext;
refexport.PrepareForWindow = RE_PrepareForWindow;
re.SetPalette = RE_SetPalette;
re.BeginFrame = RE_BeginFrame;
re.EndFrame = RE_EndFrame;
refexport.SetPalette = RE_SetPalette;
refexport.BeginFrame = RE_BeginFrame;
refexport.EndFrame = RE_EndFrame;
Swap_Init ();
return re;
return refexport;
}
/*
@ -1772,13 +1775,23 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen )
R_Printf (PRINT_ALL, "setting mode %d:", mode );
if ((mode != -1) && !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
if ((mode >= 0) && !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
{
R_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
R_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight);
/* We trying to get resolution from desktop */
if (mode == -2)
{
if(!ri.GLimp_GetDesktopMode(pwidth, pheight))
{
R_Printf( PRINT_ALL, " can't detect mode\n" );
return rserr_invalid_mode;
}
}
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
{
@ -1809,7 +1822,7 @@ SWimp_CreateRender(void)
edge_basespans = malloc((vid.width*2) * sizeof(espan_t));
// count of "out of items"
r_outofsurfaces = r_outofedges = r_outofverts = r_outoftriangles = 0;
r_outofsurfaces = r_outofedges = r_outofverts = r_outoftriangles = false;
// pointers to allocated buffers
finalverts = NULL;
r_edges = NULL;

View file

@ -203,7 +203,7 @@ R_SetUpFrustumIndexes (void)
}
}
// FIXME: do just once at start
// FIXME: do just once at start
pfrustum_indexes[i] = pindex;
pindex += 6;
}
@ -385,10 +385,6 @@ R_SetupFrame (void)
r_polycount = 0;
r_drawnpolycount = 0;
r_amodels_drawn = 0;
r_outofsurfaces = 0;
r_outofverts = 0;
r_outofedges = 0;
r_outoftriangles = 0;
// d_setup
d_minmip = sw_mipcap->value;

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// models are the only shared resource between a client and server running
// on the same machine.
#include <limits.h>
#include "header/local.h"
model_t *loadmodel;
@ -365,14 +366,11 @@ Mod_LoadVertexes (lump_t *l)
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+8)*sizeof(*out)); // extra for skybox
/*
* PATCH: eliasm
*
* This patch fixes the problem where the games dumped core
* when changing levels.
*/
memset( out, 0, (count + 6) * sizeof( *out ) );
/* END OF PATCH */
/*
* Fix for the problem where the games dumped core
* when changing levels.
*/
memset( out, 0, (count + 6) * sizeof( *out ) );
loadmodel->vertexes = out;
loadmodel->numvertexes = count;
@ -512,15 +510,12 @@ Mod_LoadTexinfo (lump_t *l)
if (next > 0)
out->next = loadmodel->texinfo + next;
/*
* PATCH: eliasm
*
* This patch fixes the problem where the game
* Fix for the problem where the game
* domed core when loading a new level.
*/
else {
out->next = NULL;
}
/* END OF PATCH */
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
out->image = R_FindImage (name, it_wall);
@ -556,8 +551,8 @@ CalcSurfaceExtents (msurface_t *s)
mtexinfo_t *tex;
int bmins[2], bmaxs[2];
mins[0] = mins[1] = 999999;
maxs[0] = maxs[1] = -99999;
mins[0] = mins[1] = INT_MAX; // Set maximum values for world range
maxs[0] = maxs[1] = INT_MIN; // Set minimal values for world range
tex = s->texinfo;
@ -683,7 +678,6 @@ Mod_LoadFaces (lump_t *l)
}
//==============
//PGM
// this marks flowing surfaces as turbulent, but with the new
// SURF_FLOW flag.
if (out->texinfo->flags & SURF_FLOWING)
@ -696,7 +690,6 @@ Mod_LoadFaces (lump_t *l)
}
continue;
}
//PGM
//==============
}
}
@ -1339,9 +1332,7 @@ RE_RegisterModel (char *name)
pheader = (dmdl_t *)mod->extradata;
for (i=0 ; i<pheader->num_skins ; i++)
mod->skins[i] = R_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
//PGM
mod->numframes = pheader->num_frames;
//PGM
}
else if (mod->type == mod_brush)
{

View file

@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <assert.h>
#include <limits.h>
#include "header/local.h"
#define AFFINE_SPANLET_SIZE 16
@ -48,7 +49,7 @@ static emitpoint_t outverts[MAXWORKINGVERTS+3];
static int s_minindex, s_maxindex;
static void R_DrawPoly(int iswater);
static void R_DrawPoly(int iswater, espan_t *spans);
/*
** R_DrawSpanletOpaque
@ -589,7 +590,7 @@ R_ClipPolyFace (int nump, clipplane_t *pclipplane)
/*
** R_PolygonDrawSpans
*/
// PGM - iswater was qboolean. changed to allow passing more flags
// iswater was qboolean. changed to allow passing more flags
static void
R_PolygonDrawSpans(espan_t *pspan, int iswater )
{
@ -600,13 +601,11 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
s_spanletvars.pbase = cacheblock;
//PGM
if ( iswater & SURF_WARP)
r_turb_turb = sintable + ((int)(r_newrefdef.time*SPEED)&(CYCLE-1));
else
// iswater & SURF_FLOWING
r_turb_turb = blanktable;
//PGM
sdivzspanletstepu = d_sdivzstepu * AFFINE_SPANLET_SIZE;
tdivzspanletstepu = d_tdivzstepu * AFFINE_SPANLET_SIZE;
@ -910,7 +909,7 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
/*
** R_ClipAndDrawPoly
*/
// PGM - isturbulent was qboolean. changed to int to allow passing more flags
// isturbulent was qboolean. changed to int to allow passing more flags
void
R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
{
@ -1021,7 +1020,7 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
r_polydesc.nump = nump;
r_polydesc.pverts = outverts;
R_DrawPoly(isturbulent);
R_DrawPoly(isturbulent, vid_polygon_spans);
}
/*
@ -1074,14 +1073,12 @@ R_BuildPolygonFromSurface(const entity_t *currententity, const model_t *currentm
VectorSubtract( vec3_origin, r_polydesc.vpn, r_polydesc.vpn );
}
// PGM 09/16/98
if ( fa->texinfo->flags & (SURF_WARP|SURF_FLOWING) )
{
r_polydesc.pixels = fa->texinfo->image->pixels[0];
r_polydesc.pixel_width = fa->texinfo->image->width;
r_polydesc.pixel_height = fa->texinfo->image->height;
}
// PGM 09/16/98
else
{
surfcache_t *scache;
@ -1153,20 +1150,18 @@ R_PolygonCalculateGradients (void)
**
** This should NOT be called externally since it doesn't do clipping!
*/
// PGM - iswater was qboolean. changed to support passing more flags
// iswater was qboolean. changed to support passing more flags
static void
R_DrawPoly(int iswater)
R_DrawPoly(int iswater, espan_t *spans)
{
int i, nump;
float ymin, ymax;
emitpoint_t *pverts;
espan_t *spans;
spans = vid_polygon_spans;
// find the top and bottom vertices, and make sure there's at least one scan to
// draw
ymin = 999999.9;
ymax = -999999.9;
ymin = INT_MAX; // Set maximum values for world range
ymax = INT_MIN; // Set minimal values for world range
pverts = r_polydesc.pverts;
for (i=0 ; i<r_polydesc.nump ; i++)
@ -1202,8 +1197,8 @@ R_DrawPoly(int iswater)
pverts[nump] = pverts[0];
R_PolygonCalculateGradients();
R_PolygonScanLeftEdge(vid_polygon_spans);
R_PolygonScanRightEdge(vid_polygon_spans);
R_PolygonScanLeftEdge(spans);
R_PolygonScanRightEdge(spans);
R_PolygonDrawSpans(spans, iswater);
}
@ -1225,20 +1220,11 @@ R_DrawAlphaSurfaces(const entity_t *currententity)
{
R_BuildPolygonFromSurface(currententity, currentmodel, s);
//=======
//PGM
// if (s->texinfo->flags & SURF_TRANS66)
// R_ClipAndDrawPoly( 0.60f, ( s->texinfo->flags & SURF_WARP) != 0, true );
// else
// R_ClipAndDrawPoly( 0.30f, ( s->texinfo->flags & SURF_WARP) != 0, true );
// PGM - pass down all the texinfo flags, not just SURF_WARP.
// pass down all the texinfo flags, not just SURF_WARP.
if (s->texinfo->flags & SURF_TRANS66)
R_ClipAndDrawPoly( 0.60f, (s->texinfo->flags & (SURF_WARP|SURF_FLOWING)), true );
else
R_ClipAndDrawPoly( 0.30f, (s->texinfo->flags & (SURF_WARP|SURF_FLOWING)), true );
//PGM
//=======
s = s->nextalphasurface;
}

View file

@ -86,7 +86,6 @@ static void R_PolysetSetEdgeTable(void);
static void R_RasterizeAliasPolySmooth(const entity_t *currententity);
// ======================
// PGM
// 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
static const byte irtable[256] = {
79, 78, 77, 76, 75, 74, 73, 72, // black/white
@ -129,7 +128,6 @@ static const byte irtable[256] = {
208, 208, 64, 64, 70, 71, 72, 64, // mishmash1
66, 68, 70, 64, 65, 66, 67, 68}; // mishmash2
// PGM
// ======================
/*
@ -220,7 +218,7 @@ R_PushEdgesSpan(int u, int v, int count,
if (d_pedgespanpackage >= triangles_max)
{
// no space any more
r_outoftriangles++;
r_outoftriangles = true;
return;
}
@ -698,12 +696,10 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
{
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
//PGM
if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
*lpdest = ((byte *)vid_colormap)[irtable[*lptex]];
else
*lpdest = ((byte *)vid_colormap)[*lptex + (llight & 0xFF00)];
//PGM
*lpz = lzi >> SHIFT16XYZ;
}
@ -891,7 +887,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
if ((triangle_spans + initialrightheight) >= triangles_max)
{
// we dont have enough triangles for save full height
r_outoftriangles++;
r_outoftriangles = true;
return;
}
originalcount = triangle_spans[initialrightheight].count;
@ -920,7 +916,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
if ((triangle_spans + initialrightheight + height) >= triangles_max)
{
// we dont have enough triangles for save full height
r_outoftriangles++;
r_outoftriangles = true;
return;
}
triangle_spans[initialrightheight + height].count = INT_MIN; // mark end of the spanpackages

View file

@ -46,7 +46,7 @@ static qboolean r_nearzionly;
int *sintable;
int *intsintable;
int *blanktable; // PGM
int *blanktable;
static mvertex_t r_leftenter, r_leftexit;
static mvertex_t r_rightenter, r_rightexit;
@ -411,7 +411,7 @@ R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
// point 0 is unclipped
if (d1 >= 0)
{
// both points are unclipped
// both points are unclipped
continue;
}
@ -548,14 +548,14 @@ R_RenderFace (entity_t *currententity, const model_t *currentmodel, msurface_t *
// skip out if no more surfs
if ((surface_p) >= surf_max)
{
r_outofsurfaces++;
r_outofsurfaces = true;
return;
}
// ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + fa->numedges + 4) >= edge_max)
{
r_outofedges += fa->numedges;
r_outofedges = true;
return;
}
@ -755,14 +755,14 @@ R_RenderBmodelFace(entity_t *currententity, bedge_t *pedges, msurface_t *psurf)
// skip out if no more surfs
if (surface_p >= surf_max)
{
r_outofsurfaces++;
r_outofsurfaces = true;
return;
}
// ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + psurf->numedges + 4) >= edge_max)
{
r_outofedges += psurf->numedges;
r_outofedges = true;
return;
}

View file

@ -331,7 +331,6 @@ TurbulentPow2 (espan_t *pspan)
}
//====================
//PGM
/*
=============
NonTurbulentPow2 - this is for drawing scrolling textures. they're warping water textures
@ -484,7 +483,7 @@ NonTurbulentPow2 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
//PGM
//====================
// Enable custom filtering

View file

@ -37,6 +37,9 @@ cvar_t *vid_displayrefreshrate;
int glimp_refreshRate = -1;
static int last_flags = 0;
static int last_display = 0;
static int last_position_x = SDL_WINDOWPOS_UNDEFINED;
static int last_position_y = SDL_WINDOWPOS_UNDEFINED;
static SDL_Window* window = NULL;
static qboolean initSuccessful = false;
@ -45,9 +48,16 @@ static qboolean initSuccessful = false;
static qboolean
CreateSDLWindow(int flags, int w, int h)
{
int windowPos = SDL_WINDOWPOS_UNDEFINED;
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
window = SDL_CreateWindow("Yamagi Quake II",
last_position_x, last_position_y,
w, h, flags);
if (window)
{
/* save current display as default */
last_display = SDL_GetWindowDisplayIndex(window);
SDL_GetWindowPosition(window,
&last_position_x, &last_position_y);
}
return window != NULL;
}
@ -136,6 +146,10 @@ ShutdownGraphics(void)
{
if (window)
{
/* save current display as default */
last_display = SDL_GetWindowDisplayIndex(window);
SDL_GetWindowPosition(window,
&last_position_x, &last_position_y);
/* cleanly ungrab input (needs window) */
GLimp_GrabInput(false);
SDL_DestroyWindow(window);
@ -417,3 +431,40 @@ GLimp_GetRefreshRate(void)
return glimp_refreshRate;
}
/*
* Detect current desktop mode
*/
qboolean
GLimp_GetDesktopMode(int *pwidth, int *pheight)
{
// Declare display mode structure to be filled in.
SDL_DisplayMode mode;
if (window)
{
/* save current display as default */
last_display = SDL_GetWindowDisplayIndex(window);
SDL_GetWindowPosition(window,
&last_position_x, &last_position_y);
}
if (last_display < 0)
{
// In case of error...
Com_Printf("Can't detect current desktop.\n");
last_display = 0;
}
// We can't get desktop where we start, so use first desktop
if(SDL_GetDesktopDisplayMode(last_display, &mode) != 0)
{
// In case of error...
Com_Printf("Can't detect default desktop mode: %s\n",
SDL_GetError());
return false;
}
*pwidth = mode.w;
*pheight = mode.h;
return true;
}

View file

@ -231,6 +231,7 @@ typedef struct
void (IMPORT *Vid_WriteScreenshot)( int width, int height, int comp, const void* data );
qboolean (IMPORT *GLimp_InitGraphics)(int fullscreen, int *pwidth, int *pheight);
qboolean (IMPORT *GLimp_GetDesktopMode)(int *pwidth, int *pheight);
} refimport_t;
// this is the only function actually exported at the linker level

View file

@ -29,7 +29,7 @@
#include "../../../common/header/common.h"
// FIXME: Remove it, it's unused.
// FIXME: Remove it, it's unused.
typedef struct vrect_s {
int x,y,width,height;
} vrect_t;
@ -61,5 +61,6 @@ qboolean GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight);
void GLimp_ShutdownGraphics(void);
void GLimp_GrabInput(qboolean grab);
int GLimp_GetRefreshRate(void);
qboolean GLimp_GetDesktopMode(int *pwidth, int *pheight);
#endif

View file

@ -387,6 +387,7 @@ VID_LoadRenderer(void)
ri.FS_Gamedir = FS_Gamedir;
ri.FS_LoadFile = FS_LoadFile;
ri.GLimp_InitGraphics = GLimp_InitGraphics;
ri.GLimp_GetDesktopMode = GLimp_GetDesktopMode;
ri.Sys_Error = Com_Error;
ri.Vid_GetModeInfo = VID_GetModeInfo;
ri.Vid_MenuInit = VID_MenuInit;