示例#1
0
void GlassSpinner::logic() {

	char buf[1024];
	
	if(cvarlink.length()>0)
		value = Cvar_GetValue(cvarlink.c_str());
	
	snprintf(buf, 1024, "%d", (int)value);
	text->setText(buf);
	
	if(Host_Milliseconds()-ticks > 300) {
		ticks = Host_Milliseconds();
		if(downSpin) {
			Cvar_SetValue(cvarlink.c_str(), CLAMP(Cvar_GetValue(cvarlink.c_str())-spinStep,min,max));
			value = CLAMP(value-spinStep, min, max);
			GlassWidget::valueChanged(gcn::SelectionEvent(this));
		} else if(upSpin) {
			Cvar_SetValue(cvarlink.c_str(), CLAMP(Cvar_GetValue(cvarlink.c_str())+spinStep,min,max));
			value = CLAMP(value+spinStep, min, max);
			GlassWidget::valueChanged(gcn::SelectionEvent(this));
		}
	}
	
	GlassContainer::logic();
}
示例#2
0
void GlassSpinner::action(const gcn::ActionEvent &ae) {
	if(ae.getId() == "up") {
		Cvar_SetValue(cvarlink.c_str(), CLAMP(Cvar_GetValue(cvarlink.c_str())+spinStep, min, max));
		value = CLAMP(value+spinStep, min, max);
	} else {
		Cvar_SetValue(cvarlink.c_str(), CLAMP(Cvar_GetValue(cvarlink.c_str())-spinStep, min, max));
		value = CLAMP(value-spinStep, min, max);
	}
	
	GlassWidget::action(ae);
	GlassWidget::valueChanged(gcn::SelectionEvent(this));
}
示例#3
0
文件: s_main.c 项目: darkshade9/aq2w
/*
 * S_Init
 */
