DrawSetTextureRGBA: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
void DrawSetTextureRGBA(int id, const unsigned char *rgba,
		
	
| m (break) | m (→Raw Data) | ||
| Line 10: | Line 10: | ||
|   	{ |   	{ | ||
|   		int offset = (j * 256 + i) * 4; |   		int offset = (j * 256 + i) * 4; | ||
|   		char *dst = ((char*)abPic) +  |   		char *dst = ((char*)abPic) + offset; | ||
|   		dst[0] = (unsigned char)255;//red |   		dst[0] = (unsigned char)255;//red | ||
| Line 18: | Line 18: | ||
|   	} |   	} | ||
|   } |   } | ||
| ===Set Up Texture ID=== | ===Set Up Texture ID=== | ||
|   	m_iHudTexture=surface()->[[CreateNewTextureID]](); |   	m_iHudTexture=surface()->[[CreateNewTextureID]](); | ||
Revision as of 22:32, 9 May 2006
void DrawSetTextureRGBA(int id, const unsigned char *rgba,
int wide, int tall, int hardwareFilter, bool forceReload)
This is a function that you should use to draw raw RGBA data to the HUD, for example when you are rendering a mask.
Sample
Initialization
unsigned char abPic[128 * 256 * 4];
Raw Data
for (j = 0; j < 128; j++) // up/down traverse
{ 
	for (i = 0; i < 256; i++) // left/right traverse
	{
		int offset = (j * 256 + i) * 4;
		char *dst = ((char*)abPic) + offset;
					
		dst[0] = (unsigned char)255;//red
		dst[1] = (unsigned char)255;//green
		dst[2] = (unsigned char)255;//blue
		dst[3] = (unsigned char)255;//alpha
	}
}
Set Up Texture ID
m_iHudTexture=surface()->CreateNewTextureID(); surface()->DrawSetTextureRGBA(m_iHudTexture,(unsigned char*)abPic,128,256,false,true); surface()->DrawSetColor(Color(255,255,255,128)); surface()->DrawTexturedRect(0,0,GetWide(),GetTall());