Sign in to follow this  
  • entries
    10
  • comments
    12
  • views
    5511

82% done

Sign in to follow this  

212 views

Ok so the menus did not come out the way I like but I have menus now. To get the kind I want I will have to write my own in glut but for now if you use the mouse right button a menu pops up with options and such.

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...

Free Image Hosting at www.ImageShack.us

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//


Sign in to follow this  


2 Comments


Recommended Comments

Not sure if you've got the file format specs or not so this may be of some help.

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.

Share this comment


Link to comment
thx for the help but iv found a forum that had a example of the loader and with some tinkering made it work. i updated my post with the results. I just need to find out if its the obj file that was incorrect or my draw or loader method that is buged for making a some what incomplete cube.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now