File: SWTri_TexelARGB.cpp

package info (click to toggle)
libtuxcap 1.4.0.dfsg2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,172 kB
  • ctags: 5,897
  • sloc: cpp: 43,203; ansic: 3,095; python: 774; objc: 242; makefile: 100; xml: 87
file content (40 lines) | stat: -rw-r--r-- 1,289 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file is included by SWTri.cpp and should not be built directly by the project.
{
	int premult;
	#if defined(MOD_ARGB) && defined(GLOBAL_ARGB)
	{
		premult = ((globalDiffuse.a*a)>>24);
		alpha = (alpha * premult) >> 8;
		tex =	((((tex&0xff0000)*((globalDiffuse.r*r)>>24))>>8)&0xff0000)|
			((((tex&0x00ff00)*((globalDiffuse.g*g)>>24))>>8)&0x00ff00)|
			((((tex&0x0000ff)*((globalDiffuse.b*b)>>24))>>8)&0x0000ff);
	}
	#elif !defined(MOD_ARGB) && defined(GLOBAL_ARGB)
	{
		premult = globalDiffuse.a;
		alpha = (alpha * premult) >> 8;
		tex =	((((tex&0xff0000)*globalDiffuse.r)>>8)&0xff0000)|
			((((tex&0x00ff00)*globalDiffuse.g)>>8)&0x00ff00)|
			((((tex&0x0000ff)*globalDiffuse.b)>>8)&0x0000ff);
	}
	#elif defined(MOD_ARGB) && !defined(GLOBAL_ARGB)
	{
		premult = a>>16;
		alpha = (alpha * premult) >> 8;
		tex =	((((tex&0xff0000)*(r>>16))>>8)&0xff0000)|
			((((tex&0x00ff00)*(g>>16))>>8)&0x00ff00)|
			((((tex&0x0000ff)*(b>>16))>>8)&0x0000ff);
	}
	#endif

	// linear blend expects pixel to already be premultiplied by alpha
	#if defined(LINEAR_BLEND) && (defined(MOD_ARGB) || defined(GLOBAL_ARGB))
	{
		int r = (((tex&0xff0000)*premult)>>8)&0xff0000;
		int g = (((tex&0x00ff00)*premult)>>8)&0x00ff00;
		int b = (((tex&0x0000ff)*premult)>>8)&0x0000ff;
		tex = r|g|b;
	}	
	#endif
}