當前位置: 首頁>>代碼示例>>C++>>正文


C++ AAssetManager_fromJava函數代碼示例

本文整理匯總了C++中AAssetManager_fromJava函數的典型用法代碼示例。如果您正苦於以下問題:C++ AAssetManager_fromJava函數的具體用法?C++ AAssetManager_fromJava怎麽用?C++ AAssetManager_fromJava使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AAssetManager_fromJava函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Java_org_gearvrf_NativeImporter_readFileFromAssets

JNIEXPORT jlong JNICALL
Java_org_gearvrf_NativeImporter_readFileFromAssets(JNIEnv * env,
        jobject obj, jobject asset_manager, jstring filename) {
    const char* native_string = env->GetStringUTFChars(filename, 0);
    AAssetManager* mgr = AAssetManager_fromJava(env, asset_manager);
    AAsset* asset = AAssetManager_open(mgr, native_string, AASSET_MODE_UNKNOWN);
    if (NULL == asset) {
        LOGE("_ASSET_NOT_FOUND_");
        return JNI_FALSE;
    }
    long size = AAsset_getLength(asset);
    char* buffer = (char*) malloc(sizeof(char) * size);
    AAsset_read(asset, buffer, size);

    AssimpImporter* assimp_scene = Importer::readFileFromAssets(
            buffer, size);

    AAsset_close(asset);

    free(buffer);

    env->ReleaseStringUTFChars(filename, native_string);

    return reinterpret_cast<jlong>(assimp_scene);
}
開發者ID:Bonch90,項目名稱:GearVRf,代碼行數:25,代碼來源:importer_jni.cpp

示例2: EnginePrepare

static jboolean EnginePrepare(JNIEnv* env, jclass clzz, jobject assetsMgr/*AAssetManager*/,
	jstring filesRoot, jobjectArray plugins /*String[]*/)
{
	AAssetManager* mgr = AAssetManager_fromJava(env, assetsMgr);
	int count = env->GetArrayLength(plugins);
	vector<string> _plugins;
	for (int i = 0; i < count; i++ ) {
		jstring ck_plugin = (jstring)env->GetObjectArrayElement(plugins, i);
		string _plgin;
		GET_CPPSTR_FROM_JSTR(env, ck_plugin, _plgin);
		_plugins.push_back(_plgin);
	}
	string filesroot_str;
	GET_CPPSTR_FROM_JSTR(env, filesRoot, filesroot_str);

	try {
		Vm::android_init(mgr, filesroot_str.c_str(), _plugins);
		return true;
	}
	catch( const vedit::Exception& e ) {
		gHook.last_error = "engine prepare failed. cause:";
		gHook.last_error += e.what();
		return false;
	}
}
開發者ID:amongll,項目名稱:AVFX,代碼行數:25,代碼來源:VEditVM_android.cpp

示例3: Java_co_theengine_loomdemo_LoomDemo_nativeSetPaths

 void Java_co_theengine_loomdemo_LoomDemo_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath, jobject am)
 {
     const char *str = env->GetStringUTFChars(apkPath, NULL);
     //cocos2d::CCFileUtils::sharedFileUtils()->setResourcePath(str);
     env->ReleaseStringUTFChars(apkPath, str);
     loom_setAssetManager(AAssetManager_fromJava(env, am));
 }
開發者ID:RichardRanft,項目名稱:LoomSDK,代碼行數:7,代碼來源:core.cpp

示例4: Java_org_linaro_glmark2_native_getSceneInfo

jobjectArray
Java_org_linaro_glmark2_native_getSceneInfo(JNIEnv* env, jclass clazz,
        jobject asset_manager)
{
    static_cast<void>(clazz);

    Util::android_set_asset_manager(AAssetManager_fromJava(env, asset_manager));

    std::vector<Scene*> scenes;
    DummyCanvas canvas;
    std::vector<jobject> si_vector;

    create_and_add_scenes(scenes, canvas);

    /* Create SceneInfo instances for all the scenes */
    for (std::vector<Scene*>::const_iterator iter = scenes.begin();
            iter != scenes.end();
            iter++)
    {
        jobject si = scene_info_from_scene(env, **iter);
        si_vector.push_back(si);
    }

    /* Create a SceneInfo[] array */
    jclass si_cls = env->FindClass("org/linaro/glmark2/SceneInfo");
    jobjectArray si_array = env->NewObjectArray(si_vector.size(), si_cls, 0);

    /* Populate the SceneInfo[] array */
    for (size_t i = 0; i < si_vector.size(); i++)
        env->SetObjectArrayElement(si_array, i, si_vector[i]);

    Util::dispose_pointer_vector(scenes);

    return si_array;
}
開發者ID:rafalmiel,項目名稱:glmark2-wl,代碼行數:35,代碼來源:android.cpp

示例5: setupJniEnv

