Jump to content
  • Advertisement
Sign in to follow this  
Anddos

How to make loading bars?

This topic is 2524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can i make a loading bar with DirectX?, i am thinking its going to be with sprites.
Ive had alook on google but could not find anything , just win32 ComDlg progress bars.

Share this post


Link to post
Share on other sites
Advertisement
The simplest way is to draw a quad, scaled according to the progress. If you want, you can also adjust the UV coordinates of the right hand two vertices to make it look like the texture is being revealed rather than the bar stretching (Which is what would happen if you leave the rightmost U coordiates as 1.0f when changing the vertex positions).

Share this post


Link to post
Share on other sites
There's two main parts to your question:

1. The actual drawing of the loading bars
For oldschool, non-animated loading bars you would indeed use sprites. Get yourself a ID3DXSprite by calling D3DXCreateSprite, then draw a texture with Draw. Every frame you change the size of the sprite: SetTransform to stretch it (a solid color texture stretched across) or if you have something like a sword that fills up then change the Draw's pSrcRect parameter.
Alternatively, you can use textured quads, which is considered more modern and proper.

2. Making the loading bar dynamic
Your loading bars show up when something that takes a long time is happening. You need to make your time-intensive functions be able to work a little bit at a time. For example, if you are loading something from a file, read some data in and then draw the loading bar (with its size updated). If you try to read all the data at once, the loading bar won't update until you are done reading data - it will start at 0%, do all the loading, then jump to 100%.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!