Hello,
I need to render the mesh.It is given by set of its surfaces
each surface is presented by its vertexes(x,y,z)
The camera and light source has to be placed at the same place.
I use this code:

//Projection
                        glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
            

			GLdouble diam = m_allModels.getDiam();
			GLdouble left = m_allModels.getCenter()[0] - diam;
			GLdouble right = m_allModels.getCenter()[0] + diam;
			GLdouble bottom = m_allModels.getCenter()[1] - diam;
			GLdouble top = m_allModels.getCenter()[1] + diam;

            
			glFrustum(left,right,bottom,top,diam,diam*3.5);            
           
//Model
                         glMatrixMode(GL_MODELVIEW);
                         glLoadIdentity();
			 gluLookAt (0.0, 0.0,2*m_allModels.getDiam(),
			m_allModels.getCenter()[0],m_allModels.getCenter()[1],m_allModels.getCenter()[2],
			0.0, 1.0, 0.0);

//Lighting
			GLfloat light_position[] = {0.0, 0.0,0.0, 1.0 };
			GLfloat white_light[] = { 0.7, 0.3, 0.2, 1.0 };
			glEnable(GL_DEPTH_TEST);
			
			
			glEnable(GL_LIGHTING);
			glLightfv(GL_LIGHT1, GL_POSITION, light_position);
			glLightfv(GL_LIGHT1, GL_DIFFUSE, white_light);
			glEnable(GL_LIGHT1);
                        glShadeModel(GL_FLAT);
			
//Draw
			glEnable(GL_NORMALIZE);
                        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
//render here
for(unsigned int modelIdx = 0;modelIdx < m_allModels.zise();++modelIdx)
			{
				model curModel = m_allModels.getModel(modelIdx);
				for(unsigned int modelSurfIdx = 0;modelSurfIdx <curModel.surfNum();
					++modelSurfIdx)
				{
					surface curSurf = curModel.getSurface(modelSurfIdx);
					glLineWidth(2);
					glBegin( GL_POLYGON );

					
					glNormal3f(curSurf.getN_x(),curSurf.getN_y(),curSurf.getN_z());
					for(unsigned int vertIdx = 0;vertIdx< curSurf.size();++vertIdx)
					{
						unsigned int curVertIdx = curSurf.getSurfVertices()[vertIdx];
						vertex curVert = curModel.getVertex(curVertIdx);
						glVertex3f((GLfloat)curVert.getX(),(GLfloat)curVert.getY(),(GLfloat)curVert.getZ());
					}	
					glEnd();

				}
			}

And I get this
[Img]http://img17.imageshack.us/img17/1103/64347046.png[/IMG]
What I am doing wrong?

Looks like your vertices are not correct. Have you tried to load
a simple mesh first?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.