Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / DGDK Window doesn't render properly

Author
Message
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 26th Sep 2009 23:27
Hello there,

I had this problem when trying to implement multi-threading system to my game for the "Loading Content" section, so that I can get the progress while the game importing the game contents.

I used this class from CodeProject for the threading: http://www.codeproject.com/KB/threads/SynchronizedThreadNoMfc.aspx

and here is my code: (simplified)

the multithreading class (please see the article given above as reference):


and my main game code:


And here's a screenshot to show how it looks like:
http://img186.imageshack.us/img186/2578/wdwren.jpg

Am I doing wrong?

Any kind of help would be appreciated!

Thanks.

if(asleep) sheep++;
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 27th Sep 2009 20:35
Quote: "DarkDGK isn't thread-safe, and thus you shouldn't try using it in multiple threads simultaneously otherwise you will get very strange behaviour."


Well, Why?.

I'm just thinking that there must be some extra lines of code in the loading thread loop to update and draw the window correctly.

if(asleep) sheep++;
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 27th Sep 2009 21:07
Quote: "only one thread can access the "Pipeline" at a time - ...maybe it was objects - but - think about it - You need to be careful about calling routines that effect something that could be getting manipulated in another thread.
"


What exactly are you doing in the load resources function?

And have you tried changing the window settings within the actual thread rather than before starting the thread?

I don't have any experience using multithreading in c++ so I can't really help other than telling you that this seems like a lot of trouble just to setup a loading progress indicator.

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 28th Sep 2009 03:22
You cannot have DarkGDK in multiple threads, it is not thread safe, and wasnt designed to be run that way. You can however use multithreading in a manner similar to DarkGDK/DBPro plugins. That is to put all of your GDK code into one thread, and use other threads for intensive calculations.

For example, Dark Lights, the lightmapping pluging, uses multithreading to create its lightmap calculations. It does this by leaving GDK in the first thread and starting another thread to handle all of the lightmap calculations(which dont touch GDK at all, they are purely mathmatical calculations, the interaction between GDK and DarkLights only occurs in the main thread), it has methods to check when it's calculations thread is complete, you can do other loading or display a progress bar or whatever while it is running in the other thread.

Another good example of where multithreading could help would be in physics simulations, where you would have the actual physics sim running in another thread, while your main program did it's rendering or whatever else.

If it ain't broke.... DONT FIX IT !!!
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 1st Oct 2009 17:45
Is that mean I couldn't have a loading indicator for my game?

if(asleep) sheep++;
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 3rd Oct 2009 20:01 Edited at: 3rd Oct 2009 20:05
Anyone..

I'm just wondering how the others implemented a loading progress indicator for their games..

-----

More details:

I made my own file format to store my contents. I compressed and encrypted my game contents into a new single file. Then I just wanted to show the progress while the game is importing the contents into DGDK.

I wrapped all of my content-importer routines into some handy functions. The progress is stored in an integer variable declared in the global scope, and is updated while importing the contents -- inside the content importer functions. I also made a function that returns the loading progress. And now the only problem is, the game window doesn't render properly when running the loading-progress threads (the content importer thread and the loading indicator thread).

if(asleep) sheep++;
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 3rd Oct 2009 21:19
If you don't mind using PureBasic, PureGDK is threadsafe.

Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 5th Oct 2009 07:40
It means I have to change the entire environment only for this small matter..and that's not a really good idea..x_x

if(asleep) sheep++;

Login to post a reply

Server time is: 2024-11-20 13:26:48
Your offset time is: 2024-11-20 13:26:48