Obj *obj_load(char *filename) { FILE *file; Obj *objFile; objFile = obj_get_by_filename(filename); if (objFile) { objFile->used++; return objFile; } objFile = obj_new(); if (!objFile) { return NULL; } file = fopen(filename,"r"); if (file == NULL) { slog("failed to open file %s",filename); return NULL; } obj_file_get_counts(objFile,file); obj_allocate(objFile); obj_file_parse(objFile, file); fclose(file); return objFile; }
VALUE rho_ruby_create_object_with_id( VALUE klass, const char* szID ) { char ** ppString = NULL; VALUE valObj = obj_allocate(klass); Data_Get_Struct(valObj, char *, ppString); *ppString = xmalloc(strlen(szID)+1); strcpy(*ppString, szID); return valObj; }
Obj *obj_load(char *filename) { FILE *file; Obj *objFile; objFile = obj_get_by_filename(filename); if (objFile) { objFile->used++; return objFile; } objFile = obj_new(); if (!objFile) { return NULL; } file = fopen(filename,"r"); if (file == NULL) { slog("failed to open file %s",filename); return NULL; } obj_file_get_counts(objFile,file); /* slog("vertices: %i",objFile->num_vertices); slog("normals: %i",objFile->num_normals); slog("texels: %i",objFile->num_texels); slog("faces: %i",objFile->num_tris); */ obj_allocate(objFile); obj_file_parse(objFile, file); fclose(file); return objFile; }