Trying to manipulate the way a texture is drawn on the HUD

My goal is to create a mini-map. I already know how to draw a texture on the screen, change it’s location, and re-size it.

What I’d like to know is how to restrict drawing of the mini-map texture to inside a rectangle. I want to be able to manipulate the mini-map texture without its contents leaving the mini-map rectangle.

I found


surface.DrawTexturedRectUV

on the garrysmod wiki. This almost gives me what I want. It creates a material inside a box. I can re-size the material, but I can’t change where the material is located in the box (required to have the map “follow” the player as they move.)

Ideally, I would like to be able to rotate the material as well, but I can live with just moving it around and re-sizing it. If you know a good way of doing this, your help would be appreciated.

EDIT: I did find scripts on garrysmod.org using a 3D rendering from above as a mini-map. This is not what I want.

EDIT2: Screenshot of what I have.

I think you could use the stencil part of the render library to not show anything that’s not inside the box and just reposition the map relative to the user’s position.

That might actually be just what you need. Well, maybe not. I don’t know if render is limited to the HUD. Doubt it is. But yeah.

[editline]6th February 2012[/editline]

I have a feeling ralle’s answer here is the key to your question:
http://www.facepunch.com/threads/1160598?p=34572310&viewfull=1#post34572310

One way is to make it draw inside a panel that’s parented to the hud. The panel will clip anything that is drawn outside of it.

Another way is to use render.SetScissorRect and just clip the areas where you want the texture to be drawn.

Awesome, this is what I needed. Thanks.