bool texture_edit_click_bitmap_open(char *bitmap_name) { char err_str[256],sub_path[1024],path[1024]; // get bitmap if (state.mode==app_mode_map) { strcpy(sub_path,"Bitmaps/Textures"); } else { sprintf(sub_path,"Models/%s/Textures",model.name); } if (!dialog_file_open_run("Open a Bitmap",sub_path,"png",NULL,bitmap_name)) return(FALSE); // check bitmap file_paths_data(&file_path_setup,path,sub_path,bitmap_name,"png"); if (!bitmap_check(path,err_str)) { os_dialog_alert("Texture Error",err_str); return(FALSE); } return(TRUE); }
int counting_bloom_check_with_hash(counting_bloom_t *bloom, unsigned int *hashes) { unsigned int index, i, offset; for (i = 0; i < bloom->nfuncs; i++) { offset = i * bloom->counts_per_func; index = hashes[i] + offset; if (!(bitmap_check(bloom->bitmap, index, bloom->offset))) { return 0; } } return 1; }
int counting_bloom_check(counting_bloom_t *bloom, const char *s, size_t len) { unsigned int index, i, offset; unsigned int *hashes = bloom->hashes; dablooms_hash_func(bloom, s, len, hashes); for (i = 0; i < bloom->nfuncs; i++) { offset = i * bloom->counts_per_func; index = hashes[i] + offset; if (!(bitmap_check(bloom->bitmap, index, bloom->offset))) { return 0; } } return 1; }
int model_texture_pick(char *material_name,char *err_str) { int n,idx; char *c,path[1024],title[256],file_name[256]; texture_type *texture; // find a free texture or texture // that already has material name idx=-1; texture=model.textures; for (n=0; n!=max_model_texture; n++) { // a free texture if (texture->frames[0].bitmap.gl_id==-1) { if (idx==-1) idx=n; } // a used texture, check to see if // material already exists else { if (strcasecmp(texture->material_name,material_name)==0) return(n); } texture++; } if (idx==-1) return(0); // load texture and remember name texture=&model.textures[idx]; strcpy(texture->material_name,material_name); // pick a bitmap sprintf(title,"Select a PNG for Material: %s",material_name); if (!os_load_file(title,path,"png")) { strcpy(err_str,"No texture was choosen."); return(-1); } // is it good? if (!bitmap_check(path,err_str)) return(-1); // get the actual file name c=strrchr(path,'/'); if (c==NULL) c=strrchr(path,'\\'); if (c==NULL) { strcpy(file_name,"unknown"); } else { strcpy(file_name,(c+1)); c=strrchr(file_name,'.'); if (c!=NULL) *c=0x0; } // copy bitmaps to model folder // copy selected bitmap and any addition _n, _s, or _g files strcpy(texture->frames[0].name,file_name); texture_copy(path,texture->frames[0].name,NULL); texture_copy(path,texture->frames[0].name,"_n"); texture_copy(path,texture->frames[0].name,"_s"); texture_copy(path,texture->frames[0].name,"_g"); // open the textures model_refresh_textures(&model); return(idx); }