Jump to content

Arena

  • entries
    5
  • comments
    21
  • views
    9,266

Multi-threading woe's


xtreampb

4,697 views

 Share

So I attempted to thread out my application and i think OpenGL got angry at me. This is what some simple threading to test if i can spin off threads in my C++ back end (which would be great). However I don't think this is possible so loading assets in a linear fashion seems to be my only option. This may be a product of early optimization.

 

Along with finding out that I can't multi-thread, it became that when i use the crawler prefab, the game will crash when it loads. I don't get any errors in the editor or in my C code so i have know idea what is going on. I just may have to create a new project. I still want to use the pivots to mark spawn locations. I'm having some issues creating the logic to be used to set the unique spawn options. Because the script will be used for each spawn, i can't use the global stack to push an options table because they will over right one another. I'm thinking about creating a C++ function that lua calls that will send a table as a parameter and then the C++ will use this along with some constraints to determine what it should be, if anything. From there the object will be loaded and placed in the world.

 Share

16 Comments


Recommended Comments

What are you trying to do with threading? Load stuff in real-time or do some sort of loading screen while the map loads?

Link to comment

So there should be a callback function to the map load function. I believe this will be called as entities are being loaded. If you put your drawing updating inside this where you draw to the screen (the stuff that's inside App::Loop()) then you should be able to have a loading screen that updates as your map is loading. It might not be the smoothest but it could be something.

 

I believe anything you do with LE entities needs to be on the same thread that LE was initialized on.

Link to comment

I never had succes with multithreaded loading screens. You can show a screen like Rick says, but a dynamic progress bar (or anything moving for that matter) is out of the question.

  • Upvote 1
Link to comment

Aggror, if you can show a screen couldn't you show some sort of moving progress bar? I mean it would probably not be fluid but you should be able to get something moving on screen right?

  • Upvote 1
Link to comment

Nah it is a simple but 'hackisch' way. You display an image as loading screen, then the next frame you load the map, before the screen is updated. After the map loading, you remove the image being drawn. So a moving or rotaing image is not possible.

Link to comment

Can't you just call the map.load hook every entity to update an animated icon? It would be like this script http://leadwerks.wikidot.com/wiki:entityindexer but instead of indexing them you are manually drawing to the screen and syncing it. It would look jerky but you know its loading. Also if you know how many entities there are in the level ahead of time (say you wrote a loading script to count it for you and stored the info in a file) you can do a proper progress bar.

Link to comment

Yeah, I think if you take the 2D drawing logic that's in App:Loop() and place it in the map loading hook you could get a moving image.

Link to comment

there is as map has a top level entity. you then get the number of children from of that entity. Cant quite remember the commands but i remember something along those lines.

Link to comment

Wouldn't that be after the map is already loaded though? You'd need this count before you load the map to make an effective progress bar.

Link to comment

for what i was doing by populating the map with pivots wouldn't take long to load the map then as each entity is loaded update the loading screen.

Link to comment

Maps in Leadwerks 3 do not have a top-level entity.

 

Trying to thread things that were not meant to be threaded will be a guaranteed disaster, really. These commands are not meant to be called from different threads, unless you want to do all your own thread locking, which is insanely complex. And probably impossible without the engine source code.

  • Upvote 1
Link to comment

Any chance on getting a function call that returns how many entities are in the map without actually loading them? Just the number? This would allow people to make an accurate progress bar while loading if they put draw and update/flip code inside the map callback.

  • Upvote 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...