osg for android学习之:配置插件

1. 例子的osgmainapp.hpp中有有如下语句:

//Static plugins Macro
USE_OSGPLUGIN(ive)
USE_OSGPLUGIN(osg)
USE_OSGPLUGIN(osg2)
USE_OSGPLUGIN(terrain)
USE_OSGPLUGIN(rgb)
USE_OSGPLUGIN(OpenFlight)
USE_OSGPLUGIN(dds)
//xu added
USE_OSGPLUGIN(tga)
//USE_OSGPLUGIN(shp)
//USE_OSGPLUGIN(dxf)
//USE_OSGPLUGIN(tiff)
//USE_OSGPLUGIN(png)
USE_OSGPLUGIN(gdal)
USE_OSGPLUGIN(jpeg)

//Static DOTOSG
USE_DOTOSGWRAPPER_LIBRARY(osg)
USE_DOTOSGWRAPPER_LIBRARY(osgFX)
USE_DOTOSGWRAPPER_LIBRARY(osgParticle)
USE_DOTOSGWRAPPER_LIBRARY(osgTerrain)
USE_DOTOSGWRAPPER_LIBRARY(osgText)
USE_DOTOSGWRAPPER_LIBRARY(osgViewer)
USE_DOTOSGWRAPPER_LIBRARY(osgVolume)
//Static serializer
USE_SERIALIZER_WRAPPER_LIBRARY(osg)
USE_SERIALIZER_WRAPPER_LIBRARY(osgAnimation)
USE_SERIALIZER_WRAPPER_LIBRARY(osgFX)
USE_SERIALIZER_WRAPPER_LIBRARY(osgManipulator)
USE_SERIALIZER_WRAPPER_LIBRARY(osgParticle)
USE_SERIALIZER_WRAPPER_LIBRARY(osgTerrain)
USE_SERIALIZER_WRAPPER_LIBRARY(osgText)
USE_SERIALIZER_WRAPPER_LIBRARY(osgVolume)



结果查看osg源码

对应的宏定义如下:


#define USE_OSGPLUGIN(ext) \
    extern "C" void osgdb_##ext(void); \
    static osgDB::PluginFunctionProxy proxy_##ext(osgdb_##ext);


#define USE_DOTOSGWRAPPER(classname) \
    extern "C" void dotosgwrapper_##classname(void); \
    static osgDB::PluginFunctionProxy proxy_dotosgwrapper_##classname(dotosgwrapper_##classname);


#define USE_DOTOSGWRAPPER_LIBRARY(libname) \
    extern "C" void dotosgwrapper_library_##libname(void); \
    static osgDB::PluginFunctionProxy proxy_dotosgwrapper_library_##libname(dotosgwrapper_library_##libname);


#define USE_SERIALIZER_WRAPPER(classname) \
    extern "C" void wrapper_serializer_##classname(void); \
    static osgDB::PluginFunctionProxy proxy_serializer_##classname(wrapper_serializer_##classname);


#define USE_SERIALIZER_WRAPPER_LIBRARY(libname) \
    extern "C" void wrapper_serializer_library_##libname(void); \
    static osgDB::PluginFunctionProxy proxy_serializer_library_##libname(wrapper_serializer_library_##libname);


#define USE_COMPRESSOR_WRAPPER(classname) \
    extern "C" void wrapper_serializer_##classname(void); \
    static osgDB::PluginFunctionProxy proxy_compressor_##classname(wrapper_compressor_##classname);


#define REGISTER_OSGPLUGIN(ext, classname) \
    extern "C" void osgdb_##ext(void) {} \
    static osgDB::RegisterReaderWriterProxy<classname> g_proxy_##classname;


#define REGISTER_OSGIMAGEPROCESSOR(ext, classname) \
    extern "C" void osgdb_##ext(void) {} \
    static osgDB::RegisterImageProcessorProxy<classname> g_proxy_##classname;

配置文件如下:

LOCAL_PATH := $(call my-dir)
### 必须位于Android.mk文件的最开始。它是用来定位源文件的位置,$(call my-dir)的作用就是返回当前目录的路径。
include $(CLEAR_VARS)
### 清除一些变量的值,但是LOCAL_PATH除外。
###指定当前待编译模块的名称
LOCAL_MODULE    := osgNativeLib
### Main Install dir
OSG_ANDROID_DIR := D:/osggles1
LIBDIR := $(OSG_ANDROID_DIR)/obj/local/armeabi


ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
LIBDIR := $(OSG_ANDROID_DIR)/obj/local/armeabi-v7a
endif


### Add all source file names to be included in lib separated by a whitespace


### LOCAL_C_INCLUDES 额外的C/C++编译头文件路径
LOCAL_C_INCLUDES:= $(OSG_ANDROID_DIR)/include


### 为C/C++编译器定义额外的标志(如宏定义)
LOCAL_CFLAGS    := -Werror -fno-short-enums


### 传递额外的标志给C++编译器
LOCAL_CPPFLAGS  := -DOSG_LIBRARY_STATIC 


###LOCAL_LDLIBS 为可执行程序或者库的编译指定额外的库,指定库以"-lxxx"格式,举例: LOCAL_LDLIBS += -lcurses -lpthread
LOCAL_LDLIBS    := -llog -lGLESv1_CM -ldl -lz -lgnustl_static


### LOCAL_SRC_FILES 指定参与编译的源代码文件
LOCAL_SRC_FILES := osgNativeLib.cpp OsgMainApp.cpp OsgAndroidNotifyHandler.cpp PersonWalkManipulator.cpp ManipulatorTerrain.cpp


### LOCAL_LDFLAGS 传递额外的参数给连接器(务必注意参数的顺序)
LOCAL_LDFLAGS   := -L $(LIBDIR) \
-losgdb_dds \
-losgdb_openflight \
-losgdb_tga \
-losgdb_jpeg \
-losgdb_gdal \
-losgdb_rgb \
-losgdb_osgterrain \
-losgdb_osg \
-losgdb_osga \
-losgdb_ive \
-losgdb_deprecated_osgviewer \
-losgdb_deprecated_osgvolume \
-losgdb_deprecated_osgtext \
-losgdb_deprecated_osgterrain \
-losgdb_deprecated_osgsim \
-losgdb_deprecated_osgshadow \
-losgdb_deprecated_osgparticle \
-losgdb_deprecated_osgfx \
-losgdb_deprecated_osganimation \
-losgdb_deprecated_osg \
-losgdb_serializers_osgvolume \
-losgdb_serializers_osgtext \
-losgdb_serializers_osgterrain \
-losgdb_serializers_osgsim \
-losgdb_serializers_osgshadow \
-losgdb_serializers_osgparticle \
-losgdb_serializers_osgmanipulator \
-losgdb_serializers_osgfx \
-losgdb_serializers_osganimation \
-losgdb_serializers_osg \
-losgViewer \
-losgVolume \
-losgTerrain \
-losgText \
-losgShadow \
-losgSim \
-losgParticle \
-losgManipulator \
-losgGA \
-losgFX \
-losgDB \
-losgAnimation \
-losgUtil \
-losg \
-lcurl \
-lOpenThreads \
-lgdal \
-ljpeg


你可能感兴趣的:(osg for android学习之:配置插件)