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: 5066
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 05 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
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (10 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!