No announcement yet.

UT2K3 Canvas resolution issue

  • Filter
  • Time
  • Show
Clear All
new posts

    UT2K3 Canvas resolution issue

    I have a problem when the user changes their screen resolution. All of the HUD graphics are shifted around (their x/y co-ordinates aren't in the same place.)

    I'm wondering if there's any code/function in the HUD/Canvas classes that would keep the location of the HUD in the right place when a resolution changes.

    This would be really helpful if anyone has an answer. Thanks!

    just use math..

    local float ScreenScale; // you could add a X and Y version of this if you allow nonuniform resolution scaling..
    local float NewX, NewY;

    // dont' forget to cast SizeX to a float, it's an int by default
    ScreenScale = float(Canvas.SizeX) / 640.0; // or whatever screensize it already works in.
    NewX = DesiredX * ScreenScale;
    NewY = DesiredY * ScreenScale;

    so, if your current resolution was 640x480, and you had a texture at coordinates (40, 10).
    Lets say you change your resolution to 800x600. using the information above, 800.0/640.0 = 1.25, so 1.25 is the scale factor. Using our new scale factor, we can get the new coordinates
    40 * 1.25 = 50
    10 * 1.25 = 12.5

    (50, 12.5)

    if you need to scale your texture out, you'd use the same method..
    hope this helps.


      I encountered a similar might be misusing the DrawPivots of your HUD icons, they work in relation to the entire screen and not particular icons..

      For instance icons draw with DP_UpperMiddle will be moved around as if they were above the crosshair, so you should ONLY EVER use DP_UpperMiddle for icons directly above the crosshair and so on.

      It's unnecesarily confusing and a pain in the butt (I had to start my HUD from scratch when I first figured it out) but that's the way it is unfortunatly. (I'd love to get my hands on whoever coded the new HUD system )


        B.SetPos(B.ClipX * 0.425, B.ClipY * 0.9);
        	B.DrawText("Whatever Text you want here");
        B being the canvas

        This is what i use in my mutator. This way it adjusts no matter what your resolution is. enjoy =-)


          hey great

          Thanks guys, I'll try those out and see what works!