Recently, for development reasons, we need to use ogre with multiple threads. Here we will briefly introduce how to compile ogre with multiple threads.
First, we need to note that ogre's support for multithreading is not aimed at improving rendering efficiency. After all, for real-time GPU-based rendering, the parallel execution of CPU load will not bring about any substantial improvement. More importantly, it aims to ensure the thread security in the multi-threaded applications that need to balance the CPU and GPU load, for example, you can share the viewpoint data or object motion data between the driver and the rendering thread, and load Resources in the background. So, to be more precise, the thread synchronization implemented by ogre is not multi-thread rendering.
Ogre supports multithreading in multiple ways, such as adding layers or plug-ins. For details, see Jeff Andrews's threading the ogre3d Render system. the most direct method is directly implemented by ogre main. This section describes how to compile and run the Ogre application under multiple threads.
In the following steps
The compiler uses vs2005 SP1
The ogre version is 1.4.6, which is more stable than 1.4.4 in terms of thread synchronization.
Boost version 1.34.1
The procedure is as follows:
1. Set
# Ifndef ogre_thread_support
# Define ogre_thread_support 1
# Endif
The second line is changed to 1, that is, the ogremain multi-thread support function is enabled;
2. Obtain and compile the boost_thread Library
Because ogremain supports multiple threads through the thread library in boost, ogre SDK can be compiled normally only when related files are required. Related files can be from http://sourceforge.net/project/showfiles.php? Group_id = 7586 download. The decompressed folder contains all the required header files and library files.
3. recompile the Ogre SDK
Before compilation, you need to set the include path to ensure that the compiler can find the header file of the boost library.
Copy the static library of boost_thread to the dependencies directory of ogre as follows:
Rename the boost_thread-vc80-mt-gd-1_34_1.lib to the libboost_thread-vc80-mt-gd-1_34_1.lib, that is, add the "lib" prefix, In the ogrenew \ dependencies \ Lib \ DEBUG directory;
Rename the boost_thread-vc80-mt-1_34_1.lib to the libboost_thread-vc80-mt-1_34_1.lib, that is, add the "lib" prefix, under the ogrenew \ dependencies \ Lib \ release directory;
You can re-compile the Ogre SDK after all settings. Of course, this will be a long wait process. You can compile the ogremain project separately and obtain the necessary library files, this saves some time for examples required for selective compilation.
4. Run Samples
Before running, you need to provide the dynamic library of boost_thread during runtime, as follows:
Place the boost_thread-vc80-mt-gd-1_34_1.dll in the ogrenew \ samples \ common \ bin \ DEBUG directory;
Place the boost_thread-vc80-mt-1_34_1.dll in the ogrenew \ samples \ common \ bin \ release directory;
Since the Ogre thread supports opening, the CPU overhead is actually increased to ensure thread synchronization. Therefore, when running the single-thread example of ogre that focuses on GPU rendering, when multithreading is enabled, the frame rate is usually decreased.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/rickArkin/archive/2008/01/16/2046735.aspx
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/pizi0475/archive/2011/05/09/6407400.aspx