Welcome, Guest! Login | Register

Higher Res for VGUI Images [Print this Article]
Posted by: -+Arcadian+-
Date posted: Jun 17 2003
User Rating: N/A
Number of views: 2429
Number of comments: 0
Description: Quick & Simple
This article shows you how to quickly change the default 320 & 640 .tga image sizes to fit whatever resolution a player is using. This does not tell you how to use VGUI at all, you should use the tutorials found here for that.

The default vgui in half-life is set up to use the same images for any resolution over 640x480. So if you had your resolution set to say 1024x768 the images would look considerably smaller. What if you wanted them to be bigger & look better? Well it's simple.

First off let me explain something you should already know if working with VGUI. The code prepends a "320_" or "640_" to whatever image you use. Like for example if your .tga name is "MyImage" (in the code) the code will look for "640_MyImage.tga" in the gfx/vgui folder. With that in mind...

Go into vgui_CustomObjects.cpp

Look for:
 CODE  

// Get the name of TGA file, without a gamedir
char *GetTGANameForRes(const char *pszName)
{
    int i;
    char sz[256];
    static char gd[256];
    if (ScreenWidth < 640)
        i = 320;
    else
        i = 640;
    sprintf(sz, pszName, i);
    sprintf(gd, "gfx/vgui/%s.tga", sz);
    return gd;
}



As you can see .. the if (ScreenWidth < 640) tells the game if the screen width is less than 640 to prepend 320 to the .tga file. All we need to do is remove a few lines and and change one of them so the code will look for other images at higher resolutions.

Change that code to:
 CODE  

// Get the name of TGA file, without a gamedir
char *GetTGANameForRes(const char *pszName)
{
    static char gd[256];
    sprintf(sz, pszName, ScreenWidth); //Use the resolution
    sprintf(gd, "gfx/vgui/%d_%s.tga", ScreenWidth, sz);
    return gd;

}


This tells the code to look for images depending on your resolution.. if your res is 800x600 it will use the 800_MyImage.tga, or if higher it will use the 1024_MyImage.tga.

[EDIT: Mind you, you're going to have to create TGAs for each possible resolution in order for nobody to be missing out. If you have a lot of TGA images, this could become a pain, and take a lot of memory.]

Pretty simple stuff.. and you can easily change it to go higher if you wanted. Maybe now people wont have such small HUDs when the screensize is 1024 user posted image
Any questions you can find me in #wavelength on gamesnet.

Rate This Article
This article has not yet been rated.

You have to register to rate this article.
User Comments

No User Comments

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
4 People Online (27 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!