Ogre 1.9 threads support

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Ogre 1.9 threads support

Post by joe70 »

Hi, Ogre fanatics
I installed Ogre 1.9 with .deb packages on Debian. Now, I'd like to enable threads support. How can i change OGRE_CONFIG_THREADS value? How can I know the OGRE_CONFIG_THREADS value now (settings default in .deb packages)?
I don't want to install Ogre 1.9 src from sources tarball. I have installed libboost-thread-dev 1.62.0.1

Thanks in advance.
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Ogre 1.9 threads support

Post by sercero »

Hello,

Check the files:

Code: Select all

/usr/include/OGRE/OgreBuildSettings.h
/usr/include/OGRE/OgreConfig.h
And look for the following:

Code: Select all

#define OGRE_THREAD_SUPPORT 0
The number indicates what level of threading support the library was compiled with by the Debian mantainers.
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Re: Ogre 1.9 threads support

Post by joe70 »

Thanks again, Sercero

In OgreBuildSettings.h -->

Code: Select all

#define OGRE_THREAD_SUPPORT 2
In OgreConfig.h -->

Code: Select all

#ifndef OGRE_THREAD_SUPPORT
#define OGRE_THREAD_SUPPORT 0
#endif
#if OGRE_THREAD_SUPPORT != 0 && OGRE_THREAD_SUPPORT != 1 && OGRE_THREAD_SUPPORT != 2
#define OGRE_THREAD_SUPPORT 0
#endif
I think that debian mantainers built deb package with 2 but, now the current value in OgreConfig.h is 0 ¿can I change the value in OgreConfig.h for thread support for background loading, isn't it?
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Ogre 1.9 threads support

Post by sercero »

I think that you already have thread support for background loading, check the OGRE log file for something like this:

Code: Select all

23:15:37: DefaultWorkQueue('Root') initialising on thread 1.
23:15:37: Particle Renderer Type 'billboard' registered
23:15:37: DefaultWorkQueue('Root')::WorkerFunc - thread 2 starting.
23:15:37: DefaultWorkQueue('Root')::WorkerFunc - thread 3 starting.
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Re: Ogre 1.9 threads support

Post by joe70 »

Thanks one more time, sercero
I've loaded music with SDL (wrapper) with the next code:

Code: Select all

...
// Carga en segundo plano y listener
  trackPtr->setBackgroundLoaded(true);
  trackPtr->addListener(new MyListener);

  // Escala la carga del recurso en segundo plano.
  if (trackPtr->isBackgroundLoaded()) {
    trackPtr->escalateLoading();
  }
  else {
    trackPtr->load();
    std::cout << "Estoy aquí!" << std::endl;
  }
  ....
There's a listener too

Code: Select all

#include <OGRE/OgreResource.h>

class MyListener : public Ogre::Resource::Listener {
  void loadingComplete (Ogre::Resource* r) {
    std::cout << "\n\t ***** ¡Carga en segundo plano completada! *****\n" << std::endl;
    // TODO
  }
and looking for in Ogre.log

Code: Select all

DefaultWorkQueue('Root') initialising on thread 7f7332bb9e00.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f757d700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f657b700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f7d7e700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f6d7c700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f4d78700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f5d7a700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f5579700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f1d7a700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f1579700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f0d78700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f2d74700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f3d76700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f4577700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f3575700 starting.
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72f0577700 starting.
19:15:38: Particle Renderer Type 'billboard' registered
19:15:38: DefaultWorkQueue('Root')::WorkerFunc - thread 7f72efd76700 starting.
19:15:38: Added resource location 'media' of type 'FileSystem' to resource group 'General'
and showing console out

Code: Select all

Finished parsing scripts for resource group Internal
Creating resources for group Internal
All done

	 ***** ¡Carga en segundo plano completada! *****
...
The thread support for background loading seems be running right isn't it?
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Ogre 1.9 threads support

Post by sercero »

It seems so, I'm not an expert on this subject.
Post Reply