I want to sketch the below graph on the screen:
|----| sphere |----| / / / / / / cylinder / / / / angle = 45 | | | | | | cylinder | | | | | | ----------- cylinder -----------
My output:
/ / / / / / cylinder / / |-----| sphere / / angle = 45 |-----|
I will sketch the top part namely sphere with a cylinder. My code is below, please look and say what is wrong.
I have tried to find the error why my primitives do not near to each other. But, I could not find. I have tried to change parameters of translate, but it does not work. Please, help
void object(void) { GLUquadraticObj *t = gluNewQuadratic(); glTranslatef(-2.0f, -1.0f, 0.0f); gluCylinder(t, 0.1f, 0.1f, 0.3f, 32,32); gluSphere(t, 0.2f, 26, 13); } void display(void) { glLoadIdentity(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); object(); glPopMAtrix(); glPopMatrix(); glutSwapBuffers(); glFlush(); } void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f, w/h, 1.0, 500.0f); glLoadIdentity(); }