Shard Posted March 23, 2010 Share Posted March 23, 2010 I'm about to start working on the HUD for my Applied Project game and I wanted to know what the common ways the forum does it. We have a HUD layout [attached] where we will have different sprites for gun models, an ammo count and a two layer health meter (shields/health). From what I figure we would create a plane of some sort that would always be in front of the camera and we would draw the sprites onto the plane and make it see through but I'm not a hundred percent sure how one would go about doing this. So forum, how do you make your HUD's? Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK Link to comment Share on other sites More sharing options...
Canardia Posted March 23, 2010 Share Posted March 23, 2010 You don't need any planes. Just draw the text, images, lines, or whatever 2D elements you want. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Ending Credits Posted March 23, 2010 Share Posted March 23, 2010 You could draw to a texture and then use the texture to texture a sprite which you could parent to the camera. This is good for transparency. Quote AMD Phenom 9850 (X4 2.5GHz) | 1066MHz CL5 GEIL Black Dragon (800MHz) | Powercolor ATI 4870 1GB | DFI 790FXB-M2RSH | 24" 1920x1200 | Windows Vista 64-bit Ultimate Link to comment Share on other sites More sharing options...
Flexman Posted March 23, 2010 Share Posted March 23, 2010 This is using the 2D method, drawing to an offscreen buffer. Draw to the buffer AFTER calling Render(). Look into CreateBuffer(Width, Height, BUFFER_COLOR), the buffer it returns you can use to draw using 2D commands. Here's a little pseudo-code to give you an idea. // save current buffer tempBuffer = CurrentBuffer() ; myhudbuffer = CreateBuffer(Width, Height, BUFFER_COLOR) ; SetBuffer(myhudbuffer) ; // We can give it a variable transparency or background colour by filling with a colour and alpha SetColor(Vec4(red, green, blue, alpha)) ; DrawRect(0, 0, width, height) ; // Do lots of interesting drawing here... // even OpengGL if it takes your fancy // Done drawing so lets paste it at some screen co-ordinates DrawImage(GetColorBuffer(myhudbuffer), x, y, width, height); // restore original buffer so we don't upset anything SetBuffer(tempBuffer) ; That should be enough to get you going for your specific needs. You might want to assign a material to the buffer. Or use a smoothing filter. After creating the buffer... material = CreateMaterial() ; SetMaterialTexture(material, GetColorBuffer(myhudbuffer)) ; TextureFilter(material.GetTexture(), TEXFILTER_SMOOTH) ; Even use shaders on with the material too. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
macklebee Posted March 23, 2010 Share Posted March 23, 2010 just remember due to recent changes, the buffer you create needs to be the same size as your current buffer or you will have serious fps drop. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2010 Share Posted March 24, 2010 just remember due to recent changes, the buffer you create needs to be the same size as your current buffer or you will have serious fps drop. I don't think there is anything that would cause this. I think you mean rendering with the framework commands to a different buffer. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted March 24, 2010 Share Posted March 24, 2010 I don't think there is anything that would cause this. I think you mean rendering with the framework commands to a different buffer. yes. your'e correct. disregard comment. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted March 24, 2010 Share Posted March 24, 2010 Just load the textures and use DrawImage(). It handles transparency and all the stuff you need really. Quote Link to comment Share on other sites More sharing options...
flachdrache Posted March 24, 2010 Share Posted March 24, 2010 I use a helmet HUD which`s background is part of the nightvision/normalvision in its postprocess.frag. So i can colorise and fade or even fade it to zero. alphaHUD With that i guess ill use 3d models representing a compass, current weapon etc. - not sure about reflections on the visor because 1. dont want to obscure the players view too much 2. would better use a "complete" 3d model for such attempt and shake this model if the player got hit (atm i can shake the view within its postprocess shader). Some issues i do have with my hud is like, should i go for a more cinematic look (minimal hud - fade it in on key press, enemy arrival) or the always present "simulation" kind of HUD iam using atm - the more quiet (search and destroy) moments do require the later but would look/feel plain awful in bright sunlight. Another thing imho is that some huds are kind of overused - you know the kind of star track outlines HUD thing in light blue/green/orange. Maybe because it looks good. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
Gard Posted March 25, 2010 Share Posted March 25, 2010 but if draw with DrawImage(), it automatically draws the sprites? Or use OpenGl functions for drawing 2d images? Quote Link to comment Share on other sites More sharing options...
Flexman Posted March 25, 2010 Share Posted March 25, 2010 DrawImage() is good enough for loading a texture and putting it on screen. No need to use OpenGL for that. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Marleys Ghost Posted March 25, 2010 Share Posted March 25, 2010 DrawImage() is good enough for loading a texture and putting it on screen. No need to use OpenGL for that. Unless of course you want to rotate it. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Canardia Posted March 25, 2010 Share Posted March 25, 2010 You can also rotate images with OpenGL commands. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Marleys Ghost Posted March 25, 2010 Share Posted March 25, 2010 You can also rotate images with OpenGL commands. which was my point. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Gard Posted March 25, 2010 Share Posted March 25, 2010 but is not heavier? Because of DirectX, as far as I know, even create 2d images (which can not rotate), is heavier than create sprites with the texture of the image... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.