void S_Init(void) {
	int freq, channels;
	unsigned short format;

	memset(&s_env, 0, sizeof(s_env));

	if (Cvar_GetValue("s_disable")) {
		Com_Warn("Sound disabled.\n");
		return;
	}

	Com_Print("Sound initialization...\n");

	s_rate = Cvar_Get("s_rate", "44100", CVAR_ARCHIVE | CVAR_S_DEVICE,
			"Sound sampling rate in Hz.");
	s_reverse = Cvar_Get("s_reverse", "0", CVAR_ARCHIVE,
			"Reverse left and right channels.");
	s_volume = Cvar_Get("s_volume", "1.0", CVAR_ARCHIVE,
			"Global sound volume level.");

	Cmd_AddCommand("s_restart", S_Restart_f, "Restart the sound subsystem");
	Cmd_AddCommand("s_play", S_Play_f, NULL);
	Cmd_AddCommand("s_stop", S_Stop_f, NULL);
	Cmd_AddCommand("s_list", S_List_f, NULL);

	if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
		if (SDL_Init(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	} else if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
		if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	}

	if (Mix_OpenAudio(s_rate->integer, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_QuerySpec(&freq, &format, &channels) == 0) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_AllocateChannels(MAX_CHANNELS) != MAX_CHANNELS) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	Mix_ChannelFinished(S_FreeChannel);

	Com_Print("Sound initialized %dKHz %d channels.\n", freq, channels);

	s_env.initialized = true;

	S_InitMusic();
}
示例#4
0
void IN_SetMouseSpace (mouseSpace_t mspace)
{
	if (mspace != MS_NULL) {
		if (mspace != cursorChange.prevSpace) {
			SCR_ChangeCursor(cursorChange.cursor);
		}
	}
	if (mouseSpace != MS_NULL && mouseSpace != cursorChange.prevSpace) {
		cursorChange.prevSpace = mouseSpace;
		cursorChange.cursor = Cvar_GetValue("cursor");
	}
	mouseSpace = mspace;
}
示例#5
0
float UI_GetReferenceFloat (const uiNode_t* const node, const void* ref)
{
	if (!ref)
		return 0.0;
	if (char const* const token = Q_strstart((char const*)ref, "*")) {
		if (token[0] == '\0')
			return 0.0;

		if (char const* const cvar = Q_strstart(token, "cvar:")) {
			return Cvar_GetValue(cvar);
		}

		Sys_Error("UI_GetReferenceFloat: unknown reference '%s' from node '%s'", token, node->name);
	}

	/* just get the data */
	return *(const float*) ref;
}
示例#6
0
void uiEkgNode::draw (uiNode_t *node)
{
	vec2_t size;
	vec2_t nodepos;
	const image_t *image;

	const char* imageName = UI_GetReferenceString(node, EXTRADATA(node).super.source);
	if (Q_strnull(imageName))
		return;

	UI_GetNodeAbsPos(node, nodepos);

	image = UI_LoadWrappedImage(imageName);
	if (image) {
		const int ekgHeight = node->box.size[1];
		const int ekgWidth = image->width;
		/* we have different ekg parts in each ekg image... */
		const int ekgImageParts = image->height / node->box.size[1];
		const int ekgMaxIndex = ekgImageParts - 1;
		/* we change the index of the image part in 20s steps */
		/** @todo this magic number should be replaced with a sane calculation of the value */
		const int ekgDivide = 20;
		/* If we are in the range of (ekgMaxValue + ekgDivide, ekgMaxValue) we are using the first image */
		const int ekgMaxValue = ekgDivide * ekgMaxIndex;
		int ekgValue;
		float current;

		/** @todo these cvars should come from the script */
		/* ekg_morale and ekg_hp are the node names */
		if (node->name[0] == 'm')
			current = Cvar_GetValue("mn_morale") / EXTRADATA(node).scaleCvarValue;
		else
			current = Cvar_GetValue("mn_hp") / EXTRADATA(node).scaleCvarValue;

		ekgValue = std::min((int)current, ekgMaxValue);

		EXTRADATA(node).super.texl[1] = (ekgMaxIndex - (int)(ekgValue / ekgDivide)) * ekgHeight;
		EXTRADATA(node).super.texh[1] = EXTRADATA(node).super.texl[1] + ekgHeight;
		EXTRADATA(node).super.texl[0] = -(int) (EXTRADATA(node).scrollSpeed * CL_Milliseconds()) % ekgWidth;
		EXTRADATA(node).super.texh[0] = EXTRADATA(node).super.texl[0] + node->box.size[0];
		/** @todo code is duplicated in the image node code */
		if (node->box.size[0] && !node->box.size[1]) {
			const float scale = image->width / node->box.size[0];
			Vector2Set(size, node->box.size[0], image->height / scale);
		} else if (node->box.size[1] && !node->box.size[0]) {
			const float scale = image->height / node->box.size[1];
			Vector2Set(size, image->width / scale, node->box.size[1]);
		} else {
			if (EXTRADATA(node).super.preventRatio) {
				/* maximize the image into the bounding box */
				const float ratio = (float) image->width / (float) image->height;
				if (node->box.size[1] * ratio > node->box.size[0]) {
					Vector2Set(size, node->box.size[0], node->box.size[0] / ratio);
				} else {
					Vector2Set(size, node->box.size[1] * ratio, node->box.size[1]);
				}
			} else {
				Vector2Copy(node->box.size, size);
			}
		}
		UI_DrawNormImage(false, nodepos[0], nodepos[1], size[0], size[1],
				EXTRADATA(node).super.texh[0], EXTRADATA(node).super.texh[1], EXTRADATA(node).super.texl[0], EXTRADATA(node).super.texl[1], image);
	}
}
示例#7
0
/**
 * @brief Do our own preprocessing to the shader file, before the
 * GLSL implementation calls it's preprocessor.
 *
 * "#if/#endif" pairs, "#unroll", "#endunroll", "#include", "#replace" are handled by our
 * preprocessor, not the GLSL implementation's preprocessor (except "#include" which may
 * also be handled by the implementation's preprocessor).  "#if" operates off
 * of the value of a cvar interpreted as a bool. Note the GLSL implementation
 * preprocessor handles "#ifdef" and "#ifndef", not "#if".
 * @param[in] name The file name of the shader (e.g. "world_fs.glsl").
 * @param[in] inPtr The non-preprocessed shader string.
 * @param[in,out] out The preprocessed shader string, nullptr if we don't want to write to it.
 * @param[in,out] remainingOutChars The number of characters left in the out buffer.
 * @param[in] nested If true, parsing a part of "#if" clause, so "#else" and "#endif" tokens are allowed
 * @param[in] inElse If true, parsing an "#else" clause and shouldn't expect another "#else"
 * @return The number of characters added to the buffer pointed to by out.
 */
