Difference between revisions of "CalVR Plugins"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
Line 13: Line 13:
  
 
Under the parent directory, e.g., (CVRPlugins Dir)/calit2/CmakeLists.txt, add the following lines:
 
Under the parent directory, e.g., (CVRPlugins Dir)/calit2/CmakeLists.txt, add the following lines:
  OPTION(PLUGIN_EXAMPLEPLUGIN "ExamplePlugin" OFF)
+
  OPTION(PLUGIN_YOURPLUGINNAME "YourPluginName" OFF)
  
  IF(PLUGIN_EXAMPLEPLUGIN)
+
  IF(PLUGIN_YOURPLUGINNAME)
   ADD_SUBDIRECTORY(ExamplePlugin)
+
   ADD_SUBDIRECTORY(YourPluginName)
  ENDIF(PLUGIN_EXAMPLEPLUGIN)
+
  ENDIF(PLUGIN_YOURPLUGINNAME)
  
 
Go to the root CVRPlugins directory and run:
 
Go to the root CVRPlugins directory and run:

Revision as of 12:51, 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

Create a new directory named <YourPluginName>. Each source code directory must have a file "CMakeLists.txt".
For your plugin, use (CVRPlugins Dir)/calit2/ModelLoader/CMakeLists.txt as an example.
Change the LIB_NAME variable to be set to <YourPluginName> and replace the source and header files with those for your plugin.
If you need compile against other libraries, add entries for them with INCLUDE_DIRECTORIES and TARGET_LINK_LIBRARIES options.

In order for cmake to generate a makefile for the new plugin, we need to add an entries 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_YOURPLUGINNAME "YourPluginName" OFF)
IF(PLUGIN_YOURPLUGINNAME)
 ADD_SUBDIRECTORY(YourPluginName)
ENDIF(PLUGIN_YOURPLUGINNAME)

Go to the root CVRPlugins directory and run:

ccmake .

Type 'c' to configure the project again.
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 File to turn on the new plugin. Now run CalVR, in the terminal we should see the init message of the new plugin.