more than one object in a scene

what am i doing wrong. i want to be able to see the two spheres but only one appear can you help a novice please?

#include <windows.h>
#include <gl/glut.h>

void sheep(void) //draw scene
{

glClear(GL_COLOR_BUFFER_BIT);//clear window
glScalef(0.8f,1.0f,1.0f);
glColor3f(1.0f,1.0f,1.0f);
GLUquadricObj *sheepBody;
sheepBody = gluNewQuadric();
gluSphere(sheepBody,30, 30, 30);


glTranslatef(20.0f,30.0f,0.0f);
glScalef(1.0f,0.8f,1.0f);
glColor3f(0.0f,0.0f,0.0f);
GLUquadricObj *sheepHead;
sheepHead = gluNewQuadric();
gluSphere(sheepHead,10, 10, 10);

}

void SetupRC(void) //setup rendering state
{
glClearColor(0.0f,0.0f,1.0f,1.0f);
}

void ChangeSize(GLsizei w, GLsizei h)
{
GLfloat nRange = 100.0f;
//GLfloat fAspect;

if(h==0)
	h=1;

glViewport(0,0,w,h);

//fAspect = (GLfloat)w/GLfloat)h;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

	gluPerspective(0.0f,0.0f,1.0,425.0);

if (w &lt;= h)
	glOrtho (-nRange,nRange,-nRange*h/w,nRange*h/w,-nRange,nRange);
else
	glOrtho (-nRange*w/h,nRange*w/h,-nRange,nRange,-nRange,nRange);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

}

void main(void) //program entry point
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow(“Sheep”);
glutDisplayFunc(sheep);
glutReshapeFunc(ChangeSize);

SetupRC();

glutMainLoop();

}

Use either orthographic or perspective projection, but not both of them at the same time. Of course, uless you know what you’re doing, and that’s what you want.

Do this:

glPushMatrix();
glClear(GL_COLOR_BUFFER_BIT);//clear window
glScalef(0.8f,1.0f,1.0f);
glColor3f(1.0f,1.0f,1.0f);
GLUquadricObj *sheepBody;
sheepBody = gluNewQuadric();
gluSphere(sheepBody,30, 30, 30);
glPopMatrix();

glPushMatrix();
glTranslatef(20.0f,30.0f,0.0f);
glScalef(1.0f,0.8f,1.0f);
glColor3f(0.0f,0.0f,0.0f);
GLUquadricObj *sheepHead;
sheepHead = gluNewQuadric();
gluSphere(sheepHead,10, 10, 10);
glPopMatrix();

[This message has been edited by WhatEver (edited 12-01-2001).]

thanks for the help guys, i just needed to flush the buffer and i was there. still having problems getting perpective to work rather than ortho.

Another thing that you can do to speed up the program would be to make only one GLUquadricObj object… it does not store any geometry of the object that you are trying to draw.