/* transparent teapot demo by Ingemar Ragnemalm*/#ifdef __APPLE__	#include <GLUT/glut.h>//	#include <OpenGL/gl.h>#else	#include <GL/glut.h>//	#include <GL/gl.h>#endif#include <math.h>GLfloat angle = 0.0;// For file management#include <stdio.h>#include <stdlib.h>int setting = 1;void display(){	GLfloat s = sin(angle);	GLfloat c = cos(angle);		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		glMatrixMode(GL_MODELVIEW);	// Save the current state	glPushMatrix();		glRotatef(angle, 1,1,1);	glScalef(-1, 1, 1); // Teapot is inside out// 3 cases: no culling, culling and draw fronts, culling and draw first backs, then fronts	glDisable(GL_CULL_FACE);//	glEnable(GL_CULL_FACE);	glCullFace(GL_FRONT); //	glutSolidTeapot(1); //	glCullFace(GL_BACK);	glutSolidTeapot(1);		glPopMatrix();		glutSwapBuffers();}void timer(int i){	angle += 1.0;	glutTimerFunc(20, timer, i);	glutPostRedisplay();}void keyboard(unsigned char key, int x, int y){	switch (key)	{	case 27:		exit(0);	case '1':		setting = 1; break;	case '2':		setting = 2; break;	case '3':		setting = 3; break;	}}void reshape(int w, int h){	glViewport (0, 0, (GLsizei) w, (GLsizei) h);	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	glFrustum(-0.7, 0.7, -0.7, 0.7, 1, 20);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();	gluLookAt(0,0,3, 0,0,0, 0,1,0); // camera, look-at-point, up-vector}	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };	GLfloat mat_shininess[] = { 10.0 };	GLfloat light_position[] = { 1.0, 1.0, 2.0, 0.0 }; // ljuset gŒr frŒn det hŒllet?// A simple texture	GLubyte minitex4[4][4][3] =	{		{ {255,  0,255}, {  0,  0,255}, {  0,  0,255}, {  0,255,255}},		{ {  0,  0,255}, {255,  0,255}, {  0,255,255}, {  0,  0,255}},		{ {  0,  0,255}, {  0,255,255}, {255,  0,255}, {  0,  0,255}},		{ {  0,255,255}, {  0,  0,255}, {  0,  0,255}, {255,  0,255}},	};// Texture with transparency	GLubyte minitexrgba[4][4][4] =	{		{ {255,  0,255, 255}, {  0,  0,255, 128}, {  0,  0,255, 128}, {  0,255,255, 255}},		{ {  0,  0,255, 128}, {255,  0,255, 0}, {  0,255,255, 0}, {  0,  0,255, 128}},		{ {  0,  0,255, 128}, {  0,255,255, 0}, {255,  0,255, 0}, {  0,  0,255, 128}},		{ {  0,255,255, 255}, {  0,  0,255, 128}, {  0,  0,255, 128}, {255,  0,255, 255}},	};	GLfloat planeS[] = {2.5, 0.0, 0.0, 0.5};	GLfloat planeT[] = {0.0, 0.0, 2.5, 0.5};	int main(int argc, char **argv){	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);	glutInitWindowSize(500, 500);	glutCreateWindow("simple9");		// Set the background color	glClearColor(0.5, 0.7, 0.5, 0);	glClearColor(1.0, 1.0, 1.0, 0);		// Various initializations, enable OpenGL features	glShadeModel(GL_SMOOTH);//	glEnable(GL_CULL_FACE);	glCullFace(GL_BACK);// ***********	glCullFace(GL_FRONT);	glEnable(GL_DEPTH_TEST);// ***********		glEnable(GL_BLEND);	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);			glEnable(GL_NORMALIZE); // if we can't guarantee normal vectors to have unit length		// Turn on the light	glEnable(GL_LIGHTING);	glEnable(GL_LIGHT0);//	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);		glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);	glLightfv(GL_LIGHT0, GL_POSITION, light_position);		glEnable(GL_TEXTURE_2D);		// Install textures//	glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, minitex4);//	glTexImage2D(GL_TEXTURE_2D, 0, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, minitex2);		glTexImage2D(GL_TEXTURE_2D, 0, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, minitexrgba);		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);//	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);		glEnable(GL_TEXTURE_GEN_S);	glEnable(GL_TEXTURE_GEN_T);	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);		glTexGenfv(GL_S, GL_OBJECT_PLANE, planeS);	glTexGenfv(GL_S, GL_OBJECT_PLANE, planeT);		// Install GLUT callback functions	glutDisplayFunc(display);	glutReshapeFunc(reshape);	glutTimerFunc(20, timer, 0);	glutKeyboardFunc(keyboard);		// Run!	glutMainLoop();	return 0;}