m_nBgTextureId1 is a panel animation var, in its defintion you can see
the texture file it loads. You should use an ImagePanel to draw an
image. If you must do all the work by hand then try something like this:
vgui::surface()->DrawSetTextureFile(m_nTextureID, "vgui/ammobg",
true, false);
vgui::surface()->DrawSetColor(_color[0], _color[1], _color[2],
_color[3]);
vgui::surface()->DrawTexturedRect( 0, 0, 100, 100 );
Note that _color[3] needs to be greater than zero otherwise the texture
isn't rendered (since it has no alpha value :). Also note that you call
DrawSetTextureFile() each time you paint (in case the texture was
flushed from the texture cache during the last frame, the underlying
code only reloads the file if required).
- Alfred
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gabe Volker
Sent: Thursday, March 10, 2005 3:04 PM
To: [email protected]
Subject: RE: [hlcoders] Texturing a HuD Element -- need help
Come on, somebody out there must have textured a hud element
successfully.
Any ideas?
-Gabe
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gabe Volker
Sent: Monday, March 07, 2005 5:31 PM
To: [email protected]
Subject: [hlcoders] Texturing a HuD Element -- need help
Hello again, I am still running into difficulties with texturing hud
elements.
I have tried both PaintBackgroundType 1 and 2, and my texture keeps
showing up as a black box, which when i pull up a weapon -- the box
seems to be behind it. Do I need to do a MoveToFront here?
The texture also shows up fine if I display it using an ImagePanel
element on a menu loaded from a res file. What could cause it not to
show up correctly in a hud element? Has anyone else had this?
Additionally, I did track down the m_nBgTextureId1 variable in the Panel
class, but I do not see where you can put a value into that variable.
There is no SetTexture() function, nor any other function where an
argument is passed and set as m_nBgTextureId1's value.
Here is some of my code:
CHudAmmoBg::CHudAmmoBg( const char *pElementName ) : CHudElement(
pElementName ), BaseClass(NULL, "HudAmmoBg") {
DevMsg("Ammo Bg Loaded\n");
vgui::Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );
m_nTextureID = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile( m_nTextureID, "vgui/ammobg"
, true, true);
SetHiddenBits( HIDEHUD_PLAYERDEAD );
}
void CHudAmmoBg::ApplySchemeSettings( IScheme *scheme ) {
BaseClass::ApplySchemeSettings( scheme );
SetPaintBackgroundEnabled( true );
}
void CHudAmmoBg::Paint( void )
{
vgui::surface()->DrawSetTexture( m_nTextureID );
vgui::surface()->DrawTexturedRect( 0, 0, 100, 100 ); }
I have placed the ammobg.vtf & .vmt in resource/vgui/ammobg, AND in
materials/vgui/ammobg (this is the appropriate place I believe) and the
results are the same.
Thanks,
-Gabe
Alfred Reynolds wrote:
PaintBackgroundType type 0 simply draws a filled rect of BgColor(), type
1 draws a background texture filling the entire background (drawn from
m_nBgTextureId1), type 2 draws a filled in rect of BgColor() with
rounded corners (4 textures, one on each corner). See
vgui2\controls\Panel.cpp for details.
- Alfred
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders