code for the menus:
//Glut Menu// submenu = glutCreateMenu(menu); glutAddMenuEntry("New", 2); glutAddMenuEntry("Load", 3); glutAddMenuEntry("Exit", 4); submenu2 = glutCreateMenu(menu); glutAddMenuEntry("Load", 5); menuip = glutCreateMenu(menu); glutAddSubMenu("File",submenu); glutAddSubMenu("Obj", submenu2); glutAttachMenu(GLUT_RIGHT_BUTTON); //Glut Menu//
*update*
ok I now have a some what working loader. I still need to add a box where you can enter the name of the file but other than that it uploads it to the screen.So far the image is only 2d on the screen but so ill need to fix that too. I wanted to load a cube from blender but for some reason the image drawn was not a cube. Did it get the obj data of the camera in blender or my draw method or my loader method needs some work...
Source of the loader:
//objLoader//void loadObj(char* filename) { char line[100]; FILE *fp; errno_t err; err = fopen_s(&fp,filename,"r"); cout << "opened: " << filename << endl; if(fp != NULL) { while(fgets(line,99,fp)) { if(line[0] == 'v') { sscanf(line, "%*c %f %f %f", &v[vertexCount].x, &v[vertexCount].y, &v[vertexCount].z); vertexCount++; }else{ sscanf(line, "%*c %d %d %d", &t[triangleCount].v1, &t[triangleCount].v2, &t[triangleCount].v3); triangleCount++; } } } fclose(fp); loadedFile = true;}//objLoader// //objLoader Draw// if(loadedFile = true) { glBegin(GL_TRIANGLES); for(int i = 0; i < triangleCount; i++) { glVertex3f(v[t.v1-1].x * 0.25, v[t.v1-1].y * 0.25, v[t.v1-1].z * 0.25); glVertex3f(v[t.v2-1].x * 0.25, v[t.v2-1].y * 0.25, v[t.v2-1].z * 0.25); glVertex3f(v[t.v3-1].x * 0.25, v[t.v3-1].y * 0.25, v[t.v3-1].z * 0.25); } glEnd(); glFlush(); } //objLoader Draw//
I tried doing a quick search for blender file loader dlls, since I would have imagined there would be one, but I had no such luck. Perhaps my googlfu isn't with me, today.