I made an object loader that can load textures from a material library file, but I am having trouble with the way the texture gets bound to the object. It will wrap around the object like I want, except for one part. The textures are being loaded properly too since I can bind the same texture to a box and not have a problem. A picture is below of where I am talking about, I get that weird sliver where it looks like the texture stretches. It does this for all my spheres of any shape or size. The function I use to bind, display, and render the texture and object is below too.
http://img.photobucket.com/albums/v4...22/texture.jpg
Code:bool LOADOBJ::RenderAllObjects() { if(head.size() == 0) return false; //nothing to render ObjectList *temp; //temp space for the render function int f_index = 0, f_index2 = 0; //face index, and non-changing face index /*render all objects to the screen*/ glPolygonMode( GL_BACK, GL_FILL ); //draw back face with lines glPolygonMode( GL_FRONT, GL_FILL ); //draw front face with lines for(unsigned int m = 0; m < head.size(); m++){ temp = head.front(); //get the front object head.pop(); //pop the front object head.push(temp); //then put it back in line for the next time it's rendered for(int i = 0; i < temp->face_count; i++){ if(temp->texture_id != NO_TEXTURE) //if there is a texture, bind it glBindTexture(GL_TEXTURE_2D,temp->texture_id); /*determine what type needs to be rendered*/ if(temp->vert_per_face[i] == 4) glBegin(GL_QUADS); //render squares else if(temp->vert_per_face[i] == 3) glBegin(GL_TRIANGLES); //render triangles else if(temp->vert_per_face[i] == 2) glBegin(GL_LINES); //render lines else if(temp->vert_per_face[i] == 1) glBegin(GL_POINTS); //render points else glBegin(GL_POLYGON); //if nothing else render a polygon (5 or more vertex) f_index2 = f_index; for(int n = f_index2; n < f_index2 + temp->vert_per_face[i]; n++){ /*create the 3D vertexes, textures, and normals*/ //if there is a texture to render, otherwise render the color if(temp->texture_id != NO_TEXTURE) glTexCoord2f(temp->vt_x [ temp->fvt[n]-1 ], temp->vt_y [ temp->fvt[n]-1 ]); else glColor3f(temp->vn_x [ temp->fvn[n]-1 ], //red color temp->vn_y [ temp->fvn[n]-1 ], //green color temp->vn_z [ temp->fvn[n]-1 ]); //blue color glVertex3f(0.01*temp->v_x [ temp->fv[n]-1 ], //x coordinate 0.01*temp->v_y [ temp->fv[n]-1 ], //y coordinate 0.01*temp->v_z [ temp->fv[n]-1 ]); //z coordinate glNormal3f(temp->vn_x [ temp->fvn[n]-1 ], //x normal temp->vn_y [ temp->fvn[n]-1 ], //y normal temp->vn_z [ temp->fvn[n]-1 ]); //z normal f_index++; } glEnd(); } //end for loop f_index2 = 0; f_index = 0; } return true; }



LinkBack URL
About LinkBacks


