DrawSetTextureRGBA
Jump to navigation
Jump to search
void ISurface::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
#define HEIGHT 256 #define WIDTH 256 #define PIXEL_BYTES 4 // RGBA (never changes) unsigned char abPic[ HEIGHT * WIDTH * PIXEL_BYTES ];
Raw Data
for (y = 0; y < HEIGHT; y++) // up/down traverse { for (x = 0; x < WIDTH; x++) // left/right traverse { int offset = (x + y * WIDTH) * PIXEL_BYTES; 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());