Advertisement

Loading data

Started by March 15, 2003 02:45 PM
13 comments, last by cavendish 21 years, 11 months ago
Hey! I''d like to put you a question (and no, I am not a newbie)... I want to make an application that shows a 3D effect while/untill the application data is loading ... The effect is supposed to work at about 30 fps (one frame is supposed to take 0.03 s)... If per frame, it takes some time to draw the 3D effect, I want to load some data during the time left (I mean load data untill the 0.03 s limit for the frame is achieved) and remember where i stopped... I think there must be something like this allready implemented in Windows, but I just never heard of it. So, if there allready is something like this, could you help me?... If Windows doesn''t support it, can you point out some code? The application is in C++, uses OpenGL and is for Windows, and yes, I have a card that can achieve 30 fps ... Check out Stargate
--------Whatever
anybody?

Check out Stargate
--------Whatever
Advertisement
I''m not really sure what you are trying to achieve here, why don''t you just use a thread to load the data in the background ?
Ickno, go on with yr ideea plz.. I didn''t use loading in the background yet

Check out Stargate
--------Whatever
Cut up everything you want to load into small sections, draw the object, and use a loop to load each section one at a time while the time has not passed 0.03s.
That is not human, i would have to make 100 sections :O

Check out Stargate
--------Whatever
Advertisement
Not the easiest solution, but spawn a new thread for doing the processing of data, and give it a lower priority than your rendering code. Just about the only thing I can think of off the top of my head.

- sighuh?
- sighuh?
Well, how exactly do I spawn a new thread and give it lower priority? And no, I really don''t know ...

Check out Stargate
--------Whatever
Take a look at flipcode. They have good tutorials on multithreading.
quote:
Original post by cavendish
Well, how exactly do I spawn a new thread and give it lower priority? And no, I really don''t know ...

Check out Stargate

Sorry for the slow response...got distracted.
If you''re using MSVC++ and don''t mind using MFC (not portable), you can do it one of several ways. Take a look at either deriving your data-parsing class from CWinThread, or using AfxBeginThread. You should also notice that one of the possible arguments for your new thread is it''s priority level.
CWinThread* AfxBeginThread(...)UINT MyThreadProc( LPVOID pParam ){    CMyObject* pObject = (CMyObject*)pParam;    if (pObject == NULL ||        !pObject->IsKindOf(RUNTIME_CLASS(CMyObject)))    return 1;   // if pObject is not valid    // do something with ''pObject''    return 0;   // thread completed successfully}// inside a different function in the program...pNewObject = new CMyObject;AfxBeginThread(MyThreadProc, pNewObject);... 

If you would rather be good and cross platform, let me know...it''s a bit more complex that way. If you''re already bound up in MSVC++, then you might as well use MFC for now.
Hope this helps.

- sighuh?
- sighuh?

This topic is closed to new replies.

Advertisement