Jump to content
  • Advertisement
Sign in to follow this  
sensate

OpenGL Load Screens with Direct3d

This topic is 4488 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

Hi All. I'm working on creating a loading screen UI component for direct3d. My current understanding for most engines is that the engine sets a refresh() event much like windows does with the GDI, or an invalidaterect that calls the beginscene, endscene of the loadscreen (all in the same thread). This ensures that the direct3d device is not being used to create vertex buffers AND render the scene from different threads. This seems messy to me, and a crap solution if you want an animated / slightly complex loadscreen. What I'd like to know is: What is the usual process for rendering and loading data under direct3d at the same time? Should I create two seperate devices for the same window and use Device A to render the load screen while device b loads and prepares the game scene for rendering? Is there any more intuitive a way to do this? (Keep in mind I don't want to create a multithreaded device). Opengl was so much kinder to me in this regard :p. Thanks everyone.

Share this post


Link to post
Share on other sites
Advertisement
hi,

what's about this:


load()
{
while( not_loaded )
{
load_some_stuff();
refresh_load_screen();
}
}

I Think this will work for both API's DirectX and OpenGL

Marc

Share this post


Link to post
Share on other sites
I'm planning on rendering a particle system in the load screen. It needs constant and consistant time step updates.

Can I load textures and create vertex buffers in one thread while the device renders in another thread if the device is multithreaded?

Share this post


Link to post
Share on other sites
There is no problem to load and draw stuff under DX in the same time, but you need to create the device with multithreading flag. This is the easy way.

However it is suggested not the create the dx device with multithreading flag, since it affects performance.

Multithreading is essential for creating an interactive loading screen. To combine the last suggestion and this, you could have a loading thread which only loads things to memory. When the resources are actually needed you can create them from the loaded data or you can hint the DX about some resource to be created (which can be done from the primary thread).

Loading would go something like this:

StartLoaderThread();

while(loading)
{
DrawLoadingScreen();
Sleep(40); //wait around 40ms to get around 25 fps
}

It is important to use the sleep at this point because otherwise you'll have two threads competing for the cpu clocks and it'll make your loading quite slow.

Share this post


Link to post
Share on other sites
I would make it multithreaded, one thread renders, the other loads.

Quote:

D3DCREATE_MULTITHREADED
Indicates that the application requests Direct3D to be multithread safe. This makes a Direct3D thread take ownership of its global critical section more frequently, which can degrade performance


Another idea would be to load part of the data, then update the progress bar. Load some more, update... repeat.

Share this post


Link to post
Share on other sites
Thankyou for your replies...

Just a couple of more questions...

Can you have two devices for the same HWND at the same time?
(I've never tried).

Has microsoft ever elaborated why the multithreaded device is slow?

Thankyour for your suggestions. I'll deliberate.

From what I've read from you guys, the multthreaded device is slow, and the suggestions of piecewise loading chunks of data doesn't seem very appealing...

I'm thinking of going with a separate device for the load screen, to keep the component reusable and clean...

What I need to know is if there are any arguments you can think of against this... Thankyou.


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!