void setupJniEnv(JNIEnv* _jniEnv, jobject _tangramInstance, jobject _assetManager) {
    _jniEnv->GetJavaVM(&jvm);
    JNIEnv* jniEnv = _jniEnv;
    jniRenderThreadEnv = _jniEnv;

    tangramInstance = jniEnv->NewGlobalRef(_tangramInstance);
    jclass tangramClass = jniEnv->FindClass("com/mapzen/tangram/MapController");
    startUrlRequestMID = jniEnv->GetMethodID(tangramClass, "startUrlRequest", "(Ljava/lang/String;J)Z");
    cancelUrlRequestMID = jniEnv->GetMethodID(tangramClass, "cancelUrlRequest", "(Ljava/lang/String;)V");
    getFontFilePath = jniEnv->GetMethodID(tangramClass, "getFontFilePath", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
        requestRenderMethodID = _jniEnv->GetMethodID(tangramClass, "requestRender", "()V");
    setRenderModeMethodID = _jniEnv->GetMethodID(tangramClass, "setRenderMode", "(I)V");
    featureSelectionCbMID = _jniEnv->GetMethodID(tangramClass, "featureSelectionCb", "(Lcom/mapzen/tangram/Properties;)V");

    jclass propertiesClass = jniEnv->FindClass("com/mapzen/tangram/Properties");

    propertiesConstructorMID = jniEnv->GetMethodID(propertiesClass, "<init>", "(JZ)V");

    assetManager = AAssetManager_fromJava(jniEnv, _assetManager);

    if (assetManager == nullptr) {
        logMsg("ERROR: Could not obtain Asset Manager reference\n");
    }

}
開發者ID:zerebubuth,項目名稱:tangram-es,代碼行數:25,代碼來源:platform_android.cpp

示例6: Archive

AssetArchive::AssetArchive(const String& name, AssetArchive* parent, const String& dir)
: Archive(name)
{
	JNIEnv* env = g_AndroidJNI->getEnv();

	if (parent->_assetManagerRef)
	{
		_assetManagerRef = env->NewGlobalRef(parent->_assetManagerRef);
		_assetManager = AAssetManager_fromJava(env, _assetManagerRef);
	}
	else
	{
		_assetManagerRef = NULL;
		_assetManager = parent->_assetManager;
	}

	_fixCaseProblem = parent->_fixCaseProblem;
	_dir = dir;

	if (!_dir.empty())
	{
		FileUtil::normalizeSeparator(_dir);

		// Make sure base to be 'path/' from
		if (_dir[_dir.length()-1] != FileUtil::getPathSeparator())
			_dir += FileUtil::getPathSeparator();

		if (StringUtil::endsWith(_dir, FileUtil::getDamnedPattern1()))
			_dir.erase(_dir.size() - FileUtil::getDamnedPattern1().length());
	}

	load();
}
開發者ID:noriter,項目名稱:nit,代碼行數:33,代碼來源:AndroidSupport.cpp

示例7: Java_com_torchandroid_neuraltalk_lua_LuaManager_initTorch

JNIEXPORT long JNICALL
Java_com_torchandroid_neuraltalk_lua_LuaManager_initTorch(JNIEnv *env, jobject thiz, jobject assetManager, jstring nativeLibraryDir_)
{
	// get native asset manager. This allows access to files stored in the assets folder
	AAssetManager* manager = AAssetManager_fromJava(env, assetManager);
	assert( NULL != manager);
	const char *nativeLibraryDir = env->GetStringUTFChars(nativeLibraryDir_, 0);
	lua_State *L = NULL;
	L = inittorch(manager, nativeLibraryDir);// create a lua_State

	// load and run file
	char file[] = "init-only.lua";
	int ret;
	long size = android_asset_get_size(file);
	if (size != -1) {
		char *filebytes = android_asset_get_bytes(file);
		ret = luaL_dobuffer(L, filebytes, size, "init-only");
		if (ret == 1) {
			D("Torch Error doing resource: %s\n", file);
			D(lua_tostring(L,-1));
		} else {
			D("Torch script ran successfully.");
		}
	}
	return (long) L;
}
開發者ID:mseyed,項目名稱:torch-android-neuraltalk,代碼行數:26,代碼來源:torchdemo.cpp

示例8: Java_com_android_accelerometergraph_AccelerometerGraphJNI_init

JNIEXPORT void JNICALL
    Java_com_android_accelerometergraph_AccelerometerGraphJNI_init(
                     JNIEnv *env, jclass type, jobject assetManager) {
        (void)type;
        AAssetManager *nativeAssetManager = AAssetManager_fromJava(env, assetManager);
        gSensorGraph.init(nativeAssetManager);
    }
開發者ID:cRAN-cg,項目名稱:android-ndk,代碼行數:7,代碼來源:sensorgraph.cpp

示例9: LoadAssetDir

static jboolean LoadAssetDir(JNIEnv* env, jclass clazz, jobject assetmgr/*AssetManager*/, jstring assetDir)
{
	if (assetDir == NULL || assetmgr == NULL) {
		gHook.last_error = "empty arguments wen loadAssetDir";
		return false;
	}

	string dir;
	GET_CPPSTR_FROM_JSTR(env, assetDir, dir);

	if (dir.size() == 0) {
		gHook.last_error = "empty arguments wen loadAssetDir";
		return false;
	}

	AAssetManager* mgr = AAssetManager_fromJava(env, assetmgr);

	try {
		Vm::load_script_assets_dir(mgr, dir.c_str());
		return true;
	}
	catch(const vedit::Exception& e)
	{
		ostringstream oss;
		oss << "loadFileDir failed, cause:"<<e.what();
		gHook.last_error = oss.str();
		return false;
	}
}
開發者ID:amongll,項目名稱:AVFX,代碼行數:29,代碼來源:VEditVM_android.cpp

示例10: Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate

JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) {
    qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId();
    g_assetManager = AAssetManager_fromJava(env, asset_mgr);
    auto oldMessageHandler = qInstallMessageHandler(tempMessageHandler);
    unpackAndroidAssets();
    qInstallMessageHandler(oldMessageHandler);
}
開發者ID:ZappoMan,項目名稱:hifi,代碼行數:7,代碼來源:native.cpp

