コード例 #1
0
static void MapRenderer_UpdateChunks(double delta) {
	struct LocalPlayer* p;
	bool samePos;
	int chunkUpdates = 0;

	/* Build more chunks if 30 FPS or over, otherwise slowdown */
	chunksTarget += delta < CHUNK_TARGET_TIME ? 1 : -1; 
	Math_Clamp(chunksTarget, 4, MapRenderer_MaxUpdates);

	p = &LocalPlayer_Instance;
	samePos = Vector3_Equals(&Camera.CurrentPos, &lastCamPos)
		&& p->Base.HeadX == lastHeadX && p->Base.HeadY == lastHeadY;

	renderChunksCount = samePos ?
		MapRenderer_UpdateChunksStill(&chunkUpdates) :
		MapRenderer_UpdateChunksAndVisibility(&chunkUpdates);

	lastCamPos = Camera.CurrentPos;
	lastHeadX  = p->Base.HeadX; 
	lastHeadY  = p->Base.HeadY;

	if (!samePos || chunkUpdates) {
		MapRenderer_ResetPartFlags();
	}
}
コード例 #2
0
/*	Called when scr_conwidth or scr_conscale changes
*/
void SCR_Conwidth_f (void)
{
	vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(Video.iWidth/scr_conscale.value) : Video.iWidth;
	vid.conwidth = Math_Clamp(320, vid.conwidth, Video.iWidth);
	vid.conwidth &= 0xFFFFFFF8;
	vid.conheight = vid.conwidth *Video.iHeight/Video.iWidth;
}
コード例 #3
0
void Sky_DrawSkyBox (void)
{
	int	i;

	for(i = 0; i < 6; i++)
	{
		if (skymins[0][i] >= skymaxs[0][i] || skymins[1][i] >= skymaxs[1][i])
			continue;

		Video_SetTexture(gSkyBoxTexture[skytexorder[i]]);

#if 1 //FIXME: this is to avoid tjunctions until i can do it the right way
		skymins[0][i] = -1;
		skymins[1][i] = -1;
		skymaxs[0][i] = 1;
		skymaxs[1][i] = 1;
#endif

		glBegin(GL_QUADS);
		Sky_EmitSkyBoxVertex (skymins[0][i], skymins[1][i], i);
		Sky_EmitSkyBoxVertex (skymins[0][i], skymaxs[1][i], i);
		Sky_EmitSkyBoxVertex (skymaxs[0][i], skymaxs[1][i], i);
		Sky_EmitSkyBoxVertex (skymaxs[0][i], skymins[1][i], i);
		glEnd();

		rs_skypolys++;
		rs_skypasses++;

		if (Fog_GetDensity() > 0 && r_skyfog.value > 0)
		{
			float *c;

			c = Fog_GetColor();

			VideoLayer_Enable(VIDEO_BLEND);
			VideoLayer_Disable(VIDEO_TEXTURE_2D);

			glColor4f(c[0], c[1], c[2], Math_Clamp(0, r_skyfog.value, 1.0f));

			glBegin(GL_QUADS);
			Sky_EmitSkyBoxVertex (skymins[0][i], skymins[1][i], i);
			Sky_EmitSkyBoxVertex (skymins[0][i], skymaxs[1][i], i);
			Sky_EmitSkyBoxVertex (skymaxs[0][i], skymaxs[1][i], i);
			Sky_EmitSkyBoxVertex (skymaxs[0][i], skymins[1][i], i);
			glEnd();

			glColor3f(1.0f,1.0f,1.0f);

			VideoLayer_Enable(VIDEO_TEXTURE_2D);
			VideoLayer_Disable(VIDEO_BLEND);

			rs_skypasses++;
		}
	}
}
コード例 #4
0
void Sky_DrawFaceQuad(glpoly_t *p)
{
	float	s,t,
			*v;
	int		i;

	glColor3f(1.0f,1.0f,1.0f);

	Video_SetTexture(gCloudTexture);

	VideoLayer_Enable(VIDEO_BLEND);
	VideoLayer_BlendFunc(VIDEO_BLEND_ONE, VIDEO_BLEND_ONE);

	glBegin(GL_QUADS);

	for (i = 0, v = p->verts[0]; i < 4; i++, v += VERTEXSIZE)
	{
		Sky_GetTexCoord(v,cv_sky_scrollspeed.value,&s,&t);

		glTexCoord2f(s,t);
		glVertex3fv(v);
	}

	glEnd();

	VideoLayer_BlendFunc(VIDEO_BLEND_DEFAULT);

	rs_skypolys++;
	rs_skypasses++;

	if(Fog_GetDensity() > 0 && r_skyfog.value > 0)
	{
		float *c = Fog_GetColor();

		VideoLayer_Disable(VIDEO_TEXTURE_2D);

		glColor4f(c[0], c[1], c[2], Math_Clamp(0.0, r_skyfog.value, 1.0));

		glBegin(GL_QUADS);
		for(i = 0,v = p->verts[0]; i < 4; i++,v += VERTEXSIZE)
			glVertex3fv(v);
		glEnd();

		glColor3f(1.0f,1.0f,1.0f);

		VideoLayer_Enable(VIDEO_TEXTURE_2D);

		rs_skypasses++;
	}

	VideoLayer_Disable(VIDEO_BLEND);
}
コード例 #5
0
static bool InputHandler_DoFovZoom(float deltaPrecise) {
	struct HacksComp* h;
	if (!KeyBind_IsPressed(KEYBIND_ZOOM_SCROLL)) return false;

	h = &LocalPlayer_Instance.Hacks;
	if (!h->Enabled || !h->CanUseThirdPersonCamera) return false;

	if (input_fovIndex == -1.0f) input_fovIndex = (float)Game_ZoomFov;
	input_fovIndex -= deltaPrecise * 5.0f;

	Math_Clamp(input_fovIndex, 1.0f, Game_DefaultFov);
	return InputHandler_SetFOV((int)input_fovIndex);
}
コード例 #6
0
/*	TODO:
		- Firstly save each iteration of our water, so we can keep track of colour etc.
		- Recalc colour for different dynamic moving lights.
*/
void Warp_DrawWaterPoly(glpoly_t *p)
{
	VideoObject_t	*voWaterPoly;
	vec3_t			vWave,vLightColour;
	float			*v;
	int				i;

	voWaterPoly = malloc(p->numverts*sizeof(VideoObject_t));
	if(!voWaterPoly)
	{
		Sys_Error("Failed to allocate water poly!\n");
		return;
	}

	v = p->verts[0];

	for(i = 0; i < p->numverts; i++,v += VERTEXSIZE)
	{
		voWaterPoly[i].vTextureCoord[0][0]	= WARPCALC(v[3],v[4]);
		voWaterPoly[i].vTextureCoord[0][1]	= WARPCALC(v[4],v[3]);
		voWaterPoly[i].vColour[3] = Math_Clamp(0, r_wateralpha.value, 1.0f);

		Math_VectorCopy(v,vWave);

		// Shitty lit water, use dynamic light points in the future...
		{
			MathVector_t	mvLightColour;

			// Use vWave position BEFORE we move it, otherwise the water will flicker.
			mvLightColour = Light_GetSample(vWave);

			Math_MVToVector(mvLightColour,vLightColour);
			Math_VectorScale(vLightColour,1.0f/200.0f,vLightColour);
			Math_VectorDivide(vLightColour,0.2f,vLightColour);
		}

		Math_VectorCopy(vLightColour,voWaterPoly[i].vColour);

		// [20/1/2013] Added in subtle water bobbing, based on this code http://www.quake-1.com/docs/quakesrc.org/26.html ~hogsy
		vWave[2] =	v[2]+
					2.0f*(float)sin(v[0]*0.025f+cl.time)*(float)sin(v[2]*0.05f+cl.time)+
					2.0f*(float)sin(v[1]*0.025f+cl.time*2.0f)*(float)sin(v[2]*0.05f+cl.time);

		Math_VectorCopy(vWave,voWaterPoly[i].vVertex);
	}

	Video_DrawObject(voWaterPoly,VIDEO_PRIMITIVE_TRIANGLE_FAN,p->numverts);

	free(voWaterPoly);
}
コード例 #7
0
/*	Each frame, update warping textures
*/
void R_UpdateWarpTextures (void)
{
	texture_t *tx;
	int i;
	float x, y, x2, warptess;

	if (r_oldwater.value || cl.bIsPaused || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
		return;

	warptess = 128.0f / Math_Clamp(3.0f, floor(r_waterquality.value), 64.0f);

	for (i=0; i<cl.worldmodel->numtextures; i++)
	{
		tx = cl.worldmodel->textures[i];
		if(!tx)
			continue;

		if(!tx->update_warp)
			continue;

		//render warp
		GL_SetCanvas (CANVAS_WARPIMAGE);
		Video_SetTexture(tx->gltexture);
		for (x=0.0; x<128.0; x=x2)
		{
			x2 = x + warptess;
			glBegin (GL_TRIANGLE_STRIP);
			for (y=0.0; y<128.01; y+=warptess) // .01 for rounding errors
			{
				glTexCoord2f (WARPCALC(x,y), WARPCALC(y,x));
				glVertex2f (x,y);
				glTexCoord2f (WARPCALC(x2,y), WARPCALC(y,x2));
				glVertex2f (x2,y);
			}
			glEnd();
		}

		//copy to texture
		Video_SetTexture(tx->warpimage);
		glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize);

		tx->update_warp = FALSE;
	}

	//if viewsize is less than 100, we need to redraw the frame around the viewport
	scr_tileclear_updates = 0;
}
コード例 #8
0
/*	Must be called whenever vid changes
	Internal use only
*/
void Screen_UpdateSize(void)
{
	float size, scale; //johnfitz -- scale

	vid.bRecalcRefDef = false;

	scr_tileclear_updates = 0; //johnfitz

// bound viewsize
	if(scr_viewsize.value < 30)
		Cvar_Set("viewsize","30");
	else if(scr_viewsize.value > 120)
		Cvar_Set("viewsize","120");

	// Bound fov
	if(scr_fov.value < 10)
		Cvar_Set ("fov","10");
	else if(scr_fov.value > 170)
		Cvar_Set ("fov","170");

	//johnfitz -- rewrote this section
	size = scr_viewsize.value;
	scale = Math_Clamp(1.0, scr_sbarscale.value, (float)glwidth / 320.0);

	if (size >= 120 || cl.intermission || scr_sbaralpha.value < 1) //johnfitz -- scr_sbaralpha.value
		sb_lines = 0;
	else if (size >= 110)
		sb_lines = 24*scale;
	else
		sb_lines = 48*scale;

	size = Math_Min(scr_viewsize.value,100)/100;
	//johnfitz

	//johnfitz -- rewrote this section
	r_refdef.vrect.width = Math_Max(glwidth * size, 96); //no smaller than 96, for icons
	r_refdef.vrect.height = Math_Min(glheight * size, glheight - sb_lines); //make room for sbar
	r_refdef.vrect.x = (glwidth - r_refdef.vrect.width)/2;
	r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2;
	//johnfitz

	r_refdef.fov_x = scr_fov.value;
	r_refdef.fov_y = CalcFovy (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);

	scr_vrect = r_refdef.vrect;
}
コード例 #9
0
void R_RenderView (void)
{
	double	time1 = 0,
			time2;

	if (r_norefresh.value)
		return;

	if (!cl.worldmodel)
		Sys_Error ("R_RenderView: NULL worldmodel");

	if(r_speeds.value)
	{
		glFinish ();
		time1 = System_DoubleTime();

		//johnfitz -- rendering statistics
		rs_brushpolys = rs_aliaspolys = rs_skypolys = rs_particles = rs_fogpolys = rs_megatexels =
		rs_dynamiclightmaps = rs_aliaspasses = rs_skypasses = rs_brushpasses = 0;
	}

	R_SetupView (); //johnfitz -- this does everything that should be done once per frame

	Video_ClearBuffer();

	//johnfitz -- stereo rendering -- full of hacky goodness
	if (r_stereo.value)
	{
		float	eyesep = Math_Clamp(-8.0f, r_stereo.value, 8.0f),
			fdepth = Math_Clamp(32.0f, r_stereodepth.value, 1024.0f);

		Math_AngleVectors(r_refdef.viewangles, vpn, vright, vup);

		// Render left eye (red)
		glColorMask(true,false,false,true);
		Math_VectorMA (r_refdef.vieworg, -0.5f * eyesep, vright, r_refdef.vieworg);
		frustum_skew = 0.5f*eyesep*NEARCLIP/fdepth;
		srand((int) (cl.time * 1000)); //sync random stuff between eyes

		R_RenderScene();

		// Render right eye (cyan)
		glClear (GL_DEPTH_BUFFER_BIT);
		glColorMask(0, 1, 1, 1);
		Math_VectorMA (r_refdef.vieworg, 1.0f * eyesep, vright, r_refdef.vieworg);
		frustum_skew = -frustum_skew;
		srand((int) (cl.time * 1000)); //sync random stuff between eyes

		R_RenderScene();

		// Restore
		glColorMask(true,true,true,true);
		Math_VectorMA (r_refdef.vieworg, -0.5f * eyesep, vright, r_refdef.vieworg);
		frustum_skew = 0.0f;
	}
	else
		R_RenderScene();
	//johnfitz

	//johnfitz -- modified r_speeds output
	time2 = System_DoubleTime();
	if(r_speeds.value == 2)
		Con_Printf(	"%3i ms  %4i/%4i wpoly %4i/%4i epoly %3i lmap %4i/%4i sky %1.1f mtex\n",
					(int)((time2-time1)*1000),
					rs_brushpolys,
					rs_brushpasses,
					rs_aliaspolys,
					rs_aliaspasses,
					rs_dynamiclightmaps,
					rs_skypolys,
					rs_skypasses,
					TexMgr_FrameUsage ());
	else if(r_speeds.value)
		Con_Printf ("%3i ms  %4i wpoly %4i epoly %3i lmap\n",
					(int)((time2-time1)*1000),
					rs_brushpolys,
					rs_aliaspolys,
					rs_dynamiclightmaps);
	//johnfitz
}