Sign in to follow this  

Please help

This topic is 4086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why the SECOND for loop square wont display one>?Please help Thanks static GLfloat xRot=0.0f; static GLfloat yRot=0.0f; //light values and co-ordinates GLfloat ambientLight[]={10.3f,10.3f,10.3f,10.0f}; GLfloat diffuseLight[]={10.7f,10.7f,10.7f,10.0f}; GLfloat specular[]={10.0f,10.0f,10.0f,10.0f}; GLfloat specref[]={10.0f,10.0f,10.0f,10.0f}; GLfloat xF=-60.0; GLfloat yS=-40.0; GLfloat xF1=-40.0; GLfloat yS1=-60.0; GLfloat a=80.0f; GLfloat b=80.0f; GLfloat c=60.0f; GLfloat d=60.0f; //reset flags as appropriate in response to menu selections //called to draw scene void DisplayScene(void) { //clear the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //SAVE MATRIX STATE AN DO THE ROTATION glPushMatrix(); glRotatef(xRot,1.0f,0.0f,0.0f); glRotatef(yRot,0.0f,1.0f,0.0f); glBegin(GL_QUADS); glColor3f(0.0f,0.0f,1.0f); // Draw A Quad glVertex3f(-80.0f, 80.0f,0.0f); // Top Left glVertex3f( 80.0f, 80.0f, 0.0f); // Top Right glVertex3f( 80.0f,-80.0f, 0.0f); // Bottom Right glVertex3f(-80.0f,-80.0f, 0.0f); // Bottom Left for(int j=0;j<4;j++) { glColor3f(1.0f,1.0f,0.0f); glVertex3f(xF, a, 0.0f); glVertex3f(yS, b, 0.0f); glVertex3f(xF1,c, 0.0f); glVertex3f(yS1,d, 0.0f); xF+=40.0f; yS+=40.0f; xF1+=40.0f; yS1+=40.0f; } glEnd(); //Restore transformations glPopMatrix(); //Flush drawing commands glutSwapBuffers(); } void MyInit() { //Black background glClearColor(1.0f, 0.0f, 0.0f, 0.0f); //Enable depth testing glEnable(GL_DEPTH_TEST); //Enable lighting glEnable(GL_LIGHTING); //Setup and enable light 0 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glEnable(GL_LIGHT0); //Enable color tracking glEnable(GL_COLOR_MATERIAL); //Set material properties to follow glColor values glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); //All materials hereafter have full specular reflectivity //with a high shine glMaterialfv(GL_FRONT, GL_SPECULAR, specref); glMateriali(GL_FRONT, GL_SHININESS, 120); //set drawing color to blue glColor3ub(0, 0, 255); } void SpecialKeys(int key, int x, int y) { if(key == GLUT_KEY_UP) xRot -= 5.0f; if(key == GLUT_KEY_DOWN) xRot += 5.0f; if(key == GLUT_KEY_LEFT) yRot -= 5.0f; if(key == GLUT_KEY_RIGHT) yRot += 5.0f; //Refresh the window glutPostRedisplay(); } void ChangeSize(int w, int h) { GLfloat lightPos[] = {-50.0f, 50.0f, 100.0f, 1.0f}; GLfloat nRange = 100.9f; //Prevent a divide by zero if(h == 0) h = 1; //Set viewport to window dimensions glViewport(0, 0, w, h); //Reset projection matrix stack glMatrixMode(GL_PROJECTION); glLoadIdentity(); //Establish clipping volume(left, right, bottom, top, near, far) if(w <= h) glOrtho(-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange); else glOrtho(-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange); //Reset model view matrix stack glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLightfv(GL_LIGHT0, GL_POSITION, lightPos); } int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("Create Menu"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(DisplayScene); MyInit(); glutMainLoop(); return 0; }

Share this post


Link to post
Share on other sites
You should really read a book about c++,

your initial values of

GLfloat xF=-60.0;
GLfloat yS=-40.0;
GLfloat xF1=-40.0;
GLfloat yS1=-60.0;


are changed during drawing !!!!

Share this post


Link to post
Share on other sites

This topic is 4086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this