static size_t R_PreprocessShaderR (const char* name, const char** inPtr, char* out, long* remainingOutChars, bool nested, bool inElse)
{
	const size_t INITIAL_REMAINING_OUT_CHARS = (size_t)*remainingOutChars;
	/* Keep looping till we reach the end of the shader string, or a parsing error.*/
	while (**inPtr) {
		if ('#' == **inPtr) {
			bool endBlockToken;
			(*inPtr)++;

			endBlockToken = !strncmp(*inPtr, "endif", 5);

			if (!strncmp(*inPtr, "else", 4)) {
				if (inElse) {
					/* Error in shader! Print a message saying our preprocessor failed parsing.*/
					Com_Error(ERR_DROP, "R_PreprocessShaderR: #else without #if: %s", name);
				}
				endBlockToken = true;
			}

			if (endBlockToken) {
				if (!nested) {
					/* Error in shader! Print a message saying our preprocessor failed parsing.*/
					Com_Error(ERR_DROP, "R_PreprocessShaderR: Unmatched #endif/#else: %s", name);
				}
				/* Whoever called us will have to deal with closing the block */
				return (INITIAL_REMAINING_OUT_CHARS - (size_t)*remainingOutChars);
			}

			if (!strncmp((*inPtr), "if ", 3)) {
				/* The line looks like "#if r_postprocess".*/
				(*inPtr) += 3;
				/* Get the corresponding cvar value.*/
				float f = Cvar_GetValue(Com_Parse(inPtr));
				if (f) { /* Condition is true, recursively preprocess #if block, and skip over #else block, if any */
					int size = R_PreprocessShaderR(name, inPtr, out, remainingOutChars, true, false);
					if (out) out += size;

					if (!strncmp((*inPtr), "else", 4)) {/* Preprocess and skip #else block */
						(*inPtr) +=4 ;
						R_PreprocessShaderR(name, inPtr, (char*)0, remainingOutChars, true, true);
					}
				} else {
					/* The cvar was false, don't add to out. Lets look and see if we hit a #else, or #endif.*/
					R_PreprocessShaderR(name, inPtr, (char*)0, remainingOutChars, true, false);
					if (!strncmp((*inPtr), "else", 4)) {
						int size;
						/* All right, we want to add this to out.*/
						(*inPtr) +=4 ;
						size = R_PreprocessShaderR(name, inPtr, out, remainingOutChars, true, true);
						if (out) out += size;
					}
				}
				/* skip #endif, if any (could also get here by unexpected EOF */
				if (!strncmp((*inPtr), "endif", 5))
					(*inPtr) +=5 ;
			} else if (!strncmp((*inPtr), "ifndef", 6) || !strncmp((*inPtr), "ifdef", 5)) { /* leave those for GLSL compiler, but follow #else/#endif nesting */
				int size;
				if (out) {
					if (*remainingOutChars <= 0)
						Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
					*out++ = '#';
					(*remainingOutChars)--;
				}

				size = R_PreprocessShaderR(name, inPtr, out, remainingOutChars, true, false);
				if (out) out += size;

				if (!strncmp((*inPtr), "else", 4)) {
					if (out) {
						if (*remainingOutChars <= 0)
							Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
						*out++ = '#';
						(*remainingOutChars)--;
					}
					size = R_PreprocessShaderR(name, inPtr, out, remainingOutChars, true, true);
					if (out) out += size;
				}

				if (out) {
					if (*remainingOutChars <= 0)
						Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
					*out++ = '#';
					(*remainingOutChars)--;
				}

			} else if (!strncmp((*inPtr), "include", 7)) {
				char path[MAX_QPATH];
				byte* buf = (byte*)0;
				const char* bufAsChar = (const char*)0;
				const char** bufAsCharPtr = (const char**)0;
				(*inPtr) += 8;
				Com_sprintf(path, sizeof(path), "shaders/%s", Com_Parse(inPtr));
				if (FS_LoadFile(path, &buf) == -1) {
					Com_Printf("Failed to resolve #include: %s.\n", path);
					continue;
				}
				bufAsChar = (const char*)buf;
				bufAsCharPtr = &bufAsChar;
				if (out) {
					out += R_PreprocessShaderR(name, bufAsCharPtr, out, remainingOutChars, nested, false);
				} else {
					R_PreprocessShaderR(name, bufAsCharPtr, out, remainingOutChars, nested, false);
				}
				FS_FreeFile(buf);
			} else if (!strncmp((*inPtr), "unroll", 6)) {
				/* loop unrolling */
				size_t subLength = 0;
				byte* const buffer = Mem_PoolAllocTypeN(byte, SHADER_BUF_SIZE, vid_imagePool);
				(*inPtr) += 6;
				int z = Cvar_GetValue(Com_Parse(inPtr));
				while (*(*inPtr)) {
					if (!strncmp((*inPtr), "#endunroll", 10)) {
						(*inPtr) += 10;
						break;
					}
					buffer[subLength++] = *(*inPtr)++;
					if (subLength >= SHADER_BUF_SIZE)
						Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
				}
				if (out) {
					for (int j = 0; j < z; j++) {
						for (int l = 0; l < subLength; l++) {
							if (buffer[l] == '$') {
								byte insertedLen = (j / 10) + 1;
								if (!Com_sprintf(out, (size_t)*remainingOutChars, "%d", j))
									Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
								out += insertedLen;
								(*remainingOutChars) -= insertedLen;
							} else {
								if (*remainingOutChars <= 0)
									Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
								*out++ = buffer[l];
								(*remainingOutChars)--;
							}
						}
					}
				}
				Mem_Free(buffer);
			} else if (!strncmp((*inPtr), "replace", 7)) {
				int r = 0;
				(*inPtr) += 8;
				r = Cvar_GetValue(Com_Parse(inPtr));
				if (out) {
					byte insertedLen = 0;
					if (!Com_sprintf(out, (size_t)*remainingOutChars, "%d", r))
						Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
					insertedLen = (r / 10) + 1;
					out += insertedLen;
					(*remainingOutChars) -= insertedLen;
				}
			} else {
				/* general case is to copy so long as the buffer has room */
				if (out) {
					if (*remainingOutChars <= 0)
						Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
					*out++ = '#';
					(*remainingOutChars)--;
				}
			}
		} else {
			/* general case is to copy so long as the buffer has room */
			if (out) {
				if (*remainingOutChars <= 0)
					Com_Error(ERR_FATAL, "R_PreprocessShaderR: Overflow in shader loading '%s'", name);
				*out++ = *(*inPtr);
				(*remainingOutChars)--;
			}
			(*inPtr)++;
		}
	}
	/* Return the number of characters added to the buffer.*/
	return (INITIAL_REMAINING_OUT_CHARS - *remainingOutChars);
}
示例#8
0
void	GL_RenderScene(camera_t *camera, vec3_t userpos, unsigned int sceneRenderFlags)
{
	if (!world.cl_loaded || !gfx_render.integer)
	{
		//GL_2dMode();
		return;
	}
	
	static float lasttime=0;
	camera_t sunCam;
	Pass basePass;
	worldLight_t rimLight;
	float lerp;
	float ambBoost = (vid_realbright.integer && gfx_GLSLQuality.integer<=1) ? vid_realbrightMult.value : 1.0f;
	
	basePass.setViewer(camera);
	scene_cam = camera;
	
	sunLight.origin[0] = -wr_sun_x.value;
	sunLight.origin[1] = -wr_sun_y.value;
	sunLight.origin[2] = -wr_sun_z.value;
	
	memset(&rimLight, 0, sizeof(worldLight_t));
	
	M_MultVec3(sunLight.origin, -1, rimLight.origin);
	rimLight.type = LIGHT_DIRECTIONAL;
	
	//// SHADOW MAP RENDER ////
	//shadow pass, render to texture
	if(gfx_shadow.integer && gfx_shadowQuality.integer >= 1 && gfx_GLSLQuality.integer>1)
	{
		vec3_t wmin, wmax, sunLook;

		
			
			World_GetBounds(wmin, wmax);
			//SET_VEC3(sunLook, (wmax[0]-wmin[0])*.5f, (wmax[1]-wmin[1])*.5f, 0 * .5f);
			M_MultVec3(camera->viewaxis[AXIS_FORWARD], camera->farclip*0.05, sunLook);
			M_AddVec2(sunLook, camera->origin, sunLook);
			
			Cam_DefaultCamera(&sunCam, gfx_shadowSize.integer, gfx_shadowSize.integer, 2, 8192);
		if(wr_sun_z.value < 0) {
			SET_VEC3(sunCam.origin, -wr_sun_x.value, -wr_sun_y.value, -wr_sun_z.value);
		} else {
			SET_VEC3(sunCam.origin, wr_sun_x.value, wr_sun_y.value, wr_sun_z.value);
		}
			M_Normalize(sunCam.origin);
			M_MultVec3(sunCam.origin, wmax[0], sunCam.origin);
			sunCam.origin[0]+=sunLook[0];
			sunCam.origin[1]+=sunLook[1];
			M_SubVec3(sunLook, sunCam.origin, sunCam.viewaxis[AXIS_FORWARD]);
		
			M_GetAxisFromForwardVec(sunCam.viewaxis[AXIS_FORWARD], sunCam.viewaxis);
			sunCam.fovy = 50;
			sunCam.time = camera->time;
			sunCam.fog_far=100000;
			sunCam.fog_near=99999;
			sunCam.flags |= CAM_NO_SKY;
			
			//CSM setup
			if(gfx_shadowQuality.integer >= 2) {
				shadowSplit=0;
				for(int i=0;i<gfx_shadowQuality.integer;i++) {
					cascadedPass[i].setViewer(&sunCam);
					renderer.addPass(&cascadedPass[i]);
				}
			} else {
				shadowPass.setViewer(&sunCam);
				renderer.addPass(&shadowPass);
			}
		
		
	} else if( gfx_GLSLQuality.integer > 1 ) {
		renderer.addPass(&shadowPass);
	}
	
	if(gfx_postProcEnabled.integer && gfx_GLSLQuality.integer>1 && (gfx_depthNormalPass.integer || gfx_postSSAO.integer)) {
		zPass->setViewer(camera);
		renderer.addPass(zPass);
	}
	
	basePass.setDepthFunc(GL_LEQUAL);
	basePass.setDepthMask(true);
	basePass.clearDepth(true);
	
	if(gfx_GLSLQuality.integer>1 && gfx_postProcessing.integer)
		basePass.setTarget(screenPostTarget);
	else
		basePass.setTarget(glScreen);
	
	renderer.addPass(&basePass);
	
	//// BUILD RENDER LIST ////
	
	// sun/moon
	
	if(wr_sun_z.value < 0) {
		lerp = CLAMP(fabs(-1 - cos(wr_sun_phi.value)), 0, 1);
		
		//Console_Printf("phi %f lerp %f\n", wr_sun_phi.value, lerp);
		
		//setup sun light color and ambient
		sunLight.ambient[0] = obj_ambient_r.value*ambBoost;
		sunLight.ambient[1] = obj_ambient_g.value*ambBoost;
		sunLight.ambient[2] = obj_ambient_b.value*ambBoost;
		sunLight.color[0] = obj_light0_r.value*.9;
		sunLight.color[1] = obj_light0_g.value*.9;
		sunLight.color[2] = obj_light0_b.value*.98;
		
		rimLight.ambient[0] = 0;
		rimLight.ambient[1] = 0;
		rimLight.ambient[2] = 0;
		rimLight.color[0] = lerp*obj_light1_r.value*.9;
		rimLight.color[1] = lerp*obj_light1_g.value*.9;
		rimLight.color[2] = lerp*obj_light1_b.value*.98;
	} else {
		if(wr_sun_phi.value < 5.23f && wr_sun_phi.value > 1.0472f)
			lerp = CLAMP(fabs(1-cos(3*(M_PI-wr_sun_phi.value))), 0, 1);
		else
			lerp = 0;
		
		//Console_Printf("phi %f lerp %f cos %f\n", wr_sun_phi.value, lerp, cos(3*(M_PI-wr_sun_phi.value)));
		
		//the lights need to flip
		M_MultVec3(sunLight.origin, -1, sunLight.origin);
		M_MultVec3(rimLight.origin, -1, rimLight.origin);
		
		//setup moon light color and ambient
		sunLight.ambient[0] = obj_ambient_r.value*ambBoost;
		sunLight.ambient[1] = obj_ambient_g.value*ambBoost;
		sunLight.ambient[2] = obj_ambient_b.value*ambBoost;
		sunLight.color[0] = obj_light1_r.value*.9;
		sunLight.color[1] = obj_light1_g.value*.9;
		sunLight.color[2] = obj_light1_b.value*.98;
		
		rimLight.ambient[0] = 0;
		rimLight.ambient[1] = 0;
		rimLight.ambient[2] = 0;
		rimLight.color[0] = lerp*obj_light0_r.value*.9;
		rimLight.color[1] = lerp*obj_light0_g.value*.9;
		rimLight.color[2] = lerp*obj_light0_b.value*.98;
	}
	
	renderer.addLight(&sunLight, NULL, 0);
	renderer.addLight(&rimLight, NULL, 0);
	
	// The deal here is rather than changing the code in scene.cpp to support the
	// new renderer, we just "import" all the scene data
	
	//// SCENE DATA ////
	
	lightCount = 0;
	//objects
	scenelist_t *list;
	for (list = scenelist; list; list = list->next)
	{
		//if(list->cull)
		//	continue;
		
		switch (list->obj.objtype)
		{
			case OBJTYPE_MODEL:
				GL_AddModelToLists(&list->obj);
				break;
			case OBJTYPE_LIGHT:
				GL_AddLight(0, &list->obj);
				break;
			default:
				break;
		}
	}
	
	//polys
	scenefacelist_t *flist;
	for (flist = scenefacelist; flist; flist = flist->next)
	{
		renderer.addPoly(flist, NULL, flist->shader);
	}
	
	//decals
	for (flist = scenefacelist_decals; flist; flist = flist->next)
	{
		renderer.addPoly(flist,  NULL, flist->shader);
	}
	
	//lights
	scenelightlist_t *llist;
	for (llist = scenelightlist; llist; llist = llist->next)
	{
		worldLight_t *l = &worldlights[lightCount++];
		M_CopyVec3(llist->light.color, l->color);
		M_CopyVec3(llist->light.pos, l->origin);
		renderer.addLight(l, NULL, 0);
	}
	
	//// END SCENE DATA ////
	
	//// ENVIRO ////
	
	if(!(camera->flags & CAM_NO_WORLD)) {
		
		//terrain
		if (!(scene_cam->flags & CAM_NO_TERRAIN))
			renderer.addCustomListItem(&terrainItem, false);
		
		//sprites
		for (std::list<scenelist_t*>::iterator itr = spritelist.begin(); itr != spritelist.end(); itr++)
		{
			scenelist_t *sprite = *itr;
			renderer.addSprite(sprite, &sprite->obj, sprite->obj.shader);
		}
		
		//clouds (at the back)
		if(gfx_sky.integer) {
			renderer.addCustomListItem(&cloudsItem, false);
		}
	
		if(gfx_water.integer) {
			waterItem.set(NULL,NULL,0);
			renderer.addCustomListItem(&waterItem, false);
		}
		
		//sky
		if (gfx_sky.integer) {
			if(Cvar_GetInteger("tl_suntod") <= 1440) 
				sky.setTimeofDay(Cvar_GetValue("tl_suntod")/1440.0f);
			else
				sky.setTimeofDay((Cvar_GetValue("tod_sunminute"))/1440.0f);
			
			//renderer.addListItem(&clouds, false);
			renderer.addCustomListItem(&sky, false);
		}
		
		//// FX LAYER ////
		
		//polys
		for (flist = scenefxfacelist; flist; flist = flist->next)
		{
			renderer.addPolyFX(flist, NULL, flist->shader);
		}
		
		//decals
		for (flist = scenefxfacelist_decals; flist; flist = flist->next)
		{
			renderer.addPolyFX(flist,  NULL, flist->shader);
		}
		
		//sprites
		for (std::list<scenelist_t*>::iterator itr = spritefxlist.begin(); itr != spritefxlist.end(); itr++)
		{
			scenelist_t *sprite = *itr;
			renderer.addSpriteFX(sprite, &sprite->obj, sprite->obj.shader);
		}
	}
	
	//// RENDER ////
	
	renderer.render(camera->time-lasttime);
	
	lasttime = camera->time;
}
示例#9
0
void GlassViewer::draw(gcn::Graphics *g) {
	sceneobj_t sc;
	int x,y;
	vec4_t rect;
	if(isCulled(g))
		return;
	
	getAbsolutePosition(x, y);
	
	gcn::Rectangle r = g->getCurrentClipArea();
	
	//setup camera
	Cam_DefaultCamera(&cam, r.width, r.height, 0.1, Cvar_GetValue("gfx_farclip"));
	cam.fovx = fov;
	cam.fog_near = cam.fog_far = 10000;
	cam.x = x;
	cam.y = Vid_GetScreenH()-y-mDimension.height;
	cam.use_viewport = true;
	Cam_CalcFovy(&cam);
	//Cam_SetDistance(&cam, 1000);
	
	M_CopyVec3(target, cam.viewaxis[AXIS_FORWARD]);
	M_GetAxisFromForwardVec(cam.viewaxis[AXIS_FORWARD], cam.viewaxis);
	M_CopyVec3(camPos, cam.origin);
	
	cam.time = Host_Milliseconds()/1000.0f;
	
	SET_VEC4(rect, 0, 0, r.width, r.height);
	
	if(mOpaque) {
		g->setColor(getBackgroundColor());
		g->fillRectangle(gcn::Rectangle(0,0,getWidth(),getHeight()));
	}
	
	Scene_Clear();
	
	Scene_SetFrustum(&cam, rect);
	
	if(model!=(residx_t)-1) {
		CLEAR_SCENEOBJ(sc);
		
		//SET_VEC3(cam.viewaxis[AXIS_FORWARD], target[0]-camPos[0], target[1]-camPos[1], target[2]-camPos[2]);
		//M_Normalize(cam.viewaxis[AXIS_FORWARD]);
		//M_GetAxisFromForwardVec(cam.viewaxis[AXIS_FORWARD], cam.viewaxis);
		M_MultVec3(cam.viewaxis[AXIS_FORWARD], -distance, cam.origin);
		
		M_AddVec3(cam.origin, camPos, cam.origin);
		
		sc.model = model;
		sc.skeleton = &skeleton;
		sc.flags = SCENEOBJ_NEVER_CULL | SCENEOBJ_USE_AXIS;
		SET_VEC3(sc.rimColor, 1.0, 1.0, 1.0);
		
		if(animState.size() > 0) {
			Geom_BeginPose(sc.skeleton, sc.model);
			Geom_SetBoneAnim("", animState.c_str(), Host_Milliseconds(), Host_Milliseconds(), 0, 0);
			Geom_EndPose();
		}
		
		M_CopyVec3(position, sc.pos);
		
		sc.angle[0] = sc.angle[1] = 0;
		sc.angle[2] = angle;
		M_GetAxis(sc.angle[0], sc.angle[1], sc.angle[2], sc.axis);
		
		if(mAutoRotate)
			angle = int(angle + dAngle) % 360;
		
		if(angle<0)
			angle +=360;
		
		Scene_AddObject(&sc);
	}
	
	if(!world) {
		cam.fog_near = 9000;
		cam.fog_far = 10000;
		cam.flags |= CAM_NO_WORLD;
	} else {
		cam.flags &= ~CAM_NO_WORLD;
		cam.fog_near = Cvar_GetValue("gfx_fog_near");
		cam.fog_far = Cvar_GetValue("gfx_fog_far");
		WO_RenderEmitters(cam.origin);
		WL_RenderLights(cam.origin);
	}
	
	//FIXME: add post-processing with viewers
	int old = gfx_postProcessing.integer;
	
	Cvar_SetVarValue(&gfx_postProcessing, 0);
	
	GL_EndFrame();
	
	GL_Enable(GL_CULL_FACE);
	
	Scene_Render(&cam, cam.origin, 0);
	
	GL_Disable(GL_CULL_FACE);
	
	GL_BeginFrame();
	Cvar_SetVarValue(&gfx_postProcessing, old);
	
	if(animState.size() > 0 && model != (residx_t)-1)
		Geom_FreeSkeleton(&skeleton);
	
}
示例#10
0
void uiGeoscapeNode::draw (uiNode_t* node)
{
    vec2_t screenPos;

    geoscapeNode = node;
    UI_MAPEXTRADATA(node).flatgeoscape = cl_3dmap->integer == 0;
    UI_MAPEXTRADATA(node).radarOverlay = Cvar_GetValue("geo_overlay_radar");
    UI_MAPEXTRADATA(node).nationOverlay = Cvar_GetValue("geo_overlay_nation");
    UI_MAPEXTRADATA(node).xviOverlay = Cvar_GetValue("geo_overlay_xvi");
    UI_MAPEXTRADATA(node).ambientLightFactor = cl_3dmapAmbient->value;
    UI_MAPEXTRADATA(node).mapzoommin = cl_mapzoommin->value;
    UI_MAPEXTRADATA(node).mapzoommax = cl_mapzoommax->value;

    UI_GetNodeAbsPos(node, UI_MAPEXTRADATA(node).mapPos);
    Vector2Copy(node->box.size, UI_MAPEXTRADATA(node).mapSize);
    if (!UI_MAPEXTRADATACONST(node).flatgeoscape) {
        /* remove the left padding */
        UI_MAPEXTRADATA(node).mapSize[0] -= UI_MAPEXTRADATACONST(node).paddingRight;
    }

    /* Draw geoscape */
    UI_GetNodeScreenPos(node, screenPos);
    UI_PushClipRect(screenPos[0], screenPos[1], node->box.size[0], node->box.size[1]);

    if (UI_MAPEXTRADATACONST(node).smoothRotation) {
        if (UI_MAPEXTRADATACONST(node).flatgeoscape)
            smoothTranslate(node);
        else
            smoothRotate(node);
    }

    geoscapeData_t& data = *UI_MAPEXTRADATA(node).geoscapeData;
    data.geoscapeNode = node;
    GAME_DrawMap(&data);
    if (!data.active)
        return;

    const char* map = data.map;
    date_t& date = data.date;

    /* Draw the map and markers */
    if (UI_MAPEXTRADATACONST(node).flatgeoscape) {
        /* the last q value for the 2d geoscape night overlay */
        static float lastQ = 0.0f;

        /* the sun is not always in the plane of the equator on earth - calculate the angle the sun is at */
        const float q = (date.day % DAYS_PER_YEAR + (float)(date.sec / (SECONDS_PER_HOUR * 6)) / 4) * 2 * M_PI / DAYS_PER_YEAR - M_PI;
        if (lastQ != q) {
            calcAndUploadDayAndNightTexture(node, q);
            lastQ = q;
        }
        R_DrawFlatGeoscape(UI_MAPEXTRADATACONST(node).mapPos, UI_MAPEXTRADATACONST(node).mapSize, (float) date.sec / SECONDS_PER_DAY,
                           UI_MAPEXTRADATACONST(node).center[0], UI_MAPEXTRADATACONST(node).center[1], 0.5 / UI_MAPEXTRADATACONST(node).zoom, map,
                           data.nationOverlay, data.xviOverlay, data.radarOverlay, r_dayandnightTexture, r_xviTexture, r_radarTexture);

        GAME_DrawMapMarkers(node);
    } else {
        bool disableSolarRender = false;
        if (UI_MAPEXTRADATACONST(node).zoom > 3.3)
            disableSolarRender = true;

        R_EnableRenderbuffer(true);

        R_Draw3DGlobe(UI_MAPEXTRADATACONST(node).mapPos, UI_MAPEXTRADATACONST(node).mapSize, date.day, date.sec,
                      UI_MAPEXTRADATACONST(node).angles, UI_MAPEXTRADATACONST(node).zoom, map, disableSolarRender,
                      UI_MAPEXTRADATACONST(node).ambientLightFactor, UI_MAPEXTRADATA(node).nationOverlay,
                      UI_MAPEXTRADATA(node).xviOverlay, UI_MAPEXTRADATA(node).radarOverlay, r_xviTexture, r_radarTexture,
                      true);

        GAME_DrawMapMarkers(node);

        R_DrawBloom();
        R_EnableRenderbuffer(false);
    }

    UI_PopClipRect();
}
示例#11
0
void GlassSpinner::linkCvar(const char *v) {
	cvarlink = v;
	value = Cvar_GetValue(cvarlink.c_str());
}