here is mainly code for reference.
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
makeStripeImage(); //draw strip texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage1D(GL_TEXTURE_1D, 0, 4, stripeImageWidth, 0,
GL_RGBA, GL_UNSIGNED_BYTE, stripeImage);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
currentCoeff = xequalzero;
currentGenMode = GL_OBJECT_LINEAR;
currentPlane = GL_OBJECT_PLANE;
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode);
glTexGenfv(GL_S, currentPlane, currentCoeff);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_1D);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
// glFrontFace(GL_CW);
// glCullFace(GL_BACK);
glMaterialf (GL_FRONT, GL_SHININESS, 64.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRasterPos2i(4,-3.5);
glDrawPixels(stripeImageWidth,32, GL_RGB, GL_UNSIGNED_BYTE, stripeImage);
//draw chechimage, but apear not.
glPushMatrix ();
glutSolidTeapot(2.0);
glTranslatef(2.0, 2.0, 0.0);
glColor3f(255, 0, 0);
glutSolidTeapot(1.0);
glTranslatef(-4, 1.0, 0.0);
glutSolidSphere(1.5, 22, 22);
//glutSolidDodecahedron(void);
glPopMatrix ();
glPushMatrix();
glTranslatef(-2.0f,-4.0f,0.0f);
glRotatef(-90.0f,1.0f,0.0f,0.0f);
glutSolidCone(2,3.5,20,20);
glPopMatrix();
glFlush();
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-5, 5, -5*(GLfloat)h/(GLfloat)w,
5*(GLfloat)h/(GLfloat)w, -5, 5); //3.5
else
glOrtho (-6.0*(GLfloat)w/(GLfloat)h,
6.0*(GLfloat)w/(GLfloat)h, -6.0, 6.0, -6.0, 6.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}