示例11: Java_com_intel_deferredgles_JNIWrapper_init_1asset_1manager

JNIEXPORT void JNICALL Java_com_intel_deferredgles_JNIWrapper_init_1asset_1manager(JNIEnv * env, jobject obj, jobject assetManager)
{
    _asset_manager = AAssetManager_fromJava(env, assetManager);

    UNUSED_PARAMETER(env);
    UNUSED_PARAMETER(obj);
}
開發者ID:gnlnx,項目名稱:OpenGL-ES-3.0-Deferred-Rendering,代碼行數:7,代碼來源:jni.c

示例12: Java_com_intel_textureloader_TextureLoaderLib_createAssetManager

JNIEXPORT void JNICALL Java_com_intel_textureloader_TextureLoaderLib_createAssetManager(JNIEnv* env, jobject obj, jobject assetManager)
{
    AAssetManager* mgr = AAssetManager_fromJava( env, assetManager );
    
    // Store the assest manager for future use.
    SetAssetManager( mgr );   
}
開發者ID:Cristianohh,項目名稱:ETC2TextureLoader,代碼行數:7,代碼來源:jni_main.c

示例13: Java_io_jxcore_node_jxcore_setNativeContext

JNIEXPORT void JNICALL
Java_io_jxcore_node_jxcore_setNativeContext(JNIEnv *env, jobject thiz,
                                            jobject context,
                                            jobject j_assetManager) {
  jxcore::JniHelper::setClassLoaderFrom(context);
  assetManager = AAssetManager_fromJava(env, j_assetManager);
}
開發者ID:heocon8319,項目名稱:thingengine-platform-android,代碼行數:7,代碼來源:jxcore.cpp

示例14: Java_com_example_android_nnapidemo_MainActivity_initModel

JNIEXPORT jlong
JNICALL
Java_com_example_android_nnapidemo_MainActivity_initModel(
        JNIEnv *env,
        jobject /* this */,
        jobject _assetManager,
        jstring _assetName) {
    // Get the file descriptor of the the model data file.
    AAssetManager *assetManager = AAssetManager_fromJava(env, _assetManager);
    const char *assetName = env->GetStringUTFChars(_assetName, NULL);
    AAsset *asset = AAssetManager_open(assetManager, assetName, AASSET_MODE_BUFFER);
    if(asset == nullptr) {
        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to open the asset.");
        return 0;
    }
    env->ReleaseStringUTFChars(_assetName, assetName);
    off_t offset, length;
    int fd = AAsset_openFileDescriptor(asset, &offset, &length);
    AAsset_close(asset);
    if (fd < 0) {
        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
                            "Failed to open the model_data file descriptor.");
        return 0;
    }
    SimpleModel* nn_model = new SimpleModel(length, PROT_READ, fd, offset);
    if (!nn_model->CreateCompiledModel()) {
        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
                            "Failed to prepare the model.");
        return 0;
    }

    return (jlong)(uintptr_t)nn_model;
}
開發者ID:cRAN-cg,項目名稱:android-ndk,代碼行數:33,代碼來源:nn_sample.cpp

示例15: Java_com_torchandroid_facedemo_CameraClass_initTorch

    JNIEXPORT long JNICALL
    Java_com_torchandroid_facedemo_CameraClass_initTorch(JNIEnv *env, jobject thiz, jobject assetManager)
    {
        // get native asset manager. This allows access to files stored in the assets folder
        AAssetManager* manager = AAssetManager_fromJava(env, assetManager);
        assert( NULL != manager);

        lua_State *L = NULL;
        L = inittorch(manager); // create a lua_State

        // load and run file
        char file[] = "main.lua";
        int ret;
        long size = android_asset_get_size(file);
        if (size != -1) {
            char *filebytes = android_asset_get_bytes(file);
            ret = luaL_dobuffer(L, filebytes, size, "main");
            if (ret == 1) {
                D("Torch Error doing resource: %s\n", file);
                D(lua_tostring(L,-1));
            } else {
                D("Torch script ran succesfully.");
            }
        }
        lua_register(L,"parse",parse); //This function is used by main.lua.

        return (long) L;
    }
開發者ID:gokceneraslan,項目名稱:torch-android,代碼行數:28,代碼來源:torchdemo.cpp


注:本文中的AAssetManager_fromJava函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。