本文整理匯總了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);
}
示例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;
}
}
示例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));
}
示例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;
}
示例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");
}
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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 );
}
示例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);
}
示例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;
}
示例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;
}