Writing an Application

To implement new applications on top of Realsoft 3D libraries you need to write main() function and initialize the application object.

The following demonstrates a minimal application:

    int main(int argc, char *argv[])
    {
        R3APP *app;

        app = R3AppCreate(&argc, &argv,
                          R3AA_AppIdentifier, "Realsoft3D",
                          R3AA_AppName, "Realsoft 3D",
                          ....
                          R3TAG_END);

        if(app) {
           R3Info("My dummy application works");
           R3AppDelete(app);
        }
        return 0;
    }

To build this application you need a makefile. The structure of makefiles for building applications is slightly different from the structure of makefiles for building plugins.

    R3APPLICATION=dummy

    CFILES=dummy.c
    CPPFILES=
    CCFILES=

    # include folders we need to see
    INCDIRS = \
        $(INCPRE)real/code 

    # list of link libraries we need
    INCLIBS = \
        $(LINKLIBPRE)r3code$(LINKLIBEXT) 

    # set TRUE for console based apps
    V4CONSOLE=

    !include $(V4HOME)/$(V4MKBIN).mak

    # dependencies
    dummy.o: dummy.c

To build the application, enter 'r3make'. Run it and you should see 'My dummy application works" message.

Note: this dummy app does not need r3code library. The library is included with the above makefile only as an example.

Using Plugin libraries

All libraries given in the makefile will be explicitely linked with the program so that you can then call the class registration functions implemented by the library in question

Plugin libraries cannot be linked explicitely. The reason for this is that they define only two external symbols: R3LibraryInit() and R3LibraryFree() and trying to link more than one plugin would result multiple defined symbol errors in linking.

An application has two choices to take advantage of plugin libraries. The first solution is to load all the plugin libraries by calling:


    R3RegisterExternalClasses(R3APP *app, char *path);

which attempts to load the plugins from the folder specified by the given path. If the 'path' is NULL, then the function uses the default plugin path defined by 'app'.

Another solution is to load only the plugins you need by calling R3LoadPluginLibrary(R3APP *app, char *name); function. where 'name' should be the base name of the library, exluding possible library prefix and file extension. For example:


    if(R3LoadPluginLibrary(app, "r3metab")) {
     ... 
    }