Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef _OPT_MARBLE
- osmGdi->bindFbo();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glLoadIdentity();
- int width = osmGdi->m_fbo->width(), height =osmGdi->m_fbo->height();// Reset The Projection Matrix
- glViewport(0, 0, width, height);
- // Calculate The Aspect Ratio Of The Window
- gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glLoadIdentity();
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
- /* glShadeModel(GL_SMOOTH);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glColor3d( 0.5, 0.6, 0.4 );
- //glEnable(GL_DEPTH_TEST);
- GLfloat lmodel_ambient[]={0.2,0.2,0.2,1.0};
- float spec[] = {0.5f, 0.0f, 0.0f, 0.5f};
- float diff[] = {0.5f, 0.4f, 0.3f, 1.0f};
- float shiness[] = { 90.0f };
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shiness);
- glEnable( GL_NORMALIZE );
- glPushMatrix();
- //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- /* glTranslated( _x, _y, _z );*/
- glScaled( 0.02, 0.02, 0.02 );
- // glMultMatrixd(m);
- // glEnable(GL_LIGHTING);
- /*
- GLfloat white_light[]={0.5,0.5,0.5,0.5};
- GLfloat green_light[]={0.0,0.5,0.0,0.5};
- GLfloat blue_light[]={0.0,0.0,0.5,0.5};
- glLightfv(GL_LIGHT0,GL_DIFFUSE,blue_light);
- glLightfv(GL_LIGHT0,GL_AMBIENT,green_light);
- glEnable(GL_LIGHT0);*/
- /* GLfloat light_position[4];
- light_position[0] = gdi()->camera()->pos().x();
- light_position[1] = gdi()->camera()->pos().y();
- light_position[2] = gdi()->camera()->pos().z();
- light_position[3] = 0.0;
- glLightfv(GL_LIGHT0,GL_POSITION,light_position);
- */
- for ( int i = 0; i < faces_.size(); ++i ) {
- // The current face might be a quad, polygon, or a triangle so we must
- // begin rendering based on the number of vertex points there are.
- if ( faces_[i].v_indices.size() == 3 ) glBegin( GL_TRIANGLES );
- else if ( faces_[i].v_indices.size() == 4 ) glBegin( GL_QUADS );
- else glBegin(GL_POLYGON);
- // Loop through all the points and draw.
- for ( int j = 0; j < faces_[i].v_indices.size(); ++j ) {
- if ( !faces_[i].n_indices.empty() )
- glNormal3d( normals_[faces_[i].n_indices[j]].x(),
- normals_[faces_[i].n_indices[j]].y(),
- normals_[faces_[i].n_indices[j]].z() );
- glVertex3d( vertices_[faces_[i].v_indices[j]].x(),
- vertices_[faces_[i].v_indices[j]].y(),
- vertices_[faces_[i].v_indices[j]].z() );
- }
- glEnd();
- }
- glPopMatrix();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // glDisable(GL_LIGHTING);
- // Reset The View
- /* glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
- glBegin(GL_TRIANGLES); // Drawing Using Triangles
- glVertex3f( 0.0f, 1.0f, 0.0f); // Top
- glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
- glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
- glEnd(); // Finished Drawing The Triangle
- glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
- glBegin(GL_QUADS); // Draw A Quad
- glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
- glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
- glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
- glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
- glEnd(); */ // Done Drawing The Quad
- osmGdi->fbo2Image().save("cap.png");
- osmGdi->releaseFbo();
- #else
- for ( int i = 0; i < faces_.size(); ++i ) {
- // The current face might be a quad, polygon, or a triangle so we must
- // begin rendering based on the number of vertex points there are.
- if ( faces_[i].v_indices.size() == 3 ) glBegin( GL_TRIANGLES );
- else if ( faces_[i].v_indices.size() == 4 ) glBegin( GL_QUADS );
- else glBegin(GL_POLYGON);
- // Loop through all the points and draw.
- for ( int j = 0; j < faces_[i].v_indices.size(); ++j ) {
- if ( !faces_[i].n_indices.empty() )
- glNormal3d( normals_[faces_[i].n_indices[j]].x(),
- normals_[faces_[i].n_indices[j]].y(),
- normals_[faces_[i].n_indices[j]].z() );
- glVertex3d( vertices_[faces_[i].v_indices[j]].x(),
- vertices_[faces_[i].v_indices[j]].y(),
- vertices_[faces_[i].v_indices[j]].z() );
- }
- glEnd();
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement