コード例 #1
0
CEXPORT bool resource_loader_load_image_with_c(texture_2d * texture) {
	texture->pixel_data=NULL;

	bool skip = false;
	// check if it is a special url (text, contacts, etc.), if it is then load in java
	if (texture->url[0] == '@') {
		skip = true;
	} 

	if(!skip) {
		unsigned long sz;
		unsigned char *data = resource_loader_read_file(texture->url, &sz);

		texture->pixel_data = texture_2d_load_texture_raw(texture->url, data, sz, &texture->num_channels, &texture->width, &texture->height, &texture->originalWidth, &texture->originalHeight, &texture->scale);

		free(data);
	}

	// if we have pixel data...
	if (texture->pixel_data != NULL) {
		// load using C
		return true;
	} else {
		launch_remote_texture_load(texture->url);

		// using java
		return false;
	}
}
コード例 #2
0
CEXPORT char *resource_loader_string_from_url(const char *url) {
    // try loading from a file first
    char* contents = NULL;
    unsigned long dummy;
    contents = (char*)resource_loader_read_file(url, &dummy);
    if(contents == NULL) {
        // otherwise, pass it up to Java
        resource *res = resource_loader_load_url(url);
        if (res->text) {
            contents = strdup(res->text);
        }
        resource_loader_destroy_resource(res);
    }
    return contents;
}