+ /* then, assuming we have successfully loaded everything, proceed to construct
+ * all the engine objects, which require access to the OpenGL context
+ */
+ if(flags & SCNLOAD_STAGE_GL) {
+ if(!loader_data) {
+ error_log("second stage scene loader failed to find valid I/O data\n");
+ return false;
+ }
+
+ LoaderData *ldata = (LoaderData*)loader_data;
+ const aiScene *aiscn = ldata->aiscn;
+ fname = ldata->fname.c_str();
+
+ // load all meshes
+ for(unsigned int i=0; i<aiscn->mNumMeshes; i++) {
+ aiMesh *aimesh = aiscn->mMeshes[i];
+ Mesh *mesh;
+
+ switch(aimesh->mPrimitiveTypes) {
+ case aiPrimitiveType_TRIANGLE:
+ if((mesh = load_mesh(this, aiscn, flags, aimesh))) {
+ ldata->mesh_by_aimesh[aimesh] = mesh;
+ meshes.push_back(mesh);
+ }
+ break;
+
+ default:
+ error_log("unsupported primitive type: %u\n", aimesh->mPrimitiveTypes);
+ break;
+ }
+ }