示例#1
0
static FDynamicColormap *CreateSpecialLights (PalEntry color, PalEntry fade, int desaturate)
{
	// GetSpecialLights is called by the scene worker threads.
	// If we didn't find the colormap, search again, but this time one thread at a time
	static std::mutex buildmapmutex;
	std::unique_lock<std::mutex> lock(buildmapmutex);

	// If this colormap has already been created, just return it
	// This may happen if another thread beat us to it
	for (FDynamicColormap *colormap = &NormalLight; colormap != NULL; colormap = colormap->Next)
	{
		if (color == colormap->Color &&
			fade == colormap->Fade &&
			desaturate == colormap->Desaturate)
		{
			return colormap;
		}
	}

	// Not found. Create it.
	FDynamicColormap *colormap = new FDynamicColormap;
	colormap->Next = NormalLight.Next;
	colormap->Color = color;
	colormap->Fade = fade;
	colormap->Desaturate = desaturate;
	colormap->Maps = new uint8_t[NUMCOLORMAPS*256];
	colormap->BuildLights ();

	// Make sure colormap is fully built before making it publicly visible
	std::atomic_thread_fence(std::memory_order_release);
	NormalLight.Next = colormap;

	return colormap;
}
示例#2
0
FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturate)
{
	FDynamicColormap *colormap;

	// If this colormap has already been created, just return it
	for (colormap = &NormalLight; colormap != NULL; colormap = colormap->Next)
	{
		if (color == colormap->Color &&
			fade == colormap->Fade &&
			desaturate == colormap->Desaturate)
		{
			return colormap;
		}
	}

	// Not found. Create it.
	colormap = new FDynamicColormap;
	colormap->Next = NormalLight.Next;
	colormap->Color = color;
	colormap->Fade = fade;
	colormap->Desaturate = desaturate;
	NormalLight.Next = colormap;

	if (Renderer->UsesColormap())
	{
		colormap->Maps = new BYTE[NUMCOLORMAPS*256];
		colormap->BuildLights ();
	}
	else colormap->Maps = NULL;

	return colormap;
}
示例#3
0
void R_SetDefaultColormap (const char *name)
{
	if (strnicmp (fakecmaps[0].name, name, 8) != 0)
	{
		int lump, i, j;
		BYTE map[256];
		BYTE unremap[256];
		BYTE remap[256];

		lump = Wads.CheckNumForName (name, ns_colormaps);
		if (lump == -1)
			lump = Wads.CheckNumForName (name, ns_global);

		// [RH] If using BUILD's palette, generate the colormap
		if (lump == -1 || Wads.CheckNumForFullName("palette.dat") >= 0 || Wads.CheckNumForFullName("blood.pal") >= 0)
		{
			Printf ("Make colormap\n");
			FDynamicColormap foo;

			foo.Color = 0xFFFFFF;
			foo.Fade = 0;
			foo.Maps = realcolormaps;
			foo.Desaturate = 0;
			foo.Next = NULL;
			foo.BuildLights ();
		}
		else
		{
			FWadLump lumpr = Wads.OpenLumpNum (lump);

			// [RH] The colormap may not have been designed for the specific
			// palette we are using, so remap it to match the current palette.
			memcpy (remap, GPalette.Remap, 256);
			memset (unremap, 0, 256);
			for (i = 0; i < 256; ++i)
			{
				unremap[remap[i]] = i;
			}
			// Mapping to color 0 is okay, because the colormap won't be used to
			// produce a masked texture.
			remap[0] = 0;
			for (i = 0; i < NUMCOLORMAPS; ++i)
			{
				BYTE *map2 = &realcolormaps[i*256];
				lumpr.Read (map, 256);
				for (j = 0; j < 256; ++j)
				{
					map2[j] = remap[map[unremap[j]]];
				}
			}
		}

		uppercopy (fakecmaps[0].name, name);
		fakecmaps[0].blend = 0;
	}
}
示例#4
0
void FDynamicColormap::RebuildAllLights()
{
	FDynamicColormap *cm;

	for (cm = &NormalLight; cm != NULL; cm = cm->Next)
	{
		if (cm->Maps == NULL)
		{
			cm->Maps = new uint8_t[NUMCOLORMAPS*256];
			cm->BuildLights ();
		}
	}
}
示例#5
0
void FDynamicColormap::RebuildAllLights()
{
	if (Renderer->UsesColormap())
	{
		FDynamicColormap *cm;

		for (cm = &NormalLight; cm != NULL; cm = cm->Next)
		{
			if (cm->Maps == NULL)
			{
				cm->Maps = new BYTE[NUMCOLORMAPS*256];
				cm->BuildLights ();
			}
		}
	}
}