Difference between revisions of "CalVR Plugins"
Line 7: | Line 7: | ||
Use (CVRPlugins Dir)/calit2/ModelLoader as an example: | Use (CVRPlugins Dir)/calit2/ModelLoader as an example: | ||
− | + | Create a new directory named <YourPluginName>. Each source code directory have a file "CMakeLists.txt". In order for cmake to generate a makefile for the new plugin, we need to add an entry to the "CMakeLists.txt" in the parent directory. | |
− | Under the parent directory, e.g., | + | Under the parent directory, e.g., (CVRPlugins Dir)/calit2/CmakeLists.txt, add the following lines: |
− | OPTION(PLUGIN_EXAMPLEPLUGIN "ExamplePlugin" | + | OPTION(PLUGIN_EXAMPLEPLUGIN "ExamplePlugin" OFF) |
IF(PLUGIN_EXAMPLEPLUGIN) | IF(PLUGIN_EXAMPLEPLUGIN) | ||
Line 16: | Line 16: | ||
ENDIF(PLUGIN_EXAMPLEPLUGIN) | ENDIF(PLUGIN_EXAMPLEPLUGIN) | ||
− | + | Go to the root CVRPlugins directory and run: | |
− | + | ccmake . | |
− | + | Type 'c' to configure the project again. | |
+ | <br>Note that under the PLUGINS entry, the calit2 checkbox should be on. | ||
+ | <br>You should now see an option to build your new plugin. Set this option to ON, re-configure, then type 'g' to generate the new makefiles. | ||
+ | <br>You can now build your plugin by typing make. | ||
Now we need to modify the CalVR/config/config.xml to turn on the new plugin. We can search for ModelLoader and add the exact lines to config.xml, and modify the names to the new plugin's name. Now run CalVR, in the terminal we should see the init message of the new plugin. | Now we need to modify the CalVR/config/config.xml to turn on the new plugin. We can search for ModelLoader and add the exact lines to config.xml, and modify the names to the new plugin's name. Now run CalVR, in the terminal we should see the init message of the new plugin. |
Revision as of 11:37, 21 November 2011
Overview
In CalVR, new applications are added in the form of plugins. These plugin modules implement a virtual base class in the CalVR core and compile into a separate shared library. At runtime, this library is loaded and the plugin receives callbacks from the CalVR core through the implemented virtual functions.
Adding a new Plugin for CalVR
Use (CVRPlugins Dir)/calit2/ModelLoader as an example:
Create a new directory named <YourPluginName>. Each source code directory have a file "CMakeLists.txt". In order for cmake to generate a makefile for the new plugin, we need to add an entry to the "CMakeLists.txt" in the parent directory.
Under the parent directory, e.g., (CVRPlugins Dir)/calit2/CmakeLists.txt, add the following lines:
OPTION(PLUGIN_EXAMPLEPLUGIN "ExamplePlugin" OFF)
IF(PLUGIN_EXAMPLEPLUGIN) ADD_SUBDIRECTORY(ExamplePlugin) ENDIF(PLUGIN_EXAMPLEPLUGIN)
Go to the root CVRPlugins directory and run:
ccmake .
Type 'c' to configure the project again.
Note that under the PLUGINS entry, the calit2 checkbox should be on.
You should now see an option to build your new plugin. Set this option to ON, re-configure, then type 'g' to generate the new makefiles.
You can now build your plugin by typing make.
Now we need to modify the CalVR/config/config.xml to turn on the new plugin. We can search for ModelLoader and add the exact lines to config.xml, and modify the names to the new plugin's name. Now run CalVR, in the terminal we should see the init message of the new plugin.