Jump to content


Photo

Best method for HUD


  • Please log in to reply
5 replies to this topic

#1 vann

vann

    GMC Member

  • GMC Member
  • 353 posts
  • Version:GM:Studio

Posted 15 April 2012 - 02:28 PM

Given d3d_set_ortho isnt cross platform compatible, I was wondering how people are approaching drawing overlays/HUDs, particularly in games where the same view is zooming the rest of the room.

Having certain objects offset the zoom with draw_sprite_ext works ok for sprites, but not for fonts afaik.

So is it surfaces? drawing everything in your overlay to a surface, then using draw_surface_ext at a scale factor which counters the view scaling?

Thanks for any contributions.
  • 0

#2 Exe_Mas

Exe_Mas

    GMC Member

  • GMC Member
  • 150 posts

Posted 15 April 2012 - 03:11 PM

draw_sprite(sprite,img,view_xview[0]+100,view_yview[0]+200).
The same with text.
Is that?
  • 0

#3 vann

vann

    GMC Member

  • GMC Member
  • 353 posts
  • Version:GM:Studio

Posted 15 April 2012 - 03:41 PM

draw_sprite(sprite,img,view_xview[0]+100,view_yview[0]+200).
The same with text.
Is that?


Exe_Mas, thanks for your reply.
That would have the text and sprites follow the view, but it wont scale them if the view port is not 1:1 with the view size.

Edited by vann, 15 April 2012 - 03:42 PM.

  • 0

#4 Centauri

Centauri

    GMC Member

  • GMC Member
  • 116 posts

Posted 15 April 2012 - 04:26 PM

If you use Exe_Mas's solution doesn't GM just automatically scale the view onto the port? If not, and you are drawing the HUD outside the view or on top of it, can't you use the port and view size variables to scale?

i.e.
xscale = view_wport/view_wview;
yscale = view_hport/view_hview;

Or for the various HUD components:
// For sprites
draw_sprite_ext(sprite, image, x, y, view_wport/view_wview, view_hport/view_hview, rotation, color, alpha);
// For text
draw_text_ext_transformed(x, y, string, sep, width, view_wport/view_wview, view_hport/view_hview, rotation);
// Or if you draw all the text and sprites onto a surface
draw_surface_ext(surface, x, y, view_wport/view_wview, view_hport/view_hview, rotation, color, alpha);

Edited by Centauri, 15 April 2012 - 04:27 PM.

  • 0

#5 vann

vann

    GMC Member

  • GMC Member
  • 353 posts
  • Version:GM:Studio

Posted 16 April 2012 - 09:40 AM

Centauri,

Actually, the key bit here I hadn't spotted before was the text function
draw_text_ext_transformed

With that in mind, the solution Exe_Mas eludes to would work fine. So thank you both.
Ill consider the surface solution too, but I try to have some fall back options for anything relying on surfaces still.
  • 0

#6 vann

vann

    GMC Member

  • GMC Member
  • 353 posts
  • Version:GM:Studio

Posted 23 April 2012 - 06:53 AM

I should say, I tested using draw_text_transformed & when using it to counter-act the view scaling, it produces really terrible results.

It's not hugely suprising, but it means theres no way thats an option for HUDs when the view is being scaled or manipulated in some way.

Back to surfaces as this stage if it needs to be cross platform.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users